Video transcoding method, device, equipment and computer-readable storage medium

By acquiring video images and macroblock information at different bit rates and quickly determining the macroblock mode, the problem of large computational complexity during video transcoding is solved, and the transcoding speed is improved.

CN115412734BActive Publication Date: 2025-09-16JD DIGITS HAIYI INFORMATION TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211041711.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-29
Publication Date
2025-09-16
Estimated Expiration
2042-08-29

AI Technical Summary

Technical Problem

In the existing technology, the video transcoding process requires a lot of computation, resulting in a slow transcoding speed.

Method used

By obtaining the cost and mode of multiple frames and macroblocks of the video to be processed at different bit rates, the macroblock mode corresponding to the second macroblock is quickly determined using this information to reduce the amount of calculation.

Benefits of technology

It improves the speed of video transcoding, reduces the amount of calculation, and speeds up the determination of macroblock modes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115412734B_ABST
    Figure CN115412734B_ABST
Patent Text Reader

Abstract

The embodiment of the present application discloses a video transcoding method, which includes: obtaining multiple frames of first images corresponding to a video to be processed, the cost of a first macroblock in each frame of the first image, and a macroblock mode corresponding to the first macroblock; wherein the multiple frames of the first image are obtained by encoding the video to be processed based on a first bit rate; obtaining multiple frames of second images corresponding to the video to be processed, and the cost of a second macroblock in each frame of the second image; wherein the multiple frames of the second image are obtained by encoding the video to be processed based on a second bit rate, and the second bit rate is less than the first bit rate; determining the macroblock mode corresponding to the second macroblock based on the cost of the first macroblock, the cost of the second macroblock, and the macroblock mode corresponding to the first macroblock; and transcoding the video to be processed based on the multiple frames of the second image and the macroblock mode corresponding to the second macroblock. The embodiment of the present application also discloses a video transcoding device, an apparatus, and a computer-readable storage medium.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communication technology, and in particular to a video transcoding method, apparatus, device, and computer-readable storage medium. Background Art

[0002] Video transcoding converts a compressed video stream into another video stream to accommodate varying network bandwidths and terminals with varying processing capabilities. If the network bandwidth changes, the video needs to be re-transcoded to accommodate the changed bandwidth. However, during implementation, the inventors discovered at least the following issues with existing technologies: The computational complexity of the transcoding process is high, resulting in slow transcoding speeds. Summary of the Invention

[0003] To solve the above technical problems, the embodiments of the present application hope to provide a video transcoding method, apparatus, device and computer-readable storage medium, which solves the problem that the transcoding process of the prior art has a large amount of calculation, resulting in a slow transcoding speed.

[0004] The technical solution of this application is achieved as follows:

[0005] A video transcoding method, comprising:

[0006] Obtaining multiple frames of first images corresponding to a video to be processed, a cost of a first macroblock in each frame of the first image, and a macroblock mode corresponding to the first macroblock; wherein the multiple frames of first images are obtained by encoding the video to be processed based on a first bit rate;

[0007] Obtaining a plurality of frames of second images corresponding to the video to be processed and a cost of a second macroblock in each frame of the second image; wherein the plurality of frames of second images are obtained by encoding the video to be processed based on a second bit rate, and the second bit rate is less than the first bit rate;

[0008] Determining a macroblock mode corresponding to the second macroblock based on the cost of the first macroblock, the cost of the second macroblock, and the macroblock mode corresponding to the first macroblock;

[0009] The video to be processed is transcoded based on the macroblock modes corresponding to the multiple frames of second images and the second macroblocks.

[0010] In the above solution, determining the macroblock mode corresponding to the second macroblock based on the cost of the first macroblock, the cost of the second macroblock, and the macroblock mode corresponding to the first macroblock includes:

[0011] For each second macroblock, determining a target macroblock corresponding to each second macroblock from the first macroblocks;

[0012] Based on the relationship between the cost of the target macroblock and the cost of each second macroblock, and the relationship between the macroblock mode corresponding to the target macroblock and the first mode, the macroblock mode corresponding to each second macroblock is determined; wherein the first mode represents that each second macroblock has no motion vector and no pixel residual.

[0013] In the above solution, determining the macroblock mode corresponding to each second macroblock based on the relationship between the cost of the target macroblock and the cost of each second macroblock, and the relationship between the macroblock mode corresponding to the target macroblock and the first mode, includes:

[0014] When the cost of each second macroblock is less than the cost of the target macroblock and the macroblock mode corresponding to the target macroblock is the first mode, determining that the macroblock mode corresponding to each second macroblock is the first mode;

[0015] When the cost of each second macroblock is greater than the cost of the target macroblock and the macroblock mode corresponding to the target macroblock is the first mode, the macroblock mode corresponding to each second macroblock is determined to be the second mode; wherein the second mode represents that each second macroblock has pixel residuals and no motion vectors.

[0016] In the above solution, determining the macroblock mode corresponding to each second macroblock based on the relationship between the cost of the target macroblock and the cost of each second macroblock, and the relationship between the macroblock mode corresponding to the target macroblock and the first mode, includes:

[0017] When the cost of each second macroblock is less than the cost of the target macroblock and the macroblock mode corresponding to the target macroblock is not the first mode, or when the cost of each second macroblock is greater than the target macroblock cost and the macroblock mode corresponding to the target macroblock is not the first mode, determining the optimal macroblock mode for each second macroblock based on the first mode decision method;

[0018] The macroblock mode corresponding to each second macroblock is determined to be the optimal macroblock mode; wherein the optimal macroblock mode indicates that the prediction cost of each second macroblock is minimized.

[0019] In the above solution, determining the macroblock mode corresponding to each second macroblock based on the relationship between the cost of the target macroblock and the cost of each second macroblock, and the relationship between the macroblock mode corresponding to the target macroblock and the first mode, includes:

[0020] When the cost of each second macroblock is equal to the cost of the target macroblock, determining the optimal macroblock mode for each second macroblock based on a second mode decision method;

[0021] Determine that the macroblock mode corresponding to each second macroblock is the optimal macroblock mode; wherein the first mode decision method does not include the operation of judging the first mode in the second mode decision method.

[0022] In the above solution, the transcoding process of the video to be processed based on the macroblock modes corresponding to the multiple frames of second images and the second macroblocks includes:

[0023] For each frame of the second image, determining a target image corresponding to the each frame of the second image from the first image;

[0024] Determining the number of macroblocks in the target image whose macroblock mode is the first mode;

[0025] Adjusting an initial quantization parameter of each frame of the second image based on the number of macroblocks to obtain a target quantization parameter of each frame of the second image;

[0026] The video to be processed is transcoded based on the target quantization parameter and the macroblock mode corresponding to the second macroblock in each frame of the second image.

[0027] In the above solution, adjusting the initial quantization parameter of each frame of the second image based on the number of macroblocks to obtain the target quantization parameter of each frame of the second image includes:

[0028] Determining an initial quantization parameter corresponding to each frame of the second image;

[0029] Calculating the ratio of the number of macroblocks to the total number of macroblocks in the target image to obtain a target value;

[0030] The initial quantization parameter is adjusted based on the target value to obtain the target quantization parameter.

[0031] In the above solution, adjusting the initial quantization parameter based on the target value to obtain the target quantization parameter includes:

[0032] When the target value is less than the first value, performing operation processing on the initial quantization parameter based on the first parameter threshold to obtain the target quantization parameter;

[0033] When the target value is greater than the second value, the initial quantization parameter is processed based on the second parameter threshold to obtain the target quantization parameter.

[0034] A video transcoding device, comprising:

[0035] an acquisition unit, configured to acquire a plurality of first image frames corresponding to a video to be processed, a cost of a first macroblock in each first image frame, and a macroblock mode corresponding to the first macroblock; wherein the plurality of first image frames are obtained by encoding the video to be processed based on a first bit rate;

[0036] The acquisition unit is further configured to acquire a plurality of frames of second images corresponding to the video to be processed and a cost of a second macroblock in each frame of the second image; wherein the plurality of frames of second images are obtained by encoding the video to be processed based on a second bit rate, and the second bit rate is lower than the first bit rate;

[0037] a processing unit, configured to determine a macroblock mode corresponding to the second macroblock based on the cost of the first macroblock, the cost of the second macroblock, and the macroblock mode corresponding to the first macroblock;

[0038] The processing unit is further configured to perform transcoding processing on the video to be processed based on the macroblock modes corresponding to the multiple frames of second images and the second macroblocks.

[0039] A video transcoding device, comprising: a processor, a memory, and a communication bus;

[0040] The communication bus is used to realize the communication connection between the processor and the memory;

[0041] The processor is used to execute the video transcoding program in the memory to implement the steps of the above-mentioned video transcoding method.

[0042] A computer-readable storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps of the above-mentioned video transcoding method.

[0043] Because multiple frames of first images corresponding to the video to be processed, the cost of the first macroblock in each frame of the first image, and the macroblock mode corresponding to the first macroblock are obtained, multiple frames of second images corresponding to the video to be processed, the cost of the second macroblock in each frame of the second image are obtained, and then based on the cost of the first macroblock, the cost of the second macroblock, and the macroblock mode corresponding to the first macroblock, the macroblock mode corresponding to the second macroblock is determined, and then based on the macroblock mode corresponding to the multiple frames of the second image and the second macroblock, the video to be processed is transcoded; wherein the second bit rate is lower than the first bit rate; in this way, by using the cost of the first macroblock in each frame of the first image of the video to be processed encoded at the first bit rate and the macroblock mode corresponding to the first macroblock as a reference, the second macroblock in the multiple frames of the second image encoded at the second bit rate is analyzed, and the macroblock mode corresponding to the second macroblock can be quickly determined, thereby reducing the amount of calculation in the transcoding process, overcoming the problem of slow transcoding speed caused by the large amount of calculation in the transcoding process in the prior art, and improving the speed of determining the macroblock mode corresponding to the second macroblock, thereby improving the transcoding speed. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] Figure 1 A schematic diagram of a video transcoding method according to an embodiment of the present invention;

[0045] Figure 2 A schematic diagram of another video transcoding method provided in an embodiment of the present application;

[0046] Figure 3 A schematic diagram of a flow chart of another video transcoding method provided in an embodiment of the present application;

[0047] Figure 4 A schematic flow chart of a video transcoding method provided in another embodiment of the present application;

[0048] Figure 5 A schematic diagram of the structure of a video transcoding device provided in an embodiment of the present application;

[0049] Figure 6 A schematic diagram of the structure of a video transcoding device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0050] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application.

[0051] It should be understood that the “embodiments of the present application” or “the aforementioned embodiments” mentioned throughout the specification mean that the specific features, structures or characteristics related to the embodiments are included in at least one embodiment of the present application. Therefore, “in the embodiments of the present application” or “in the aforementioned embodiments” appearing throughout the specification do not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. In the various embodiments of the present application, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application. The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages and disadvantages of the embodiments.

[0052] Unless otherwise specified, when an electronic device performs any step in the embodiments of the present application, the processor of the electronic device may perform the step. It is also worth noting that the embodiments of the present application do not limit the order in which the electronic device performs the following steps. In addition, the methods used to process data in different embodiments may be the same method or different methods. It should also be noted that any step in the embodiments of the present application can be independently executed by the electronic device, that is, when the electronic device performs any step in the following embodiments, it can be independent of the execution of other steps.

[0053] It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application.

[0054] The embodiment of the present application provides a video transcoding method, which can be applied to a video transcoding device. Figure 1 As shown, the method includes the following steps:

[0055] Step 101: Obtain multiple frames of first images corresponding to a video to be processed, the cost of a first macroblock in each frame of the first image, and a macroblock mode corresponding to the first macroblock.

[0056] The multiple frames of first images are obtained by encoding the video to be processed based on the first bit rate.

[0057] In an embodiment of the present application, the video to be processed is a video that currently needs to be transcoded. The video to be processed may be one video or multiple videos. The embodiment of the present application does not limit the number of videos to be processed. The multiple frames of first images are obtained after encoding the video to be processed based on a first bit rate; wherein, the first bit rate can be pre-set, and the first bit rate can be set according to actual business needs; in a feasible manner, the first bit rate can be a high bit rate, so as to provide a reference in the subsequent transcoding process of the video to be processed based on a second bit rate. At this time, the multiple frames of first images are multiple frames of images obtained after encoding the video to be processed based on a high bit rate. The first macroblock is a macroblock in the first image. Each frame of the first image may include multiple first macroblocks. The cost of the first macroblock may be the motion vector of the first macroblock. The macroblock mode corresponding to the first macroblock is the prediction mode adopted by the first macroblock, so as to obtain better image quality with minimal computational complexity.

[0058] In a feasible method, a high-bitrate encoding operation can be performed on the processed video, and then the encoded multiple frames of first images, the cost of the first macroblock in each frame of the first image, and the macroblock mode corresponding to the first macroblock are stored frame by frame, so as to provide a reference in the subsequent transcoding process of the processed video based on the second bit rate.

[0059] Step 102: Obtain multiple frames of second images corresponding to the video to be processed and the cost of the second macroblock in each frame of the second image.

[0060] The multiple frames of second images are obtained by encoding the video to be processed based on a second bit rate, and the second bit rate is lower than the first bit rate.

[0061] In an embodiment of the present application, the second bit rate can be pre-set and can be set according to business needs, as long as the second bit rate is less than the first bit rate. Since the image after transcoding the processed video based on a high bit rate retains richer image information, it can provide a reference and analysis basis for the process of transcoding the processed video based on a low bit rate, so the second bit rate must be less than the first bit rate. In one feasible embodiment, the second bit rate can be a low bit rate, and the multiple frames of second images are multiple frames of images after encoding the processed video based on the low bit rate. The second macroblock is a macroblock in the second image, and each frame of the second image can include multiple second macroblocks. The cost of the second macroblock can be the motion vector of the second macroblock.

[0062] In a feasible method, a low-bit-rate encoding operation can be performed on the processed video, and then the encoded multiple frames of second images are stored frame by frame, with the cost of the second macroblock in each frame of the second image; the multiple frames of second images and the multiple frames of first images are stored frame by frame in order to align the first image with the second image, so as to facilitate the subsequent reference and analysis basis for the second image through the image information in the first image.

[0063] Step 103: Determine the macroblock mode corresponding to the second macroblock based on the cost of the first macroblock, the cost of the second macroblock, and the macroblock mode corresponding to the first macroblock.

[0064] In the embodiment of the present application, the macroblock mode corresponding to the second macroblock is the prediction mode adopted by the second macroblock, so as to obtain better image quality with minimum computational complexity. The macroblock mode corresponding to the second macroblock is determined based on the cost of the first macroblock, the cost of the second macroblock, and the macroblock mode corresponding to the first macroblock, that is, the macroblock mode corresponding to the second macroblock is determined based on the multiple frames of first images transcoded at the first code rate, the cost of the first macroblock in each frame of the first image, the macroblock mode corresponding to the first macroblock, and the cost of the second macroblock in the multiple frames of the second image encoded at the second code rate; since the first code rate is greater than the second code rate, the image information included in each frame of the first image encoded at the first code rate is richer than the image information included in each frame of the second image encoded at the second code rate. At this time, the cost of the first macroblock in each frame of the first image encoded at the first code rate of the video to be processed and the macroblock mode corresponding to the first macroblock can be used as a reference and analysis basis to analyze the second macroblock in the multiple frames of the second image encoded at the second code rate to quickly determine the macroblock mode corresponding to the second macroblock, reduce the amount of calculation in the transcoding process, and improve the speed of determining the macroblock mode corresponding to the second macroblock.

[0065] Step 104 : performing transcoding processing on the video to be processed based on the macroblock modes corresponding to the multiple frames of second images and the second macroblocks.

[0066] In an embodiment of the present application, after determining the macroblock mode corresponding to the second macroblock, operations such as predictive coding, transform coding, and entropy coding can be performed on multiple frames of the second image based on the macroblock mode corresponding to the second macroblock to achieve transcoding of the video to be processed. Since the speed of determining the macroblock mode corresponding to the second macroblock is increased, the amount of computation is reduced, and thus, transcoding the video to be processed based on the macroblock mode corresponding to the multiple frames of the second image and the second macroblock can be improved.

[0067] The video transcoding method provided in the embodiment of the present application analyzes the second macroblocks in multiple frames of second images encoded at a second bit rate by taking the cost of the first macroblock in each frame of the first image of the video to be processed encoded at a first bit rate and the macroblock mode corresponding to the first macroblock as a reference. This method can quickly determine the macroblock mode corresponding to the second macroblock, reduce the amount of calculation in the transcoding process, overcome the problem of slow transcoding speed caused by the large amount of calculation in the transcoding process in the prior art, improve the speed of determining the macroblock mode corresponding to the second macroblock, and thus improve the transcoding speed.

[0068] Based on the above embodiments, the present application provides a video transcoding method, referring to Figure 2 As shown, the method includes the following steps:

[0069] Step 201: A video transcoding device obtains a plurality of first image frames corresponding to a video to be processed, a cost of a first macroblock in each first image frame, and a macroblock mode corresponding to the first macroblock.

[0070] The multiple frames of first images are obtained by encoding the video to be processed based on the first bit rate.

[0071] Step 202: The video transcoding device obtains multiple frames of second images corresponding to the video to be processed and the cost of the second macroblock in each frame of the second image.

[0072] The multiple frames of second images are obtained by encoding the video to be processed based on a second bit rate, and the second bit rate is lower than the first bit rate.

[0073] Step 203: For each second macroblock, the video transcoding device determines a target macroblock corresponding to each second macroblock from the first macroblock.

[0074] In the embodiment of the present application, each frame of the second image may include multiple second macroblocks, so analyzing each frame of the second image means analyzing each second macroblock in each frame of the second image; wherein, the operation of analyzing each second macroblock is similar, and the embodiment of the present application is described here by taking each second macroblock as an example. The target macroblock is a macroblock corresponding to each second macroblock determined from the first macroblock; when analyzing each second macroblock, it is necessary to first determine the target macroblock corresponding to the second macroblock from the first macroblock in the first image corresponding to the second image where the second macroblock is located, and use the target macroblock as a reference macroblock to analyze the macroblock pattern corresponding to the second macroblock; simply, if each second macroblock is the first macroblock in the first frame of the second image stored by frame after encoding, then the target macroblock corresponding to the second macroblock is the first macroblock in the first frame of the first image stored by frame after encoding.

[0075] Step 204: The video transcoding device determines a macroblock mode corresponding to each second macroblock based on the relationship between the cost of the target macroblock and the cost of each second macroblock, and the relationship between the macroblock mode corresponding to the target macroblock and the first mode.

[0076] The first mode indicates that each second macroblock has no motion vector and no pixel residual.

[0077] In the embodiment of the present application, since the target macroblock and each second macroblock are both obtained by encoding the video to be processed, but using different bit rates, the target macroblock and each second macroblock have a certain relationship. Therefore, based on the relationship between the cost of the target macroblock and the cost of each second macroblock, and the relationship between the macroblock mode corresponding to the target macroblock and the first mode, the macroblock mode corresponding to each second macroblock can be quickly determined. The first mode indicates that each second macroblock has no motion vector and no pixel residual; in one feasible embodiment, the first mode can be a skip mode.

[0078] In one feasible method, after determining the target macroblock corresponding to each second macroblock, the cost of the target macroblock can be determined from the cost of the stored first macroblock, and then the macroblock mode corresponding to each second macroblock can be quickly determined based on the relationship between the cost of the target macroblock and the cost of each second macroblock and the relationship between the macroblock mode corresponding to the target macroblock and the first mode.

[0079] Step 205: For each frame of the second image, the video transcoding device determines a target image corresponding to each frame of the second image from the first image.

[0080] In an embodiment of the present application, the target image is the first image corresponding to each frame of the second image; in a feasible manner, for each frame of the second image, the order of each frame of the second image is first determined, and then the first image with the same order is determined, and this first image is determined as the target image; that is, if each frame of the second image is the first frame of the second image stored by frame after encoding, then the target image is the first frame of the first image stored by frame after encoding.

[0081] Step 206: The video transcoding device determines the number of macroblocks in the target image whose macroblock mode is the first mode.

[0082] In an embodiment of the present application, if the first mode is the skip mode, then the number of macroblocks in the target image whose macroblock mode is the first mode is determined, that is, the number of macroblocks in the target image whose macroblock mode is the skip mode is determined.

[0083] Step 207: The video transcoding device adjusts the initial quantization parameter of each frame of the second image based on the number of macroblocks to obtain a target quantization parameter of each frame of the second image.

[0084] In the embodiment of the present application, the quantization parameter can reflect the compression of the image in terms of spatial details. The value of the quantization parameter is inversely proportional to the image quality, that is, the smaller the value of the quantization parameter, the finer the quantization and the higher the image quality; conversely, the larger the value of the quantization parameter, the coarser the quantization and the worse the image quality; the initial quantization parameter can be pre-set and can be set according to actual business needs. The embodiment of the present application does not limit this; the target quantization parameter is the adjusted quantization parameter. The initial quantization parameter is adjusted based on the number of macroblocks in the target image whose macroblock mode is the first mode, that is, the initial quantization parameter is adaptively adjusted based on the number of macroblocks in the first mode, so that the adjusted target quantization parameter can be more consistent with the image and ensure image quality.

[0085] Step 208: The video transcoding device performs transcoding processing on the video to be processed based on the target quantization parameter and the macroblock mode corresponding to the second macroblock in each frame of the second image.

[0086] In an embodiment of the present application, based on the cost of the first macroblock in each frame of the first image encoded at the first bit rate and the macroblock mode corresponding to the first macroblock as a reference, the speed of determining the macroblock mode corresponding to the second macroblock can be improved, thereby improving the transcoding speed; at the same time, transcoding the video to be processed based on the target quantization parameter can ensure the image quality of the video to be processed after transcoding.

[0087] It should be noted that, for the description of the same steps and contents in this embodiment as those in other embodiments, reference can be made to the description in other embodiments and will not be repeated here.

[0088] The video transcoding method provided in the embodiment of the present application analyzes the second macroblocks in multiple frames of second images encoded at a second bit rate by taking the cost of the first macroblock in each frame of the first image of the video to be processed encoded at a first bit rate and the macroblock mode corresponding to the first macroblock as a reference. This method can quickly determine the macroblock mode corresponding to the second macroblock, reduce the amount of calculation in the transcoding process, overcome the problem of slow transcoding speed caused by the large amount of calculation in the transcoding process in the prior art, improve the speed of determining the macroblock mode corresponding to the second macroblock, and thus improve the transcoding speed.

[0089] Based on the above embodiments, the present application provides a video transcoding method, referring to Figure 3 As shown, the method includes the following steps:

[0090] Step 301: A video transcoding device obtains multiple frames of first images corresponding to a video to be processed, the cost of a first macroblock in each frame of the first image, and a macroblock mode corresponding to the first macroblock.

[0091] The multiple frames of first images are obtained by encoding the video to be processed based on the first bit rate.

[0092] Step 302: The video transcoding device obtains multiple frames of second images corresponding to the video to be processed and the cost of the second macroblock in each frame of the second image.

[0093] The multiple frames of second images are obtained by encoding the video to be processed based on a second bit rate, and the second bit rate is lower than the first bit rate.

[0094] Step 303: For each second macroblock, the video transcoding device determines a target macroblock corresponding to each second macroblock from the first macroblock.

[0095] It should be noted that after step 303 , step 304 , or step 305 , or steps 306 to 307 , or steps 308 to 309 may be executed.

[0096] Step 304: When the cost of each second macroblock is less than the cost of the target macroblock and the macroblock mode corresponding to the target macroblock is the first mode, the video transcoding device determines that the macroblock mode corresponding to each second macroblock is the first mode.

[0097] The first mode indicates that each second macroblock has no motion vector and no pixel residual.

[0098] In an embodiment of the present application, the cost of each second macroblock can be expressed as cur_cost, and the cost of the target macroblock can be expressed as info_curcost. If the first mode is the skip mode, then when cur_cost < info_curcost and the macroblock mode corresponding to the target macroblock is the skip mode, it is determined that the macroblock mode corresponding to each second macroblock is the skip mode.

[0099] Step 305: When the cost of each second macroblock is greater than the cost of the target macroblock and the macroblock mode corresponding to the target macroblock is the first mode, the video transcoding device determines that the macroblock mode corresponding to each second macroblock is the second mode.

[0100] The second mode indicates that each second macroblock has pixel residuals but no motion vector.

[0101] In an embodiment of the present application, the second mode characterizes that each second macroblock has pixel residuals and no motion vectors. In a feasible manner, the second mode can be a P16x16 mode; wherein, the P macroblock refers to the use of previously decoded pixels as a reference to achieve intra-frame prediction, and 16x16 means that the size of the P macroblock is 16x16; if the first mode is the skip mode, then when cur_cost>info_curcost, and the macroblock mode corresponding to the target macroblock is the skip mode, it is determined that the macroblock mode corresponding to each second macroblock is the P16x16 mode.

[0102] Step 306: When the cost of each second macroblock is less than the cost of the target macroblock and the macroblock mode corresponding to the target macroblock is not the first mode, or when the cost of each second macroblock is greater than the cost of the target macroblock and the macroblock mode corresponding to the target macroblock is not the first mode, the video transcoding device determines the optimal macroblock mode for each second macroblock based on the first mode decision method.

[0103] The optimal macroblock mode indicates that the prediction cost of each second macroblock is the smallest.

[0104] In an embodiment of the present application, the first mode decision method can be a mode decision method obtained by removing the skip mode judgment operation from the existing mode decision method, that is, without performing the skip mode judgment operation, directly performing the P16x16 mode judgment operation and the subsequent P8x8 mode and I4x4 mode judgment operations, and selecting the mode with the lowest cost as the optimal macroblock mode. If the first mode is the skip mode, then when cur_cost < info_curcost and the macroblock mode corresponding to the target macroblock is not the skip mode, the optimal macroblock mode for each second macroblock is determined based on the first mode decision method; or, when cur_cost > info_curcost and the macroblock mode corresponding to the target macroblock is not the skip mode, the optimal macroblock mode for each second macroblock is determined based on the first mode decision method.

[0105] Step 307: The video transcoding device determines that the macroblock mode corresponding to each second macroblock is the optimal macroblock mode.

[0106] In the embodiment of the present application, after the optimal macroblock mode is determined, the optimal macroblock mode is determined as the macroblock mode corresponding to each second macroblock.

[0107] Step 308 : When the cost of each second macroblock is equal to the cost of the target macroblock, the video transcoding device determines the optimal macroblock mode for each second macroblock based on the second mode decision method.

[0108] In an embodiment of the present application, the second mode decision method may be an existing mode decision method. The optimal macroblock mode for each second macroblock is determined based on the second mode decision method when the cost of each second macroblock is equal to the cost of the target macroblock, that is, when the cost of each second macroblock is equal to the cost of the target macroblock and the macroblock mode corresponding to the target macroblock is the first mode, or when the cost of each second macroblock is equal to the cost of the target macroblock and the macroblock mode corresponding to the target macroblock is not the first mode, the optimal macroblock mode for each second macroblock is determined based on the second mode decision method.

[0109] In one feasible manner, when cur_cost = info_curcost and the macroblock mode corresponding to the target macroblock is the skip mode, the optimal macroblock mode of each second macroblock is determined based on the second mode decision method; or, when cur_cost = info_curcost and the macroblock mode corresponding to the target macroblock is not the skip mode, the optimal macroblock mode of each second macroblock is determined based on the second mode decision method; that is, when cur_cost = info_curcost, the existing mode decision method is directly used to determine the optimal macroblock mode.

[0110] Step 309: The video transcoding device determines that the macroblock mode corresponding to each second macroblock is the optimal macroblock mode.

[0111] The first mode decision method does not include the operation of judging the first mode in the second mode decision method.

[0112] In an embodiment of the present application, when the cost of each second macroblock is less than the cost of the target macroblock and the macroblock mode corresponding to the target macroblock is the first mode, the macroblock mode corresponding to each second macroblock can be directly determined to be the first mode; and when the cost of each second macroblock is greater than the cost of the target macroblock and the macroblock mode corresponding to the target macroblock is the first mode, the macroblock mode corresponding to each second macroblock can be determined to be the second mode, without having to execute the existing mode decision method once, so the speed is higher; secondly, when the cost of each second macroblock is less than the cost of the target macroblock and the macroblock mode corresponding to the target macroblock is not the first mode, or when the cost of each second macroblock is greater than the cost of the target macroblock and the macroblock mode corresponding to the target macroblock is not the first mode, the existing judgment operation on the first mode can be skipped to determine the optimal macroblock mode for each second macroblock. Compared with the existing mode decision method, the judgment steps are reduced, so the speed is faster; therefore, compared with the existing technology that requires executing the mode decision method once for each macroblock, the determination speed of the macroblock mode corresponding to the second macroblock is faster and the computational complexity is lower.

[0113] It should be noted that step 310 may be executed after step 304 , step 305 , step 307 and step 309 .

[0114] Step 310: For each frame of the second image, the video transcoding device determines a target image corresponding to each frame of the second image from the first image.

[0115] Step 311: The video transcoding device determines the number of macroblocks in the target image whose macroblock mode is the first mode.

[0116] Step 312: The video transcoding device determines an initial quantization parameter corresponding to each frame of the second image.

[0117] In an embodiment of the present application, the initial quantization parameter is a quantization parameter initially set for the video to be processed; further, the initial quantization parameter can be set for each frame of the video to be processed, that is, each frame of the video to be processed has a corresponding initial quantization parameter, and the initial quantization parameters corresponding to different frames of the video can be the same or different, and the initial quantization parameters can be set according to actual business needs, which is not limited in this embodiment of the present application. In one achievable method, when processing each frame of the second image, the initial quantization parameter corresponding to each frame of the second image can be predetermined so that the initial quantization parameter can be adjusted later.

[0118] Step 313: The video transcoding device calculates the ratio of the number of macroblocks to the total number of macroblocks in the target image to obtain a target value.

[0119] In the embodiment of the present application, the target value is the ratio of the number of macroblocks in the target image whose macroblock mode is the first mode to the total number of macroblocks in the target image. In one feasible approach, the number of macroblocks in the target image whose macroblock mode is the first mode can be first counted, and then the total number of macroblocks in the target image can be determined. The target value can then be obtained by dividing the number of macroblocks by the total number of macroblocks.

[0120] Step 314: The video transcoding device adjusts the initial quantization parameter based on the target value to obtain a target quantization parameter.

[0121] In an embodiment of the present application, the initial quantization parameter is adjusted based on the proportion of macroblocks in the target image that are in the first mode, so that the adjusted target quantization parameter is more closely aligned with the image, ensuring image quality. In one feasible approach, the initial quantization parameter can be processed based on a target parameter threshold corresponding to the target value to obtain the target quantization parameter; the target parameter threshold can be pre-set and can be set based on actual business needs and business experience.

[0122] Step 314 can be implemented by the following steps:

[0123] Step 314a: When the target value is less than the first value, the video transcoding device performs calculation processing on the initial quantization parameter based on the first parameter threshold to obtain the target quantization parameter.

[0124] In an embodiment of the present application, the first numerical value and the first parameter threshold can be pre-set. The first numerical value and the first parameter threshold can be set according to actual business needs and business experience, and the embodiment of the present application does not limit this; in a feasible manner, the first numerical value can be set to 0.2, and the first parameter threshold can be set to 0.5.

[0125] In one feasible approach, when the target value is less than the first value, the initial quantization parameter can be subtracted from the first parameter threshold to obtain the target parameter threshold; that is, if the first value is 0.2 and the first parameter threshold is 0.5, then when the target value is less than 0.2, the initial parameter threshold is subtracted from 0.5 to obtain the target parameter threshold.

[0126] Step 314b: When the target value is greater than the second value, the video transcoding device performs calculation processing on the initial quantization parameter based on the second parameter threshold to obtain the target quantization parameter.

[0127] In an embodiment of the present application, the second numerical value and the second parameter threshold can be pre-set, and the second numerical value and the second parameter threshold can be set according to actual business needs and business experience, and the embodiment of the present application does not limit this; wherein, the second parameter threshold can be the same as the first parameter threshold, or can be different from the first parameter threshold; in a feasible manner, the second numerical value can be set to 0.85, and the second parameter threshold can be set to 0.5.

[0128] In one feasible approach, when the target value is greater than the second value, the initial quantization parameter can be added to the second parameter threshold to obtain the target parameter threshold; that is, if the second value is 0.85 and the second parameter threshold is 0.5, then when the target value is greater than 0.85, the initial parameter threshold is added to 0.5 to obtain the target parameter threshold.

[0129] In other embodiments of the present application, if the target value is neither less than the first value nor greater than the second value, in this case, the initial parameter threshold is not adjusted and the initial parameter threshold is directly determined as the target parameter threshold.

[0130] Step 315: The video transcoding device transcodes the video to be processed based on the target quantization parameter and the macroblock mode corresponding to the second macroblock in each frame of the second image.

[0131] like Figure 4As shown, the multiple frames of first images after encoding the video to be processed based on the first bit rate can be expressed as {Info1, Info2, Info3, ..., Infon}; wherein n is the number of frames of the multiple frames of first images; the multiple frames of second images after encoding the video to be processed based on the second bit rate can be expressed as {1, 2, 3, ..., N}; wherein N is the number of frames of the multiple frames of second images; the cost of the first macroblock in each frame of the first image after encoding the video to be processed at the first bit rate and the macroblock mode of the first macroblock are obtained. In this way, when encoding the video to be processed at the second bit rate which is lower than the first bit rate, after obtaining the cost of the second macroblock in each frame of the second image after encoding the video to be processed at the second bit rate, the cost of the second macroblock can be analyzed based on the cost of the first macroblock in each frame of the first image and the macroblock mode of the first macroblock, and the macroblock mode corresponding to the second macroblock can be quickly determined. Then, the processing is transcoded based on the multiple frames of second images and the macroblock mode corresponding to the macroblock in each frame of the second image, thereby improving the transcoding speed.

[0132] The video transcoding method provided in the embodiment of the present application can also be applied to speeding up video transcoding at low resolution by using video encoding information at high resolution; specifically, multiple frames of third images of the video to be processed at high resolution, the cost of the third macroblock in each frame of the third image, and the macroblock mode corresponding to the third macroblock are obtained, and multiple frames of fourth images of the video to be processed at low resolution and the cost of the fourth macroblock in each frame of the fourth image are obtained, and then based on the cost of the third macroblock in each frame of the third image, the macroblock mode corresponding to the third macroblock, and the cost of the fourth macroblock, the macroblock mode corresponding to the fourth macroblock is quickly determined, and then the video to be processed is encoded based on the multiple frames of the fourth image and the macroblock mode corresponding to the fourth macroblock in each frame of the fourth image to obtain the video to be processed after transcoding at low resolution; wherein, the operation of quickly determining the macroblock mode corresponding to the fourth macroblock based on the cost of the third macroblock in each frame of the third image, the macroblock mode corresponding to the third macroblock, and the cost of the fourth macroblock is similar to the operation of determining the macroblock mode corresponding to the second macroblock based on the cost of the first macroblock, the macroblock mode corresponding to the first macroblock, and the cost of the second macroblock, and the embodiments of the present application will not be repeated here.

[0133] It should be noted that, for the description of the same steps and contents in this embodiment as those in other embodiments, reference can be made to the description in other embodiments and will not be repeated here.

[0134] The video transcoding method provided in the embodiment of the present application analyzes the second macroblocks in multiple frames of second images encoded at a second bit rate by taking the cost of the first macroblock in each frame of the first image of the video to be processed encoded at a first bit rate and the macroblock mode corresponding to the first macroblock as a reference. This method can quickly determine the macroblock mode corresponding to the second macroblock, reduce the amount of calculation in the transcoding process, overcome the problem of slow transcoding speed caused by the large amount of calculation in the transcoding process in the prior art, improve the speed of determining the macroblock mode corresponding to the second macroblock, and thus improve the transcoding speed.

[0135] Based on the above embodiments, the present invention provides a video transcoding device, which can be applied to Figures 1 to 3 In the video transcoding method provided in the corresponding embodiment, refer to Figure 5 As shown, the video transcoding device 4 may include:

[0136] An acquisition unit 41 is configured to acquire a plurality of first image frames corresponding to a video to be processed, a cost of a first macroblock in each first image frame, and a macroblock mode corresponding to the first macroblock; wherein the plurality of first image frames are obtained by encoding the video to be processed based on a first bit rate;

[0137] The acquisition unit 41 is further configured to acquire a plurality of frames of second images corresponding to the video to be processed and a cost of a second macroblock in each frame of the second image; wherein the plurality of frames of second images are obtained by encoding the video to be processed based on a second bit rate, and the second bit rate is lower than the first bit rate;

[0138] a processing unit 42 configured to determine a macroblock mode corresponding to the second macroblock based on the cost of the first macroblock, the cost of the second macroblock, and the macroblock mode corresponding to the first macroblock;

[0139] The processing unit 42 is further configured to perform transcoding processing on the video to be processed based on the macroblock modes corresponding to the multiple frames of second images and the second macroblocks.

[0140] In other embodiments of the present application, the processing unit 42 is specifically configured to perform the following steps:

[0141] For each second macroblock, determining a target macroblock corresponding to each second macroblock from the first macroblock;

[0142] Based on the relationship between the cost of the target macroblock and the cost of each second macroblock, and the relationship between the macroblock mode corresponding to the target macroblock and the first mode, the macroblock mode corresponding to each second macroblock is determined; wherein the first mode represents that each second macroblock has no motion vector and no pixel residual.

[0143] In other embodiments of the present application, the processing unit 42 is specifically configured to perform the following steps:

[0144] When the cost of each second macroblock is less than the cost of the target macroblock and the macroblock mode corresponding to the target macroblock is the first mode, determining that the macroblock mode corresponding to each second macroblock is the first mode;

[0145] When the cost of each second macroblock is greater than the cost of the target macroblock and the macroblock mode corresponding to the target macroblock is the first mode, the macroblock mode corresponding to each second macroblock is determined to be the second mode; wherein the second mode represents that each second macroblock has pixel residuals and no motion vectors.

[0146] In other embodiments of the present application, the processing unit 42 is specifically configured to perform the following steps:

[0147] When the cost of each second macroblock is less than the cost of the target macroblock and the macroblock mode corresponding to the target macroblock is not the first mode, or when the cost of each second macroblock is greater than the cost of the target macroblock and the macroblock mode corresponding to the target macroblock is not the first mode, determining the optimal macroblock mode for each second macroblock based on the first mode decision method;

[0148] The macroblock mode corresponding to each second macroblock is determined to be the optimal macroblock mode; wherein the optimal macroblock mode indicates that the prediction cost of each second macroblock is the minimum.

[0149] In other embodiments of the present application, the processing unit 42 is specifically configured to perform the following steps:

[0150] determining an optimal macroblock mode for each second macroblock based on a second mode decision method when the cost of each second macroblock is equal to the cost of the target macroblock;

[0151] Determine that the macroblock mode corresponding to each second macroblock is the optimal macroblock mode; wherein the first mode decision method does not include the operation of judging the first mode in the second mode decision method.

[0152] In other embodiments of the present application, the processing unit 42 is specifically configured to perform the following steps:

[0153] For each frame of the second image, determining a target image corresponding to each frame of the second image from the first image;

[0154] Determining the number of macroblocks in the target image whose macroblock mode is the first mode;

[0155] Adjusting an initial quantization parameter of each frame of the second image based on the number of macroblocks to obtain a target quantization parameter of each frame of the second image;

[0156] The video to be processed is transcoded based on the target quantization parameter and the macroblock mode corresponding to the second macroblock in each frame of the second image.

[0157] In other embodiments of the present application, the processing unit 42 is specifically configured to perform the following steps:

[0158] Determining an initial quantization parameter corresponding to each frame of the second image;

[0159] Calculate the ratio of the number of macroblocks to the total number of macroblocks in the target image to obtain the target value;

[0160] The initial quantization parameter is adjusted based on the target value to obtain the target quantization parameter.

[0161] In other embodiments of the present application, the processing unit 42 is specifically configured to perform the following steps:

[0162] When the target value is less than the first value, performing operation processing on the initial quantization parameter based on the first parameter threshold to obtain the target quantization parameter;

[0163] When the target value is greater than the second value, the initial quantization parameter is processed based on the second parameter threshold to obtain the target quantization parameter.

[0164] It should be noted that the specific description of the steps performed by each unit can be referred to Figures 1 to 3 The video transcoding method provided in the corresponding embodiment will not be described again here.

[0165] The video transcoding device provided in the embodiment of the present application analyzes the second macroblocks in multiple frames of second images encoded at a second bit rate by taking the cost of the first macroblock in each frame of the first image of the video to be processed encoded at the first bit rate and the macroblock mode corresponding to the first macroblock as a reference. This can quickly determine the macroblock mode corresponding to the second macroblock, reduce the amount of calculation in the transcoding process, overcome the problem of slow transcoding speed caused by the large amount of calculation in the transcoding process in the prior art, improve the speed of determining the macroblock mode corresponding to the second macroblock, and thus improve the transcoding speed.

[0166] Based on the above embodiments, the embodiments of the present application provide a video transcoding device, which can be applied to Figures 1 to 3 In the video transcoding method provided in the corresponding embodiment, refer to Figure 6 As shown, the video transcoding device 5 may include: a processor 51, a memory 52 and a communication bus 53, wherein:

[0167] The communication bus 53 is used to realize the communication connection between the processor 51 and the memory 52;

[0168] The processor 51 is configured to execute the video transcoding program in the memory 52 to implement the following steps:

[0169] Obtaining multiple frames of first images corresponding to the video to be processed, the cost of a first macroblock in each frame of the first image, and a macroblock mode corresponding to the first macroblock; wherein the multiple frames of first images are obtained by encoding the video to be processed based on a first bit rate;

[0170] Obtaining a plurality of frames of second images corresponding to the video to be processed and a cost of a second macroblock in each frame of the second image; wherein the plurality of frames of second images are obtained by encoding the video to be processed based on a second bit rate, and the second bit rate is less than the first bit rate;

[0171] Determining a macroblock mode corresponding to the second macroblock based on the cost of the first macroblock, the cost of the second macroblock, and the macroblock mode corresponding to the first macroblock;

[0172] The video to be processed is transcoded based on the macroblock modes corresponding to the multiple frames of second images and the second macroblocks.

[0173] In other embodiments of the present application, the processor 51 is configured to execute the video transcoding program in the memory 52 to determine the macroblock mode corresponding to the second macroblock based on the cost of the first macroblock, the cost of the second macroblock, and the macroblock mode corresponding to the first macroblock, so as to implement the following steps:

[0174] For each second macroblock, determining a target macroblock corresponding to each second macroblock from the first macroblock;

[0175] Based on the relationship between the cost of the target macroblock and the cost of each second macroblock, and the relationship between the macroblock mode corresponding to the target macroblock and the first mode, the macroblock mode corresponding to each second macroblock is determined; wherein the first mode represents that each second macroblock has no motion vector and no pixel residual.

[0176] In other embodiments of the present application, the processor 51 is configured to execute the video transcoding program in the memory 52 to determine the macroblock mode corresponding to each second macroblock based on the relationship between the cost of the target macroblock and the cost of each second macroblock, and the relationship between the macroblock mode corresponding to the target macroblock and the first mode, so as to implement the following steps:

[0177] When the cost of each second macroblock is less than the cost of the target macroblock and the macroblock mode corresponding to the target macroblock is the first mode, determining that the macroblock mode corresponding to each second macroblock is the first mode;

[0178] When the cost of each second macroblock is greater than the cost of the target macroblock and the macroblock mode corresponding to the target macroblock is the first mode, the macroblock mode corresponding to each second macroblock is determined to be the second mode; wherein the second mode represents that each second macroblock has pixel residuals and no motion vectors.

[0179] In other embodiments of the present application, the processor 51 is configured to execute the video transcoding program in the memory 52 to determine the macroblock mode corresponding to each second macroblock based on the relationship between the cost of the target macroblock and the cost of each second macroblock, and the relationship between the macroblock mode corresponding to the target macroblock and the first mode, so as to implement the following steps:

[0180] When the cost of each second macroblock is less than the cost of the target macroblock and the macroblock mode corresponding to the target macroblock is not the first mode, or when the cost of each second macroblock is greater than the cost of the target macroblock and the macroblock mode corresponding to the target macroblock is not the first mode, determining the optimal macroblock mode for each second macroblock based on the first mode decision method;

[0181] The macroblock mode corresponding to each second macroblock is determined to be the optimal macroblock mode; wherein the optimal macroblock mode indicates that the prediction cost of each second macroblock is the minimum.

[0182] In other embodiments of the present application, the processor 51 is configured to execute the video transcoding program in the memory 52 to determine the macroblock mode corresponding to each second macroblock based on the relationship between the cost of the target macroblock and the cost of each second macroblock, and the relationship between the macroblock mode corresponding to the target macroblock and the first mode, so as to implement the following steps:

[0183] determining an optimal macroblock mode for each second macroblock based on a second mode decision method when the cost of each second macroblock is equal to the cost of the target macroblock;

[0184] Determine that the macroblock mode corresponding to each second macroblock is the optimal macroblock mode; wherein the first mode decision method does not include the operation of judging the first mode in the second mode decision method.

[0185] In other embodiments of the present application, the processor 51 is configured to execute the video transcoding program in the memory 52 to perform transcoding processing on the video to be processed based on the macroblock mode corresponding to the multi-frame second image and the second macroblock, so as to implement the following steps:

[0186] For each frame of the second image, determining a target image corresponding to each frame of the second image from the first image;

[0187] Determining the number of macroblocks in the target image whose macroblock mode is the first mode;

[0188] Adjusting an initial quantization parameter of each frame of the second image based on the number of macroblocks to obtain a target quantization parameter of each frame of the second image;

[0189] The video to be processed is transcoded based on the target quantization parameter and the macroblock mode corresponding to the second macroblock in each frame of the second image.

[0190] In other embodiments of the present application, the processor 51 is configured to execute the video transcoding program in the memory 52 to adjust the initial quantization parameter of each frame of the second image based on the number of macroblocks to obtain the target quantization parameter of each frame of the second image, so as to implement the following steps:

[0191] Determining an initial quantization parameter corresponding to each frame of the second image;

[0192] Calculate the ratio of the number of macroblocks to the total number of macroblocks in the target image to obtain the target value;

[0193] The initial quantization parameter is adjusted based on the target value to obtain the target quantization parameter.

[0194] In other embodiments of the present application, the processor 51 is configured to execute the video transcoding program in the memory 52 to adjust the initial quantization parameter based on the target value to obtain the target quantization parameter, so as to implement the following steps:

[0195] When the target value is less than the first value, performing operation processing on the initial quantization parameter based on the first parameter threshold to obtain the target quantization parameter;

[0196] When the target value is greater than the second value, the initial quantization parameter is processed based on the second parameter threshold to obtain the target quantization parameter.

[0197] It should be noted that the specific description of the steps performed by the processor can be referred to Figures 1 to 3 The video transcoding method provided in the corresponding embodiment will not be described again here.

[0198] The video transcoding device provided in the embodiment of the present application analyzes the second macroblocks in multiple frames of second images encoded at a second bit rate by taking the cost of the first macroblock in each frame of the first image of the video to be processed encoded at the first bit rate and the macroblock mode corresponding to the first macroblock as a reference. The device can quickly determine the macroblock mode corresponding to the second macroblock, reduce the amount of calculation in the transcoding process, overcome the problem of slow transcoding speed caused by the large amount of calculation in the transcoding process in the prior art, improve the speed of determining the macroblock mode corresponding to the second macroblock, and thus improve the transcoding speed.

[0199] Based on the above embodiments, the embodiments of the present application provide a computer-readable storage medium, which stores one or more programs, and the one or more programs can be executed by one or more processors to implement Figures 1 to 3 The corresponding embodiment provides steps of the video transcoding method.

[0200] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of hardware embodiments, software embodiments, or embodiments combining software and hardware. Furthermore, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage and optical storage, etc.) containing computer-usable program code.

[0201] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the steps in the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0202] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0203] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0204] The above description is merely a preferred embodiment of the present application and is not intended to limit the scope of protection of the present application.

Claims

1. A video transcoding method, characterized in that: The method comprises: Obtaining multiple frames of first images corresponding to a video to be processed, a cost of a first macroblock in each frame of the first image, and a macroblock mode corresponding to the first macroblock; wherein the multiple frames of first images are obtained by encoding the video to be processed based on a first bit rate; Obtaining a plurality of frames of second images corresponding to the video to be processed and a cost of a second macroblock in each frame of the second image; wherein the plurality of frames of second images are obtained by encoding the video to be processed based on a second bit rate, and the second bit rate is less than the first bit rate; For each second macroblock, determining a target macroblock corresponding to each second macroblock from the first macroblocks; Determining a macroblock mode corresponding to each of the second macroblocks based on a relationship between the cost of the target macroblock and the cost of each of the second macroblocks, and a relationship between the macroblock mode corresponding to the target macroblock and the first mode; The video to be processed is transcoded based on the multiple frames of second images and the macroblock mode corresponding to each second macroblock.

2. The method according to claim 1, characterized in that The determining, based on a relationship between the cost of the target macroblock and the cost of each second macroblock, and a relationship between the macroblock mode corresponding to the target macroblock and the first mode, of the macroblock mode corresponding to each second macroblock includes: When the cost of each second macroblock is less than the cost of the target macroblock and the macroblock mode corresponding to the target macroblock is the first mode, determining that the macroblock mode corresponding to each second macroblock is the first mode; When the cost of each second macroblock is greater than the cost of the target macroblock and the macroblock mode corresponding to the target macroblock is the first mode, the macroblock mode corresponding to each second macroblock is determined to be the second mode.

3. The method according to claim 1, characterized in that The determining, based on a relationship between the cost of the target macroblock and the cost of each second macroblock, and a relationship between the macroblock mode corresponding to the target macroblock and the first mode, of the macroblock mode corresponding to each second macroblock includes: When the cost of each second macroblock is less than the cost of the target macroblock and the macroblock mode corresponding to the target macroblock is not the first mode, or when the cost of each second macroblock is greater than the target macroblock cost and the macroblock mode corresponding to the target macroblock is not the first mode, determining the optimal macroblock mode for each second macroblock based on the first mode decision method; The macroblock mode corresponding to each second macroblock is determined to be the optimal macroblock mode; wherein the optimal macroblock mode indicates that the prediction cost of each second macroblock is minimized.

4. The method according to claim 1, wherein The determining, based on a relationship between the cost of the target macroblock and the cost of each second macroblock, and a relationship between the macroblock mode corresponding to the target macroblock and the first mode, of the macroblock mode corresponding to each second macroblock includes: When the cost of each second macroblock is equal to the cost of the target macroblock, determining the optimal macroblock mode for each second macroblock based on a second mode decision method; Determine that the macroblock mode corresponding to each second macroblock is the optimal macroblock mode; wherein the first mode decision method does not include the operation of judging the first mode in the second mode decision method.

5. The method according to claim 1, characterized in that The transcoding process of the video to be processed based on the multiple frames of second images and the macroblock mode corresponding to each second macroblock includes: For each frame of the second image, determining a target image corresponding to the each frame of the second image from the first image; Determining the number of macroblocks in the target image whose macroblock mode is the first mode; Adjusting an initial quantization parameter of each frame of the second image based on the number of macroblocks to obtain a target quantization parameter of each frame of the second image; The video to be processed is transcoded based on the target quantization parameter and the macroblock mode corresponding to the second macroblock in each frame of the second image.

6. The method according to claim 5, characterized in that The adjusting the initial quantization parameter of each frame of the second image based on the number of macroblocks to obtain the target quantization parameter of each frame of the second image includes: Determining an initial quantization parameter corresponding to each frame of the second image; Calculating the ratio of the number of macroblocks to the total number of macroblocks in the target image to obtain a target value; The initial quantization parameter is adjusted based on the target value to obtain the target quantization parameter.

7. The method according to claim 6, characterized in that The adjusting the initial quantization parameter based on the target value to obtain the target quantization parameter includes: When the target value is less than the first value, performing operation processing on the initial quantization parameter based on the first parameter threshold to obtain the target quantization parameter; When the target value is greater than the second value, the initial quantization parameter is processed based on the second parameter threshold to obtain the target quantization parameter.

8. A video transcoding device, characterized in that: The device comprises: an acquisition unit, configured to acquire a plurality of first image frames corresponding to a video to be processed, a cost of a first macroblock in each first image frame, and a macroblock mode corresponding to the first macroblock; wherein the plurality of first image frames are obtained by encoding the video to be processed based on a first bit rate; The acquisition unit is further configured to acquire a plurality of frames of second images corresponding to the video to be processed and a cost of a second macroblock in each frame of the second image; wherein the plurality of frames of second images are obtained by encoding the video to be processed based on a second bit rate, and the second bit rate is lower than the first bit rate; a processing unit, configured to determine, for each second macroblock, from the first macroblocks, a target macroblock corresponding to each second macroblock; The processing unit is further configured to determine a macroblock mode corresponding to each second macroblock based on a relationship between a cost of the target macroblock and a cost of each second macroblock, and a relationship between a macroblock mode corresponding to the target macroblock and the first mode; The processing unit is further configured to perform transcoding processing on the video to be processed based on the multiple frames of second images and the macroblock mode corresponding to each second macroblock.

9. A video transcoding device, characterized in that: The device includes: a processor, a memory and a communication bus; The communication bus is used to realize the communication connection between the processor and the memory; The processor is configured to execute the video transcoding program in the memory to implement the steps of the video transcoding method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps of the video transcoding method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Skip macro block judgment method, video transcoding method, electronic device and storage medium

    CN108769689A

  • Real-time transcoding method and device with encoding information inheritance

    WO2017101349A1