Video transcoding method, video transcoding model training method and related equipment
By redefining the constant rate factor based on the image quality parameters after the first transcoding process during the video encoding process, the problem of poor adaptability of fixed CRF to different videos is solved, and the bandwidth saving effect is achieved while ensuring video quality.
Patent Information
- Application Number
- CN202311377233.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-23
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2043-10-23
AI Technical Summary
During the video encoding process, the fixed constant rate factor (CRF) has poor adaptability to different videos, resulting in excessive image quality of some videos and wasted bandwidth.
By first transcoding the video with a preset constant rate factor, the image quality parameters of the video to be processed are determined, and then the appropriate constant rate factor is redetermined based on the image quality parameter for the second transcoding.
While ensuring that the video quality is subjective and lossless, bandwidth is saved and the excess bit rate during the video transcoding process is reduced.
Smart Images

Figure CN117729353B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of video processing technology, and specifically to a video transcoding method, a video transcoding model training method, and related equipment. Background Art
[0002] At present, in the process of video encoding, the bit rate control of the video is set accordingly. For example, the bit rate can be controlled by using a constant rate factor (CRF). Generally, a fixed CRF value is set in advance, and all videos are subsequently transcoded with the fixed CRF. However, the above-mentioned method of transcoding all videos with a fixed CRF has different video clarity or quality presented by the fixed CRF value in different videos. For example, the clarity or image quality of some videos under the fixed CRF value is too high, which will lead to the problem of wasting bandwidth. Summary of the invention
[0003] The embodiments of the present application provide a video transcoding method, a video transcoding model training method and related equipment, which save bandwidth while ensuring that the video quality is subjectively lossless.
[0004] In a first aspect, an embodiment of the present application provides a video transcoding method, the method comprising:
[0005] Get the first video;
[0006] Performing a first transcoding on the first video by using a first constant rate factor to obtain a video to be processed, wherein the first constant rate factor is preset;
[0007] Determining a first image quality parameter of the video to be processed;
[0008] Determining a second constant rate factor corresponding to the video to be processed based on the first image quality parameter;
[0009] Based on the second constant rate factor, the processed video is transcoded for the second time.
[0010] In a second aspect, an embodiment of the present application provides a video transcoding model training method, the method comprising:
[0011] Get the second video;
[0012] The second video is transcoded for the first time by using a third constant rate factor to obtain a video to be trained, where the third constant rate factor is preset;
[0013] Determine the third image quality parameter of the video to be trained;
[0014] Extracting features from the second video to obtain video features;
[0015] Determine a predicted constant rate factor corresponding to the video to be trained based on the video feature and the third image quality parameter;
[0016] Based on the method of the first aspect above, a second constant rate factor corresponding to the video to be trained is obtained;
[0017] Based on the predicted constant rate factor and the second constant rate factor corresponding to the video to be trained, the video transcoding model is trained to predict the constant rate factor for transcoding the video for the second time based on the trained video transcoding model.
[0018] In a third aspect, an embodiment of the present application provides a video transcoding device, the device comprising: a first acquisition unit and a first processing unit;
[0019] A first acquisition unit, used to acquire a first video;
[0020] A first processing unit is used to perform a first transcoding on the first video using a first constant rate factor to obtain a video to be processed, where the first constant rate factor is preset;
[0021] The first processing unit is further used to determine a first image quality parameter of the video to be processed;
[0022] The first processing unit is further used to determine a second constant rate factor corresponding to the video to be processed based on the first image quality parameter;
[0023] The first processing unit is further configured to perform a second transcoding on the video to be processed based on a second constant rate factor.
[0024] In a fourth aspect, an embodiment of the present application provides a video transcoding model training device, the device comprising: a second acquisition unit and a second processing unit;
[0025] The second acquisition unit is used to acquire a second video;
[0026] The second processing unit is used to perform a first transcoding on the second video using a third constant rate factor to obtain a video to be trained, where the third constant rate factor is preset;
[0027] The second processing unit is used to determine a third image quality parameter of the video to be trained;
[0028] The second processing unit is used to extract features from the second video to obtain video features;
[0029] The second processing unit is used to determine a predicted constant rate factor corresponding to the video to be trained based on the video feature and the third image quality parameter;
[0030] The second processing unit is used to obtain a second constant rate factor corresponding to the video to be trained based on the method of the first aspect;
[0031] The second processing unit is used to train the video transcoding model based on the predicted constant rate factor and the second constant rate factor corresponding to the video to be trained, so as to predict the constant rate factor for the second transcoding of the video based on the trained video transcoding model.
[0032] In a fifth aspect, an embodiment of the present application provides an electronic device, comprising: a processor and a memory, the processor being connected to the memory, the memory being used to store a computer program, and the processor being used to execute the computer program stored in the memory, so that the electronic device executes the method of the first aspect or the second aspect.
[0033] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and the computer program enables a computer to execute the method of the first aspect.
[0034] In a seventh aspect, an embodiment of the present application provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and is computer-operable to cause the computer to execute the method of the first aspect.
[0035] Implementing the embodiments of the present application has the following beneficial effects:
[0036] First, a first constant rate factor is used to perform a first transcoding on the first video to obtain a video to be processed; then a first picture quality parameter of the video to be processed is determined; and based on the first picture quality parameter, a second constant rate factor corresponding to the video to be processed is determined. That is, after the first video is transcoded for the first time using a fixed constant rate factor (i.e., the first constant rate factor), the second constant rate factor corresponding to the video to be processed is determined based on the picture quality of the transcoded video (i.e., the video to be processed). That is, the second constant rate factor is determined based on the picture quality after the first transcoding to re-determine the second constant rate factor corresponding to the video to be processed. At this time, the second constant rate factor is obtained under the condition of adapting to adjusting the picture quality, that is, meeting the subjective lossless picture quality. Then, when the second constant rate factor is used for the second transcoding, bandwidth is saved, or excess bit rate in the video transcoding process is saved. In short, bandwidth is saved while ensuring that the quality of the video after transcoding meets the subjective lossless quality. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0038] Figure 1 A schematic diagram of a video transcoding scenario provided in an embodiment of the present application;
[0039] Figure 2 A schematic diagram of a video transcoding method provided in an embodiment of the present application;
[0040] Figure 3 A schematic diagram of image quality distribution after transcoding multiple videos using a fixed CRF value provided in an embodiment of the present application;
[0041] Figure 4 A schematic diagram of determining a target code point provided in an embodiment of the present application;
[0042] Figure 5 A block diagram of the functional units of a video transcoding device provided in an embodiment of the present application;
[0043] Figure 6 A block diagram of the functional units of a video transcoding model training device provided in an embodiment of the present application;
[0044] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0045] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0046] The terms "first", "second", "third" and "fourth" etc. in the specification, claims and drawings of the present application are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices.
[0047] Reference to "embodiments" herein means that a particular feature, result, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0048] First, the relevant terms involved in this application are explained:
[0049] CRF: is a way to control the bit rate, which means to ensure "certain quality" and intelligently allocate the bit rate. That is to say, for example, the control bit rate change after video encoding ensures constant quality. At present, in the process of video transcoding, a preset fixed CRF value is generally used to transcode the video. However, since the video quality presented by the fixed CRF value in different videos is different, that is, the fixed CRF value may not be compatible with each video. For example, the video quality presented by some videos using the fixed CRF value may be lower than the ideal expectation or higher than the ideal expectation, which will waste bandwidth. Therefore, in order to solve the problem of incompatibility between the fixed CRF value and the video, that is, to solve the problem of saving bandwidth when the video quality meets the ideal expectation, the present application determines the CRF value adapted to the video based on the quality of the video after transcoding after transcoding, and then transcodes it again. This not only satisfies the ideal expectation of the quality of the video, but also saves bandwidth.
[0050] See also Figure 1 , Figure 1 A schematic diagram of a video transcoding scenario provided for an embodiment of the present application. The scenario includes a first user terminal 101, a second user terminal 102, and a server 103; wherein the first user terminal 101 and the second user terminal 102 can both be computers, tablet computers, smart phones, and other devices, and the first user terminal 101 and the second user terminal 102 are both installed with a target application (such as a short video playback software), and the first user terminal 101 and the second user terminal 102 can be the same user terminal or different user terminals. It should be noted that the present application does not limit the number of the first user terminal 101 and the second user terminal 102. Figure 1 A first user terminal 101 and a second user terminal 102 are merely used for illustration.
[0051] like Figure 1As shown, after the user uploads the first video by clicking the "plus" button in the target application in the first user terminal 101, the server 103 receives or obtains the first video from the first user terminal 101; then the server 103 transcodes the first video according to the video transcoding method of the present application to save bit rate or bandwidth. Specifically, the server 103 uses a first constant rate factor to perform a first transcoding on the first video to obtain a video to be processed, wherein the first constant rate factor is pre-set; then the server 103 determines a first image quality parameter of the video to be processed; then the server 103 determines a second constant rate factor corresponding to the video to be processed based on the first image quality parameter; based on the second constant rate factor, the server 103 performs a second transcoding on the video to be processed; accordingly, the server 103 sends the second transcoded video to the second user terminal 102, and at this time, the user of the second user terminal 102 can browse the second transcoded video through the target application installed on the second user terminal 102.
[0052] It can be seen that in the embodiment of the present application, the first video is first transcoded for the first time using the first constant rate factor to obtain the video to be processed; then the first picture quality parameter of the video to be processed is determined; and based on the first picture quality parameter, the second constant rate factor corresponding to the video to be processed is determined, that is, after the first video is transcoded for the first time using a fixed constant rate factor (that is, the first constant rate factor), the second constant rate factor corresponding to the video to be processed is determined based on the picture quality of the transcoded video (that is, the video to be processed), that is, the second constant rate factor is re-determined to correspond to the video to be processed under the consideration of the picture quality after the first transcoding, at this time, the second constant rate factor is obtained under the condition of adapting to the adjustment of the picture quality, that is, meeting the subjective lossless picture quality, and then when the second constant rate factor is used for the second transcoding, bandwidth is saved, or excess bit rate in the video transcoding process is saved. In short, bandwidth is saved while ensuring that the quality of the video after transcoding meets the subjective lossless quality.
[0053] See also Figure 2 , Figure 2 A schematic flow chart of a video transcoding method provided in an embodiment of the present application, the method includes but is not limited to steps 201-205:
[0054] 201: Get the first video.
[0055] In the embodiment of the present application, the first video is obtained by encoding the original video, and the specific encoding format is not specifically limited in this application.
[0056] 202: Perform a first transcoding on the first video using a first constant rate factor to obtain a video to be processed.
[0057] It should be noted that the constant rate factor CRF ranges from 0 to 51. Generally speaking, the smaller the CRF value, the higher the quality or image quality of the video after transcoding, but the corresponding bit rate will also be higher, and there is a situation where the image quality is too high and bandwidth is wasted; generally, in the process of video transcoding, a default CRF value is pre-set to transcode all videos once. After obtaining the first video, the present application first uses the pre-set first constant rate factor to transcode the first video once, and then obtains the video to be processed.
[0058] 203: Determine a first image quality parameter of the video to be processed.
[0059] In the embodiment of the present application, since the first transcoding is performed based on the first constant rate factor, the video to be processed has a situation where the image quality is too high and the bandwidth is wasted, so it is necessary to measure the image quality of the video to be processed, and the measurement standard of the image quality of the video to be processed can adopt standards such as Peak signal-to-noise ratio (PSNR) and Visual Multimethod Assessment Fusion (VMAF); for the PSNR standard, the larger the value of PSNR, the higher the video quality; for the VMAF standard, its numerical range is 0 to 100, and the larger the value, the higher the video quality. Therefore, the first image quality parameter of the video to be processed determined by the present application can be represented by any one of the image quality measurement standards, and the present application does not limit it. Exemplarily, if the first image quality parameter is measured by PSNR, the first image quality parameter of the video to be processed can be determined specifically as follows: Since the first video and the video to be processed can be understood as multiple frames of images after decoding, in practical applications, each frame of the image can be a monochrome image or a color image. If each frame of the first video and the video to be processed is a monochrome image after decoding, take the i-th frame image after decoding the first video (denoted as image P1) and the i-th frame image after decoding the video to be processed (denoted as image P2) as examples, then calculate the square of the difference between the corresponding pixels of P1 and P2 and take the average value to obtain the corresponding average value Square error, and then calculate the ratio of the square of the maximum pixel value of P1 to the mean square error and then take the logarithm to get the peak signal-to-noise ratio corresponding to the i-th frame image. Similarly, the peak signal-to-noise ratio corresponding to each frame of the video to be processed can be calculated, and the peak signal-to-noise ratios corresponding to multiple frames of the image to be processed can be averaged as the first image quality parameter corresponding to the video to be processed; it should be noted that if each frame of the video to be processed is a color image, the peak signal-to-noise ratio corresponding to the color image on the RGB three channels can be calculated according to the above principle of calculating the peak signal-to-noise ratio corresponding to the monochrome image, and then the average is calculated as the first image quality parameter corresponding to the video to be processed.
[0060] 204: Determine a second constant rate factor corresponding to the video to be processed based on the first image quality parameter.
[0061] In an optional embodiment of the present application, if the first image quality parameter is greater than the first threshold, it can also be generally understood that the image quality of the video to be processed is too high, then step 203 may specifically include: first, obtaining a first mapping relationship between a constant rate factor and an image quality parameter corresponding to the video to be processed. It should be noted that since a constant rate factor presents different image qualities in different videos, for example, refer to Figure 3 , Figure 3 A schematic diagram of image quality distribution after transcoding multiple videos using a fixed CRF value is provided in an embodiment of the present application, such as Figure 3 As shown, the horizontal axis represents the PSNR value, and the vertical axis represents the number of videos. Assuming that the fixed CRF value is the first preset value, the distribution of the image quality after transcoding multiple videos based on the first preset value is as follows Figure 3 As shown, the values of "29-60" in the horizontal axis represent the PSNR value, and the values of "0-700" in the vertical axis represent the video. For example, there are 500 videos with a PSNR value of 42, and 200 videos with a PSNR value of 46. Similarly, we will not list them one by one here. Figure 3 The corresponding relationship between the PSNR value and the number of videos is shown; therefore, we need to traverse the image quality corresponding to the video to be processed under different constant rate factors for each video, that is, the video to be processed, and then we can obtain the first mapping relationship between the constant rate factor and the image quality parameter for the video to be processed.
[0062] Then, based on the preset lossless image quality parameters and the first mapping relationship, a constant rate factor corresponding to the lossless image quality parameters is determined. It should be noted that lossless image quality means that although the video occupies less storage after compression and storage, the quality presented by the video has not changed. It can also be called "subjective lossless image quality", that is, the quality has not changed in people's subjective impression. It is generally understood as a subtle quality change that is difficult to detect with the naked eye and will not affect people's visual experience. In any image quality measurement standard, there is a corresponding default lossless image quality value. For example, there is a recognized lossless image quality parameter in the PSNR standard, and there is also a recognized lossless image quality parameter in the VAMF standard. This application does not limit it; then the constant rate factor corresponding to the lossless image quality parameter is determined as the second constant rate factor. Exemplarily, after obtaining the first mapping relationship between the constant rate factor corresponding to the video to be processed and the image quality parameter, the constant rate factor corresponding to the lossless image quality parameter can be determined from the first mapping relationship, and then the constant rate factor corresponding to the lossless image quality parameter is determined as the second constant rate factor corresponding to the video to be processed. It should be noted that for videos with too high image quality, that is, videos with image quality parameters greater than the first threshold, the constant rate factor corresponding to the lossless image quality parameters is determined as the second constant rate factor through the pre-set lossless image quality parameters, that is, the target image quality after the second transcoding is the subjective lossless image quality in the image quality measurement standard. Therefore, the quality of the video after the second transcoding can be guaranteed. In other words, even if the quality of the video after the second transcoding is reduced in the objective image quality evaluation standard, the quality is still not lower than the lossless image quality, and does not affect people's subjective visual experience. At the same time, it also reduces the excess bit rate caused by excessive image quality, that is, saves bandwidth.
[0063] In an optional embodiment of the present application, if the first image quality parameter is less than the first threshold value, it can also be generally understood that the first image quality parameter of the video to be processed is the second highest, then step 203 may specifically include: first, obtaining a second mapping relationship between the bit rate and the image quality parameter corresponding to the video to be processed; then, based on the first image quality parameter and the second mapping relationship, determining the first bit rate corresponding to the first image quality parameter; further, based on the first bit rate, the first image quality parameter and the second mapping relationship, determining the second image quality parameter, specifically: based on the first bit rate, the first image quality parameter and the second mapping relationship, determining multiple code points, wherein each code point records a picture quality parameter and a bit rate corresponding to the picture quality parameter, the picture quality parameter corresponding to each code point is less than the first picture quality parameter, and the bit rate corresponding to each code point is less than the first bit rate; then, based on the picture quality parameter and bit rate corresponding to each code point, as well as the first picture quality parameter and the first bit rate, determining the bit rate gain corresponding to each code point, wherein the bit rate gain is used to represent the proportional relationship between the lost picture quality of the video and the reduced bit rate. Exemplarily, the bit rate gain corresponding to the i-th code point can be obtained by formula (1):
[0064]
[0065] Among them, P i is the code rate benefit corresponding to the i-th code point, B 1 is the first code rate, B i is the code rate corresponding to the i-th code point, Q 1 is the first image quality parameter, Q i is the image quality parameter corresponding to the i-th code point.
[0066] Then, multiple code points are traversed. If it is determined for the first time that the bit rate gain corresponding to the i-th code point is greater than the second threshold, and the bit rate gain corresponding to the i+1-th code point is less than the second threshold, the i-th code point is determined as the target code point, wherein the image quality parameter and the bit rate corresponding to the i-th code point are both less than the image quality parameter and the bit rate corresponding to the i+1-th code point, and i is an integer; the image quality corresponding to the target code point is further determined as the second image quality parameter; based on the second image quality parameter and the first mapping relationship, a constant rate factor corresponding to the second image quality parameter is determined; finally, the constant rate factor corresponding to the second image quality parameter is determined as the second constant rate factor. It should be explained that the bit rate benefit reflects that for videos with the second highest image quality, that is, less than the first threshold, a very high bit rate reduction return can be obtained while the video image quality is reduced very little. Since the bit rate benefit of the target code point can be understood as the code point with the highest bit rate benefit among multiple code points, that is to say, by determining the image quality corresponding to the target code point as the target image quality to be presented after the second transcoding, at this time, the target image quality is reduced very little compared to the first image quality parameter, but the bit rate reduction, that is, the bit rate reduction, is very high, thereby saving a lot of bit rate or bandwidth while ensuring a small loss in image quality.
[0067] For example, see Figure 4 , Figure 4 A schematic diagram of determining a target code point provided in an embodiment of the present application is as follows: Figure 4 As shown, the horizontal axis represents the bit rate, and the vertical axis represents the image quality (it should be noted that at this time Figure 4 The image quality measurement standard used is the VMAF standard). Figure 4 The mapping relationship between the bit rate of "0-3500" and the VMAF value of "50-100" is only shown as an example when the first video is transcoded once using a fixed constant rate factor. Figure 4 It can be known that the code point of the first transcoding records the image quality (i.e., the first image quality parameter) and the bit rate (i.e., the first bit rate) after the first video is transcoded once using the first constant rate factor; after determining the location of the code point of the first transcoding, multiple code points (i.e., Figure 4Each small cross symbol on the middle curve corresponds to 1, 2, 3, 4, 5...) and the image quality corresponding to each code point, that is, the VMAF value and the bit rate, and the VMAF values and the bit rates of these multiple code points are all less than the first image quality parameter and the first bit rate corresponding to the code point of the first transcoding; then, according to the distance between each code point and the code point of the first transcoding, the bit rate gain of each code point is calculated according to the distance from small to large, so the first code point is the closest. For the first code point, assuming that the bit rate gain corresponding to the first code point obtained by the bit rate gain calculation method provided in the embodiment of the present application is greater than the second threshold, the bit rate gain corresponding to the second code point is calculated in the same way. If the bit rate gain corresponding to the second code point is also greater than the second threshold, the bit rate gain corresponding to the third code point is calculated in the same way. If the low bit rate gain corresponding to the third code point is less than the second threshold, then the situation that the bit rate gain corresponding to the second code point is greater than the second threshold and the bit rate gain corresponding to the third code point is less than the second threshold for the first time appears, and the second code point is determined as the target code point.
[0068] 205: Based on the second constant rate factor, perform a second transcoding on the video to be processed.
[0069] In an embodiment of the present application, a second constant rate factor is determined based on a first image quality parameter of the video to be processed after the first transcoding, and then the second constant rate factor is used to perform a second transcoding on the video to be processed, so that the image quality remains lossless or slightly reduced, thereby saving excess bit rate or bandwidth.
[0070] The present application also provides a video transcoding model training method, which specifically includes: obtaining a second video, and similarly, the second video is also an encoded video; using a third constant rate factor to perform a first transcoding on the second video to obtain a video to be trained, wherein the third constant rate factor is preset; then, determining a third image quality parameter of the video to be trained, and it should be noted that the third image quality parameter of the video to be trained is similar to the determination principle of the first image quality parameter of the video to be processed, and will not be repeated; extracting features from the second video to obtain video features, and it should be noted that the feature extraction of the second video may be spatiotemporal feature extraction, and the spatiotemporal features may include temporal complexity (i.e., the degree of motion of the video content), spatial complexity (i.e., the complexity of the texture in the video), etc., and the video features after feature extraction may specifically include but are not limited to normalized cross-correlation (NCC), motion estimation (ME), gray-level co-occurrence matrix (Gray-level Co-occurrence Matrix, GLCM) and other features. For example, the motion estimation feature is used to represent the temporal complexity of the video. It is to calculate the motion vector between the current frame image and the reference frame image during the compression coding process. For example, it can be determined by using a pixel-by-pixel motion estimation algorithm, an integer pixel motion estimation algorithm, etc.; the gray-level co-occurrence matrix feature is used to represent the spatial complexity of the video. For example, for any frame image in the video to be processed, the image is converted into a grayscale image, and then a specific direction (such as horizontal, vertical, etc.) and distance (the interval distance between pixels) are selected to calculate the co-occurrence matrix. For each pixel, the neighboring pixels with a specific direction and distance are counted. The grayscale co-occurrence frequency between pixels (which may be pixels at a specific distance in a specific direction) is calculated, and then a grayscale co-occurrence matrix is constructed. The element GLCM (i, j) in the grayscale co-occurrence matrix represents the number of times pixel grayscale levels i and j appear simultaneously in a specific direction and distance. The grayscale co-occurrence matrix is then normalized to obtain a co-occurrence probability matrix. The elements in the co-occurrence probability matrix represent the probability of pixel grayscale levels i and j appearing simultaneously in a specific direction and distance. Then, according to the co-occurrence probability matrix, the statistics used to describe texture features (such as contrast, correlation, energy, entropy, etc., which are not specifically limited in this application) can be calculated, namely, the grayscale co-occurrence matrix features.Based on the video features and the third image quality parameter, the predicted constant rate factor corresponding to the video to be processed is determined. Specifically: if the third image quality parameter is greater than the first threshold, the structural similarity (SSIM) corresponding to the video to be trained is obtained, and then the predicted constant rate factor is predicted based on the above video features, the third image quality parameter, and the structural similarity. For example, the predicted constant rate factor is obtained by performing a logistic regression on the above video features, the third image quality parameter, the result similarity, and the bit rate when the third constant rate factor is used for the first transcoding, that is, the logistic regression model is input to output the predicted constant rate factor. Specifically, at this time, the video features, the third image quality parameter, the result similarity, and the bit rate when the first transcoding is performed are used as indicator data, and then a logistic regression is performed on each indicator data according to the softmax function to determine the probability of each indicator data under the corresponding multiple constant rate factors when the image quality of the video to be trained meets the target image quality, and the constant rate factor with the largest probability is determined as the constant rate factor corresponding to each indicator data when the video to be trained is the target image quality, and then the constant rate factor with the largest probability corresponding to the constant rate factor corresponding to each indicator data can be determined as the predicted constant rate factor. Similarly, if the third image quality parameter is less than the first image quality parameter, then based on the video features, determine whether there is a target code point in the video to be trained. For example, the extracted video features can be input into the classifier, and the output result can be used to determine whether there is a target code point with the maximum bit rate benefit and greater than the second threshold. That is to say, if there are multiple video features, then determine the probability of each video feature having a target code in the video to be trained, and then average the probability corresponding to each video feature to obtain the final probability, and determine whether there is a target code point in the training video based on the relationship between the final probability and the preset value. For example, if the final probability is greater than the preset value, it is determined that the target code point exists in the video to be trained; if it exists, then based on the video features, predict the predicted constant rate factor, that is, perform logistic regression on the above video features, that is, input them into the logistic regression model to output the predicted constant rate factor. Similarly, for example, logistic regression can be performed on each video feature based on the sigmiod function to determine the probability of each indicator video under the corresponding multiple constant rate factors when the video to be trained meets the bit rate benefit corresponding to the target code point, and the constant rate factor with the largest probability is determined as the constant rate factor corresponding to each video feature, and then the constant rate factor with the largest probability corresponding to the constant rate factor corresponding to each video feature can be determined as the predicted constant rate factor.Then, a second constant rate factor corresponding to the video to be trained is obtained based on the video transcoding method provided in the embodiment of the present application, which will not be repeated here; finally, based on the above-mentioned predicted constant rate factor and the second constant rate factor corresponding to the video to be trained, the pre-trained model is trained to obtain a target model, so as to predict the constant rate factor for the second transcoding of the video based on the target model. Specifically, the loss can be calculated based on the predicted constant rate factor and the second constant rate factor corresponding to the video to be trained, such as using a cross entropy loss function, a mean square error loss function, etc. to calculate the loss, and iterative training is performed to reduce the loss gradient until the loss is minimized or less than the preset loss, which is not limited in the present application. Furthermore, after the target model, i.e., the logistic regression model, is trained, the second constant rate factor for the subsequent transcoding process can be directly predicted based on the target model. For example, a third video that has been encoded is obtained, and the third video is transcoded for the first time based on a preset constant rate factor to obtain a fourth video. Feature extraction is then performed on the fourth video to obtain corresponding video features, and the image quality parameters corresponding to the fourth video are determined. The video features and image quality parameters corresponding to the fourth video are then input into the target model. Finally, the target model can directly output the second constant rate factor corresponding to the fourth video, so that the fourth video can be transcoded for a second time based on the second constant rate factor to save bandwidth while ensuring that the image quality of the video is subjectively lossless.
[0071] Generally speaking, the smaller the CRF value, the higher the quality or image quality of the video after transcoding, but the corresponding bit rate will also be higher, and there is a situation where the image quality is too high and bandwidth is wasted. In the process of video transcoding, a default CRF value is generally set in advance to transcode all videos once, but this method cannot guarantee that the default CRF value is applicable to all videos. Some videos will have the problem of too high image quality when the default CRF value is applied, thereby wasting a lot of bit rate. Therefore, it can be seen that in the embodiment of the present application, the first video is transcoded for the first time by using the first constant rate factor to obtain the video to be processed; then the first picture quality parameter of the video to be processed is determined; and based on the first picture quality parameter, the second constant rate factor corresponding to the video to be processed is determined, that is, after the first video is transcoded for the first time by using a fixed constant rate factor (that is, the first constant rate factor), the second constant rate factor corresponding to the video to be processed is determined according to the picture quality of the transcoded video (that is, the video to be processed), that is, the second constant rate factor is re-determined to correspond to the video to be processed by taking into account the picture quality after the first transcoding, and at this time, the second constant rate factor is obtained under the condition of adapting to the adjustment of the picture quality, that is, meeting the subjective lossless picture quality, and then when the second constant rate factor is used for the second transcoding, bandwidth is saved, that is, excess bit rate in the video transcoding process is saved.
[0072] See also Figure 5 , Figure 5 This is a block diagram of the functional units of a video transcoding device provided in an embodiment of the present application. The video transcoding device 500 includes: a first acquisition unit 501 and a first processing unit 502;
[0073] A first acquisition unit 501 is used to acquire a first video;
[0074] A first processing unit 502 is used to perform a first transcoding on the first video using a first constant rate factor to obtain a video to be processed, where the first constant rate factor is preset;
[0075] The first processing unit 502 is further used to determine a first image quality parameter of the video to be processed;
[0076] The first processing unit 502 is further configured to determine a second constant rate factor corresponding to the video to be processed based on the first image quality parameter;
[0077] The first processing unit 502 is further configured to perform a second transcoding on the video to be processed based on a second constant rate factor.
[0078] In one embodiment of the present application, if the first image quality parameter is greater than the first threshold, in determining the second constant rate factor corresponding to the video to be processed based on the first image quality parameter, the first processing unit 502 is specifically configured to:
[0079] Obtaining a first mapping relationship between a constant rate factor and an image quality parameter corresponding to the video to be processed;
[0080] Based on the preset lossless image quality parameter and the first mapping relationship, determining a constant rate factor corresponding to the lossless image quality parameter;
[0081] A constant rate factor corresponding to the lossless image quality parameter is determined as a second constant rate factor.
[0082] In one embodiment of the present application, if the first image quality parameter is less than the first threshold, in determining the second constant rate factor corresponding to the video to be processed based on the first image quality parameter, the first processing unit 502 is specifically configured to:
[0083] Obtaining a second mapping relationship between a bit rate and a picture quality parameter corresponding to the video to be processed;
[0084] Determining a first bit rate corresponding to the first image quality parameter based on the first image quality parameter and the second mapping relationship;
[0085] Determining a second image quality parameter based on the first bit rate, the first image quality parameter, and the second mapping relationship;
[0086] Determining a constant rate factor corresponding to the second image quality parameter based on the second image quality parameter and the first mapping relationship;
[0087] A constant rate factor corresponding to the second image quality parameter is determined as a second constant rate factor.
[0088] In one embodiment of the present application, in determining the second image quality parameter based on the first bit rate, the first image quality parameter and the second mapping relationship, the first processing unit 502 is specifically configured to:
[0089] Based on the first bit rate, the first image quality parameter and the second mapping relationship, a plurality of code points are determined, wherein each code point records an image quality and a bit rate corresponding to the image quality parameter, the image quality parameter corresponding to each code point is smaller than the first image quality parameter, and the bit rate corresponding to each code point is smaller than the first bit rate;
[0090] Determine a bitrate gain corresponding to each code point based on the image quality parameter and bitrate corresponding to each code point, as well as the first image quality parameter and the first bitrate, wherein the bitrate gain is used to indicate a proportional relationship between the image quality loss and the reduced bitrate of the video;
[0091] Traversing multiple code points, if it is determined for the first time that the bit rate gain corresponding to the i-th code point is greater than the second threshold, and the bit rate gain corresponding to the i+1-th code point is less than the second threshold, the i-th code point is determined as the target code point, wherein the image quality parameter and bit rate corresponding to the i-th code point are both less than the image quality parameter and bit rate corresponding to the i+1-th code point, and i is an integer;
[0092] The image quality corresponding to the target code point is determined as the second image quality parameter.
[0093] See also Figure 6 , Figure 6 A functional unit composition block diagram of a video transcoding model training device provided in an embodiment of the present application. The video transcoding model training device 600 includes: a second acquisition unit 601 and a second processing unit 602;
[0094] A second acquisition unit 601 is used to acquire a second video;
[0095] The second processing unit 602 is used to perform a first transcoding on the second video by using a third constant rate factor to obtain a video to be trained, where the third constant rate factor is preset;
[0096] The second processing unit 602 is further used to determine a third image quality parameter of the video to be trained;
[0097] The second processing unit 602 is further used to extract features from the second video to obtain video features;
[0098] The second processing unit 602 is further configured to determine a predicted constant rate factor corresponding to the video to be trained based on the video feature and the third image quality parameter;
[0099] The second processing unit 602 is further configured to obtain a second constant rate factor corresponding to the video to be trained based on the video transcoding method of the embodiment of the present application;
[0100] The second processing unit 602 is further used to train the video transcoding model based on the predicted constant rate factor and the second constant rate factor corresponding to the video to be trained, so as to predict the constant rate factor for the second transcoding of the video based on the trained video transcoding model.
[0101] In one embodiment of the present application, if the third image quality parameter is greater than the first threshold, in determining the predicted constant rate factor corresponding to the video to be processed based on the video feature and the third image quality parameter, the second processing unit 602 is specifically configured to:
[0102] Obtain the structural similarity corresponding to the video to be trained;
[0103] Based on the video features, the third image quality parameter and the structural similarity, a predicted constant rate factor is predicted.
[0104] In one embodiment of the present application, if the third image quality parameter is less than the first threshold, in determining the predicted constant rate factor corresponding to the video to be processed based on the video feature and the third image quality parameter, the second processing unit 602 is specifically configured to:
[0105] Based on the video features, determine whether the video to be trained has the target code point;
[0106] If present, a predicted constant rate factor is predicted based on the video features.
[0107] See also Figure 7 , Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 7 As shown, the electronic device 700 includes a transceiver 701, a processor 702 and a memory 703. They are connected via a bus 704. The memory 703 is used to store computer programs and data, and can transmit the data stored in the memory 703 to the processor 702.
[0108] The processor 702 is used to read the computer program in the memory 703 and perform the following operations:
[0109] Control transceiver 701 to obtain a first video; use a first constant rate factor to perform a first transcoding on the first video to obtain a video to be processed, where the first constant rate factor is preset; determine a first image quality parameter of the video to be processed; based on the first image quality parameter, determine a second constant rate factor corresponding to the video to be processed; based on the second constant rate factor, perform a second transcoding on the video to be processed.
[0110] Alternatively, control the transceiver 701 to obtain a second video; use a third constant rate factor to perform a first transcoding on the second video to obtain a video to be trained, where the third constant rate factor is preset; determine a third image quality parameter of the video to be trained; perform feature extraction on the second video to obtain video features; determine a predicted constant rate factor corresponding to the video to be trained based on the video features and the third image quality parameter; obtain a second constant rate factor corresponding to the video to be trained based on the video transcoding method of an embodiment of the present application; train a video transcoding model based on the predicted constant rate factor and the second constant rate factor corresponding to the video to be trained, so as to predict a constant rate factor for transcoding the video for a second time based on the trained video transcoding model.
[0111] Specifically, the transceiver 701 may be Figure 5 The first acquisition unit 501 of the video transcoding device 500 of the embodiment is Figure 6 The second acquisition unit 601 of the video transcoding model training device 600 of the embodiment, the processor 702 may be Figure 5 The first processing unit 502 of the video transcoding device 500 of the embodiment is Figure 6 The second processing unit 602 of the video transcoding model training device 600 of the embodiment.
[0112] In a specific implementation, the transceiver 701, processor 702, and memory 703 described in the embodiments of the present invention may correspond to the implementation methods in all embodiments of the video transcoding method and video transcoding model training method provided in the embodiments of the present invention, which will not be repeated here.
[0113] It should be understood that the electronic devices in this application may include smart phones (such as Android phones, iOS phones, Windows Phone phones, etc.), tablet computers, PDAs, laptops, mobile Internet devices MID (Mobile Internet Devices, referred to as: MID) or wearable devices, etc. The above electronic devices are only examples, not exhaustive, and include but are not limited to the above electronic devices. In practical applications, the above electronic devices may also include: smart vehicle terminals, computer equipment, etc.
[0114] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. The computer program is executed by a processor to implement part or all of the steps of any video transcoding method or video transcoding model training method recorded in the above method embodiments.
[0115] An embodiment of the present application also provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute part or all of the steps of any one of the video transcoding methods or video transcoding model training methods recorded in the above method embodiments.
[0116] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present application.
[0117] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0118] In the several embodiments provided in the present application, it should be understood that the disclosed devices can be implemented in other ways. For example, the device embodiments described above are only schematic, such as the division of units, which is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical or other forms.
[0119] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0120] In addition, each functional unit in each embodiment of the present application may be integrated into a first processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of a software program module.
[0121] If the integrated unit is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a memory and includes several instructions for a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of each embodiment method of the present application. The aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.
[0122] A person skilled in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable memory, and the memory can include: a flash drive, a read-only memory (English: Read-Only Memory, abbreviated as: ROM), a random access memory (English: Random Access Memory, abbreviated as: RAM), a magnetic disk or an optical disk, etc.
[0123] The embodiments of the present application are introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for those skilled in the art, according to the idea of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A video transcoding method, characterized in that: The method comprises: Get the first video; Performing a first transcoding on the first video by using a first constant rate factor to obtain a video to be processed, wherein the first constant rate factor is preset; Determining a first image quality parameter of the video to be processed; Determining a second constant rate factor corresponding to the video to be processed based on the first image quality parameter specifically includes: if the first image quality parameter is less than a first threshold, obtaining a second mapping relationship between the bit rate and the image quality parameter corresponding to the video to be processed; determining a first bit rate corresponding to the first image quality parameter based on the first image quality parameter and the second mapping relationship; determining a second image quality parameter based on the first bit rate, the first image quality parameter and the second mapping relationship; determining a constant rate factor corresponding to the second image quality parameter based on the second image quality parameter and the first mapping relationship between the constant rate factor corresponding to the video to be processed and the image quality parameter; and determining the constant rate factor corresponding to the second image quality parameter as the second constant rate factor; Based on the second constant rate factor, the video to be processed is transcoded for the second time.
2. The method according to claim 1, characterized in that If the first image quality parameter is greater than a first threshold, determining a second constant rate factor corresponding to the to-be-processed video based on the first image quality parameter includes: Obtaining a first mapping relationship between a constant rate factor and an image quality parameter corresponding to the video to be processed; Based on the preset lossless image quality parameter and the first mapping relationship, determining a constant rate factor corresponding to the lossless image quality parameter; A constant rate factor corresponding to the lossless image quality parameter is determined as the second constant rate factor.
3. The method according to claim 1 or 2, characterized in that: The determining the second image quality parameter based on the first bit rate, the first image quality parameter and the second mapping relationship includes: Determine a plurality of code points based on the first bit rate, the first image quality parameter, and the second mapping relationship, wherein each code point records an image quality parameter and a bit rate corresponding to the image quality parameter, the image quality parameter corresponding to each code point is smaller than the first image quality parameter, and the bit rate corresponding to each code point is smaller than the first bit rate; Determine a bitrate gain corresponding to each code point based on a picture quality parameter and a bitrate corresponding to each code point, as well as the first picture quality parameter and the first bitrate, wherein the bitrate gain is used to indicate a proportional relationship between a video quality loss and a reduced bitrate; Traversing the multiple code points, if it is determined for the first time that the bit rate gain corresponding to the i-th code point is greater than the second threshold, and the bit rate gain corresponding to the i+1-th code point is less than the second threshold, determining the i-th code point as the target code point, wherein the image quality parameter and the bit rate corresponding to the i-th code point are both less than the image quality parameter and the bit rate corresponding to the i+1-th code point, and i is an integer; The image quality parameter corresponding to the target code point is determined as the second image quality parameter.
4. A video transcoding model training method, characterized in that: The method comprises: Get the second video; Transcoding the second video for the first time using a third constant rate factor to obtain a video to be trained, wherein the third constant rate factor is preset; Determining a third image quality parameter of the video to be trained; Extracting features from the second video to obtain video features; Determining a predicted constant rate factor corresponding to the video to be trained based on the video feature and the third image quality parameter; Obtaining a second constant rate factor corresponding to the video to be trained based on any one of the methods of claims 1 to 3; The video transcoding model is trained based on the predicted constant rate factor and a second constant rate factor corresponding to the video to be trained, so as to predict a constant rate factor for a second transcoding of the video based on the trained video transcoding model.
5. The method according to claim 4, characterized in that If the third image quality parameter is greater than the first threshold, determining the predicted constant rate factor corresponding to the to-be-trained video based on the video feature and the third image quality parameter includes: Obtaining structural similarity corresponding to the video to be trained; The predicted constant rate factor is predicted based on the video feature, the third image quality parameter, and the structural similarity.
6. The method according to claim 5, characterized in that If the third image quality parameter is less than the first threshold, determining the predicted constant rate factor corresponding to the to-be-trained video based on the video feature and the third image quality parameter includes: Based on the video features, determining whether the video to be trained has a target code point; If present, the predicted constant rate factor is predicted based on the video features.
7. A video transcoding device, characterized in that: The device comprises: a first acquisition unit and a first processing unit; The first acquisition unit is used to acquire a first video; The first processing unit is used to perform a first transcoding on the first video using a first constant rate factor to obtain a video to be processed, where the first constant rate factor is preset; The first processing unit is further used to determine a first image quality parameter of the video to be processed; The first processing unit is further used to determine a second constant rate factor corresponding to the video to be processed based on the first image quality parameter, specifically comprising: if the first image quality parameter is less than a first threshold, obtaining a second mapping relationship between a bit rate and an image quality parameter corresponding to the video to be processed; determining a first bit rate corresponding to the first image quality parameter based on the first image quality parameter and the second mapping relationship; determining a second image quality parameter based on the first bit rate, the first image quality parameter and the second mapping relationship; determining a constant rate factor corresponding to the second image quality parameter based on the second image quality parameter and the first mapping relationship between the constant rate factor corresponding to the video to be processed and the image quality parameter; and determining the constant rate factor corresponding to the second image quality parameter as the second constant rate factor; The first processing unit is further configured to perform a second transcoding on the video to be processed based on the second constant rate factor.
8. A video transcoding model training device, characterized in that: The device comprises a second acquisition unit and a second processing unit; The second acquisition unit is used to acquire a second video; The second processing unit is used to perform a first transcoding on the second video using a third constant rate factor to obtain a video to be trained, wherein the third constant rate factor is preset; The second processing unit is further used to determine a third image quality parameter of the video to be trained; The second processing unit is further used to extract features from the second video to obtain video features; The second processing unit is further used to determine a predicted constant rate factor corresponding to the video to be trained based on the video feature and the third image quality parameter; The second processing unit is further used to obtain a second constant rate factor corresponding to the video to be trained based on the method of any one of claims 1 to 3; The second processing unit is further used to train the video transcoding model based on the predicted constant rate factor and a second constant rate factor corresponding to the video to be trained, so as to predict the constant rate factor for the second transcoding of the video based on the trained video transcoding model.
9. An electronic device, characterized in that: include: A processor and a memory, the processor is connected to the memory, the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory, so that the electronic device executes the method as described in any one of claims 1 to 6.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Video file transcoding method
CN103763559A