Method, device, storage medium and electronic device for controlling video bit rate

By identifying ROI and non-ROI regions in video frames and calculating and adjusting the quantization parameters of each macroblock separately, the problem of bitrate increase in ROI regions and bitrate waste in non-ROI regions is solved, thereby improving video quality and optimizing resources.

CN117812264BActive Publication Date: 2025-11-25SHUXING TECH (BEIJING) CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211172966.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-26
Publication Date
2025-11-25
Estimated Expiration
2042-09-26

AI Technical Summary

Technical Problem

In video encoding, the introduction of Region of Interest (ROI) leads to an increase in ROI bitrate and a decrease in compression rate. Background bitrate is wasted and video clarity is reduced. Existing ROI bitrate adjustment methods are not suitable for static backgrounds and non-static foreground scenes, resulting in overall bitrate and bandwidth waste.

Method used

By identifying ROI and non-ROI regions in video frames, the first and second adjustment parameters for each macroblock are calculated. The quantization parameters are adjusted to optimize the bitrate allocation between ROI and non-ROI regions, ensuring improved video quality in ROI regions and avoiding bitrate waste and distortion in non-ROI regions.

Benefits of technology

It improves video quality in the ROI region, avoids wasting bitrate and bandwidth in the ROI region, and saves bitrate in the non-ROI region, thus avoiding video quality distortion in the non-ROI region.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117812264B_ABST
    Figure CN117812264B_ABST
Patent Text Reader

Abstract

The application discloses a method, device, storage device and electronic device for controlling video code rate. The method comprises the following steps: decoding an input video to obtain an input code rate of each macro block in each image in the input video; identifying an ROI region in each image; calculating a first adjustment parameter for each macro block in the ROI region based on the input code rate; and adjusting the first adjustment parameter to obtain a first quantization parameter and a first adjusted code rate. The application can make the video in the ROI region clearer, avoid waste of code rate and bandwidth in the ROI region, save code rate in a non-ROI region, and avoid large distortion of video quality in the non-ROI region.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present disclosure relates to the field of digital video coding, and in particular, to a method and apparatus for controlling video bit rate, a storage medium, and an electronic device. BACKGROUND

[0002] In current video applications, video transcoding is involved in many scenarios. Video transcoding refers to converting a video bitstream that has been compressed and encoded into another video bitstream according to certain encoding standards, bit rates, and the like, that is, a process of decoding a video first and then encoding the video. The bit rate refers to the amount of data transmitted per unit of time during video transmission, that is, the number of bits per second.

[0003] In recent years, the subjective quality of a video has attracted more and more attention from the video coding industry, because the human eye often focuses on the region of interest (ROI) of a video, such as a face, a human body, and a foreground object.

[0004] To improve the subjective quality of a video, researchers attempt to introduce the concept of ROI into video coding. In video coding, different bit rate allocations will result in different outcomes, such as a video region with a higher bit rate allocation has a better video quality, and a video region with a lower bit rate allocation has a poorer video quality. Therefore, different bit rate allocations will affect the subjective quality of a video. In video coding, after the introduction of ROI, the QP_offset of the ROI region and the non-ROI region is adjusted to allocate more bit rates to the ROI region, thereby improving the video quality of the region, and conversely, less bit rates are allocated to the non-ROI region to weaken the video quality of the region. Indeed, the introduction of ROI brings better subjective quality of a video, but it also causes some other problems in video coding.

[0005] After the introduction of ROI, the bit rate of video coding will be affected unpredictably, for example, the bit rate of a video with a large ROI region will rise, causing a problem of a decreased compression rate. Moreover, some situations are not suitable for ROI processing. For example, the background of a video is a static scene, and the foreground is a non-static scene. In this case, the background will only be allocated very few bit rates, and the foreground has occupied most of the bit rates, that is, this case already has an ROI effect. If the bit rate of the foreground is further increased, the overall bit rate will rise, causing waste of bit rate and bandwidth. If the bit rate of the background, which is already very low, is further compressed, some relatively large distortions will occur, resulting in a decrease in the clarity of the output video. In addition, the bit rate adjustment of the ROI region in the past is mainly based on fixed QP_offset adjustment, which will also cause the overall bit rate of the ROI region to rise. SUMMARY

[0006] The embodiment of the present application provides a method for controlling video code rate, a device for controlling video code rate, a storage medium, an electronic device and a computer program product.

[0007] In a first aspect, the embodiment of the present application provides a method for controlling video code rate, which is used for an electronic device, and the method comprises the following steps:

[0008] A decoding step is performed to decode an input video to obtain an input code rate of each macro block in each frame of the input video;

[0009] A recognition step is performed to recognize a region of interest (ROI) in each frame of the image;

[0010] A calculation step is performed to calculate a first adjustment parameter based on the input code rate for each macro block in the ROI region;

[0011] An adjustment step is performed to obtain a first quantization parameter by using the first adjustment parameter for each macro block in the ROI region, so as to obtain a first adjusted code rate.

[0012] In a possible implementation of the first aspect, each frame of the image comprises a non-ROI region,

[0013] The calculation step further comprises the following steps: calculating a second adjustment parameter based on the input code rate for each macro block in the non-ROI region,

[0014] The adjustment step further comprises the following steps: obtaining a second quantization parameter by using the second adjustment parameter for each macro block in the non-ROI region, so as to obtain a second adjusted code rate.

[0015] In a possible implementation of the first aspect, in the calculation step, the first adjustment parameter is calculated by using a first calculation mode based on the input code rate, a maximum input code rate in each frame of the image, a pixel number of the ROI region, a pixel number of each frame of the image and a preset intensity value of the ROI region for each macro block in the ROI region.

[0016] In a possible implementation of the first aspect, in the calculation step, the second adjustment parameter is calculated by using a second calculation mode based on the input code rate, a maximum input code rate in each frame of the image, a pixel number of the ROI region, a pixel number of each frame of the image and a preset intensity value of the ROI region for each macro block in the non-ROI region.

[0017] In a possible implementation of the first aspect, in the adjusting step, for each of the macroblocks in the ROI region, the initial quantization parameter of each of the macroblocks is adjusted by using the first adjustment parameter of each of the macroblocks to obtain the first quantization parameter of each of the macroblocks, and the first quantization parameter makes the first adjusted code rate of each of the macroblocks greater than the input code rate.

[0018] In a possible implementation of the first aspect, in the adjusting step, for each of the macroblocks in the non-ROI region, the initial quantization parameter of each of the macroblocks is adjusted by using the second adjustment parameter of each of the macroblocks to obtain the second quantization parameter of each of the macroblocks, and the second quantization parameter makes the second adjusted code rate of each of the macroblocks less than the input code rate.

[0019] In a possible implementation of the first aspect, the method further includes: encoding a corresponding macroblock according to the first adjusted code rate of each of the macroblocks in the ROI region.

[0020] In a possible implementation of the first aspect, the method further includes: encoding a corresponding macroblock according to the second adjusted code rate of each of the macroblocks in the non-ROI region.

[0021] In a second aspect, an embodiment of the present application provides a computer program product, including computer executable instructions, characterized in that the instructions are executed by a processor to implement the method for controlling a video code rate in the first aspect.

[0022] In a third aspect, an embodiment of the present application provides a computer readable storage medium, characterized in that the storage medium stores instructions, and the instructions, when executed on a computer, cause the computer to execute the method for controlling a video code rate in the first aspect.

[0023] In a fourth aspect, an embodiment of the present application provides an electronic device, including: one or more processors; one or more memories; wherein the one or more memories store one or more programs, and when the one or more programs are executed by the one or more processors, the electronic device is caused to execute the method for controlling a video code rate in the first aspect.

[0024] In a fifth aspect, an embodiment of the present application provides a device for controlling a video code rate, including:

[0025] a decoding unit configured to decode an input video to obtain an input code rate of each macroblock in each frame of the input video;

[0026] a recognition unit configured to recognize an ROI region in each frame of the image;

[0027] a calculating unit configured to calculate, for each of the macroblocks in the ROI region, a first adjusting parameter based on the input code rate;

[0028] a calculating unit configured to calculate, for each of the macroblocks in the ROI region, a first adjusting parameter based on the input code rate;

[0029] In the present application, the input code rate of each macroblock is used to adjust the code rate of each macroblock in the ROI region and the non-ROI region in different ways, so that the video in the ROI region is clearer, the waste of code rate and bandwidth in the ROI region is avoided, and the code rate in the non-ROI region is saved while avoiding large distortion of the video quality in the non-ROI region. BRIEF DESCRIPTION OF DRAWINGS

[0030] Figure 1 According to some embodiments of the present application, a block diagram of an electronic device is shown.

[0031] Figure 2 According to some embodiments of the present application, a flow chart of a method of controlling video code rate is shown.

[0032] Figure 3 According to some embodiments of the present application, a structural diagram of an apparatus for controlling video code rate is shown. DETAILED DESCRIPTION

[0033] Illustrative embodiments of the present application include, but are not limited to, a method of controlling video code rate, an apparatus for controlling video code rate, a medium, an electronic device, and a computer program product.

[0034] The embodiments of the present application will be described in further detail below with reference to the accompanying drawings.

[0035] Figure 1 According to some embodiments of the present application, a block diagram of an electronic device is shown.

[0036] As shown in Figure 1 The electronic device 100 can include one or more processors 102, a system motherboard 108 connected to at least one of the processors 102, a system memory 104 connected to the system motherboard 108, a non-volatile memory (NVM) 106 connected to the system motherboard 108, and a network interface 110 connected to the system motherboard 108.

[0037] The processor 102 can include one or more single-core or multi-core processors. The processor 102 can include any combination of general-purpose processors (CPUs) and dedicated processors (e.g., graphics processors, application processors, baseband processors, etc.). A graphics processing unit (GPU) is a specialized processor designed to rapidly manipulate and alter memory to accelerate the creation of images in a frame buffer intended for output to a display. In embodiments of the application, the processor 102 can be configured to perform one or more of the various embodiments as shown in FIG. 1. Figure 2

[0038] In some embodiments, the system motherboard 108 can include any suitable interface controller (not shown in FIG. 1) to provide any suitable interface to at least one of the processors 102 and / or any suitable device or component in communication with the system motherboard 108. Figure 1

[0039] In some embodiments, the system motherboard 108 can include one or more memory controllers to provide an interface to the system memory 104. The system memory 104 can be used to load and store data and / or instructions 120. In some embodiments, the system memory 104 of the electronic device 100 can include any suitable volatile memory, such as a suitable dynamic random access memory (DRAM).

[0040] The non-volatile memory 106 can include one or more tangible, non-transitory computer-readable media for storage of data and / or instructions 120. In some embodiments, the non-volatile memory 106 can include any suitable non-volatile memory and / or any suitable non-volatile storage device, such as at least one of a flash memory, a hard disk drive (HDD), a Compact Disc (CD) drive, a Digital Versatile Disc (DVD) drive, etc.

[0041] The non-volatile memory 106 can include a portion of the storage resources installed on the device of the electronic device 100, or it can be accessed by an external device, but not necessarily part of the external device. For example, the non-volatile memory 106 can be accessed via the network interface 110 over a network.

[0042] In particular, the system memory 104 and the non-volatile memory 106 can include, respectively, a temporary copy and a permanent copy of the instructions 120. The instructions 120 can include instructions that, when executed by at least one of the processors 102, cause the electronic device 100 to implement one or more of the various embodiments as shown in FIG. 1. Figure 2 ​​instructions of the illustrated method. In some embodiments, the instructions 120, hardware, firmware, and / or software components thereof can additionally / alternatively be disposed in the system motherboard 108, the network interface 110, and / or the processor 102.

[0043] The network interface 110 can include a transceiver to provide a radio interface for the electronic device 100 to communicate with any other suitable device (e.g., a front-end module, an antenna, etc.) over one or more networks. In some embodiments, the network interface 110 can be integrated with other components of the electronic device 100. For example, the network interface 110 can be integrated with at least one of the processor 102, the system memory 104, the non-volatile memory 106, and a firmware device (not shown) having instructions that, when executed by at least one of the processors 102, cause the electronic device 100 to implement one or more of the various embodiments illustrated. Figure 2 one or more of the various embodiments illustrated.

[0044] The network interface 110 can further include any suitable hardware and / or firmware to provide a multiple-input multiple-output radio interface. For example, the network interface 110 can be a network adapter, a wireless network adapter, a telephone modem, and / or a wireless modem.

[0045] In one embodiment, at least one of the processors 102 can be packaged with one or more controllers for the system motherboard 108 to form a system-in-a-package (SiP). In one embodiment, at least one of the processors 102 can be integrated on the same die with one or more controllers for the system motherboard 108 to form a system-on-a-chip (SoC).

[0046] The electronic device 100 can further include an input / output (I / O) device 112 coupled to the system motherboard 108. The I / O device 112 can include a user interface to enable a user to interact with the electronic device 100; a peripheral component interface to enable peripheral components to also interact with the electronic device 100. In some embodiments, the electronic device 100 also includes a sensor to determine at least one of environmental conditions and location information related to the electronic device 100.

[0047] In some embodiments, the I / O device 112 can include, but is not limited to, a display (e.g., a liquid crystal display, a touch screen display, etc.), a speaker, a microphone, one or more cameras (e.g., a still image camera and / or a video camera), a flashlight (e.g., a light-emitting diode flash), a keyboard, and a graphics card. The graphics card is composed of a graphics processor integrated with an I / O interface (e.g., a PCIE interface) conforming to a data transmission protocol specification.

[0048] In some embodiments, the peripheral component interface can include, but is not limited to, a non-volatile memory port, an audio jack, and a power interface.

[0049] In some embodiments, the sensors can include, but are not limited to, a gyroscope sensor, an accelerometer, a proximity sensor, an ambient light sensor, and a positioning unit. The positioning unit can also be part of or interact with the network interface 110 to communicate with components of a positioning network (e.g., Global Positioning System (GPS) satellites).

[0050] It can be understood that the structures illustrated in the embodiments of the present application do not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 can include more or fewer components than illustrated, or combine certain components, or split certain components, or different arrangement of components. The illustrated components can be implemented in hardware, software, or a combination of software and hardware.

[0051] The program code can be applied to input instructions to perform the functions described in the present application and to generate output information. The output information can be applied to one or more output devices in a known manner. For the purpose of the present application, the system for processing instructions including the processor 102 includes any system having a processor such as a digital signal processor (DSP), a microcontroller, an application specific integrated circuit (ASIC), or a microprocessor.

[0052] The program code can be implemented in a high-level programming language or an object-oriented programming language to communicate with the processing system. When necessary, the program code can also be implemented in assembly language or machine language. In fact, the mechanisms described in the present application are not limited to the scope of any specific programming language. In any case, the language can be a compiled language or an interpreted language.

[0053] One or more aspects of at least one embodiment can be implemented by instructions stored on a computer-readable storage medium that, when executed by a processor, enable an electronic device to implement methods of embodiments described in the present application.

[0054] The method for controlling video code rate provided in the present application can be applied in Figure 1 The electronic device 100 shown is, for example, a computer, a mobile device, a platform device, etc.

[0055] Figure 2 is a flowchart of the method for controlling video code rate according to the present application.

[0056] Referring to Figure 2 In the decoding step S201, the input video is decoded to obtain the input code rate of each macroblock in each frame of the input video.

[0057] It can be understood that the decoded input video includes multiple frames of images, and each frame of image includes multiple macroblocks. A macroblock (MB for short) is a basic encoding unit in the H.264 video encoding standard. Each macroblock occupies a certain amount of bytes, that is, an input code rate. The code rate is the number of bits per unit time, which directly reflects the bandwidth cost.

[0058] It can be understood that the input code rate of each macroblock in each frame of image in the input video refers to the code rate of the input video before transcoding.

[0059] In the identifying step S202, the ROI region in each frame of image is identified. For example, each decoded frame of image is a YUV (color encoding method) image, and the ROI region in a frame of image can be identified through the YUV image.

[0060] In the calculating step S203, for each macroblock in the ROI region, the first adjustment parameter is calculated based on the input code rate.

[0061] Specifically, for each macroblock in the ROI region, the first adjustment parameter is calculated by using a first calculation method based on the input code rate, the maximum input code rate in each frame of image, the number of pixels of the ROI region, the number of pixels of each frame of image, and a preset intensity value of the ROI region.

[0062] For example, taking the mth frame of image as an example, the ROI region is identified from the mth frame of image, and for each macroblock in the ROI region, the first adjustment parameter of each macroblock is calculated by using the following formula 1 (i.e., the first calculation method).

[0063]

[0064] Wherein, QP_Offset roi_mb (i) represents the first adjustment parameter of the ith macroblock in the ROI region, strength is the preset intensity value of the ROI region, S roi is the number of pixels of the ROI region, S frame is the number of pixels of the mth frame of image, mb_bytes(i) is the input code rate of the ith macroblock in the ROI region, and Max_Mb_Bytes is the maximum input code rate in the input code rates of all macroblocks in the mth frame of image.

[0065] It can be understood that after the mth frame of image is decoded and the ROI region is identified from the mth frame of image, S roi and S frame can be obtained. The specific method can use the prior art, which will not be described in detail here.

[0066] It can be understood that the value of strength can be preset by a user before transcoding the input video, i.e., before decoding the input video.

[0067] Here, QP_Offset is an offset of QP, which is used as an adjustment parameter of each macroblock. QP refers to Quantization Parameter, which can be used to control the size of the output code rate of video compression in the encoding process. By adjusting the size of QP, the number of bits allocated by the encoder to each encoding unit (macroblock) can be adjusted. The smaller the QP value, the more bits, the lower the compression rate but the better the video quality, i.e., QP is inversely proportional to the code rate. That is, the lower the QP, the higher the picture quality. The value range of QP is, for example, (0-51).

[0068] Using formula 1, the first adjustment parameter QP_Offset of each macroblock in the ROI region can be calculated. roi_mb (i). It can be understood that the first adjustment parameter of each macroblock is different for different input code rates mb_bytes(i) of each macroblock.

[0069] Further, each frame of image includes a non-ROI region, i.e., a region other than the ROI region in each frame of image as a non-ROI region.

[0070] In this calculation step S203, further including calculating a second adjustment parameter based on the input code rate for each macroblock in the non-ROI region.

[0071] Specifically, for each macroblock in the non-ROI region, the second adjustment parameter is calculated based on the input code rate, the maximum input code rate in each frame of image, the number of pixels in the ROI region, the number of pixels in each frame of image, and the preset strength value of the ROI region, using a second calculation method.

[0072] For example, taking the mth frame of image as an example, for each macroblock in the non-ROI region (NROI), the second adjustment parameter of each macroblock is calculated using formula 2 (i.e., the second calculation method) as follows.

[0073]

[0074] where QP_Offset nroi_mb (i) represents the second adjustment parameter of the ith macroblock in the non-ROI region, strength is the preset strength value of the ROI region, S roi is the number of pixels in the ROI region, S frameLet be the number of pixels in the m-th frame, mb_bytes(i) be the input bitrate of the i-th macroblock in the non-ROI region, and Max_Mb_Bytes be the maximum input bitrate among all macroblocks in the m-th frame.

[0075] Using Formula 2, the second adjustment parameter QP_Offset for each macroblock in the non-ROI region can be calculated. nroi_mb (i). Understandably, the second adjustment parameter for each macroblock varies depending on the input bitrate mb_bytes(i) of each macroblock.

[0076] In adjustment step S204, for each macroblock in the ROI region, the first adjustment parameter is used to obtain the first quantization parameter, thereby obtaining the first adjusted bitrate.

[0077] Specifically, for each macroblock in the ROI region, the first adjustment parameter QP_Offset of each macroblock is used. roi_mb (i) to adjust the initial quantization parameters of each macroblock to obtain the first quantization parameters of each macroblock, the first quantization parameters making the first adjusted bit rate of each macroblock greater than the input bit rate.

[0078] For example, taking the m-th frame image as an example, the i-th macroblock in the ROI region has an initial quantization parameter QP. ini_roi_mb (i) using the first adjustment parameter QP_Offset of the i-th macroblock roi_mb (i) to adjust the initial quantization parameter QP of the i-th macroblock. ini_roi_mb (i). For example, the first adjustment parameter QP_Offset of the i-th macroblock. roi_mb (i) and the initial quantization parameters QP of the i-th macroblock ini_roi_mb (i) Perform summation to obtain the first quantization parameter QP of the i-th macroblock. obj_roi_mb (i). Then, based on the first quantization parameter QP of the i-th macroblock. obj_roi_mb (i) Obtain the first adjusted bitrate of the i-th macroblock, i.e., the adjusted bitrate. It is understandable that the process of obtaining the bitrate from the quantization parameter QP is the same as in the existing technology, so it will not be described in detail here.

[0079] As can be seen from Formula 1 above, the first quantization parameter of each macroblock in the ROI region is less than the initial quantization parameter. Since the quantization parameter is inversely proportional to the bitrate, the first adjusted bitrate obtained from the first quantization parameter is greater than the input bitrate obtained from the initial quantization parameter. Therefore, the first adjusted bitrate of each macroblock in the ROI region is adjusted to be greater than the input bitrate, thereby making the video quality corresponding to each macroblock in the ROI region clearer.

[0080] Further, according to the above formula 1, it can be seen that the greater the input code rate of a certain macroblock in the ROI region, the more the first quantization parameter is reduced compared with the initial quantization parameter. Since the quantization parameter is inversely proportional to the code rate, the greater the first adjusted code rate is adjusted, and thus the video quality corresponding to the macroblock is clearer. In addition, since the first adjusted code rate of each macroblock is obtained by adjusting the input code rate of each macroblock in the ROI region respectively, the waste of code rate and bandwidth in the ROI region caused by uniform adjustment of the code rate is avoided.

[0081] In the adjusting step S204, for each macroblock in the non-ROI region, a second adjusted code rate is obtained by using a second adjusted parameter to obtain a second quantization parameter.

[0082] Specifically, for each macroblock in the non-ROI region, the initial quantization parameter of each macroblock is adjusted by using the second adjusted parameter QP_Offset nroi_mb (i) of each macroblock to obtain the second quantization parameter of each macroblock, and the second quantization parameter makes the second adjusted code rate of each macroblock less than the input code rate.

[0083] For example, still taking the mth frame of image as an example, the ith macroblock in the non-ROI region has an initial quantization parameter QP ini_nroi_mb (i), and the initial quantization parameter QP nroi_mb (i) of the ith macroblock is adjusted by using the second adjusted parameter QP_Offset ini_nroi_mb (i) of the ith macroblock. For example, the second adjusted parameter QP_Offset nroi_mb (i) of the ith macroblock is summed with the initial quantization parameter QP ini_nroi_mb (i) of the ith macroblock to obtain the second quantization parameter QP obj_nroi_mb (i) of the ith macroblock. Then, the second adjusted code rate, i.e. the adjusted code rate, of the ith macroblock is obtained according to the second quantization parameter QP obj_nroi_mb (i) of the ith macroblock. It can be understood that the process of obtaining the code rate from the quantization parameter QP is the same as that of the prior art, and thus will not be described in detail here.

[0084] According to the above formula 2, it can be seen that the second quantization parameter of each macroblock in the non-ROI region is greater than the initial quantization parameter, and since the quantization parameter is inversely proportional to the code rate, the second adjusted code rate obtained from the second quantization parameter is less than the input code rate obtained from the initial quantization parameter. Therefore, the second adjusted code rate of each macroblock in the non-ROI region is adjusted to be less than the input code rate, so as to reduce the code rate allocated to each macroblock in the non-ROI region and save the code rate in the non-ROI region.

[0085] Further, according to the above-mentioned formula 2, it can be seen that the greater the input code rate of a certain macroblock in the non-ROI region, the more the second quantization parameter is adjusted compared with the initial quantization parameter. Since the quantization parameter is inversely proportional to the code rate, the more the second adjusted code rate is adjusted. Therefore, the code rate in the non-ROI region can be further saved. In addition, since the second adjusted code rate of each macroblock in the non-ROI region is adjusted according to the input code rate of each macroblock in the non-ROI region, respectively, the video quality in the non-ROI region is avoided from being greatly distorted due to the uniform adjustment of the code rate.

[0086] It can be understood that for each frame of image, the corresponding macroblock is encoded according to the first adjusted code rate of each macroblock in the ROI region, and the corresponding macroblock is encoded according to the second adjusted code rate of each macroblock in the non-ROI region, thereby generating an output video, i.e., a transcoded video.

[0087] In the present application, based on the input code rate of each macroblock of the input video (i.e., the code rate allocation of the input video), the code rate of each macroblock in the ROI region and the non-ROI region is adjusted in different ways, respectively, so that the video in the ROI region is clearer, while avoiding the waste of code rate and bandwidth in the ROI region, and the code rate in the non-ROI region can be saved, while avoiding the video quality in the non-ROI region from being greatly distorted.

[0088] The present application also provides a device for controlling video code rate. As shown in Figure 3 The device 30 for controlling video code rate comprises: a decoding unit 301 for decoding the input video to obtain the input code rate of each macroblock in each frame of image in the input video; an identifying unit 302 for identifying the ROI region in each frame of image; a calculating unit 303 for calculating a first adjustment parameter based on the input code rate for each macroblock in the ROI region; and an adjusting unit 304 for obtaining a first quantization parameter by using the first adjustment parameter for each macroblock in the ROI region, thereby obtaining a first adjusted code rate. It can be understood that the decoding unit 301, the identifying unit 302, the calculating unit 303 and the adjusting unit 304 can be realized by the processor 102 having the functions of these modules or units in the electronic device 100. The above-mentioned embodiments are the method embodiments corresponding to the present embodiment, and the present embodiment can be implemented in cooperation with the above-mentioned embodiments. The related technical details mentioned in the above-mentioned embodiments are still valid in the present embodiment, and in order to reduce repetition, they will not be described here. Correspondingly, the related technical details mentioned in the present embodiment can also be applied in the above-mentioned embodiments.

[0089] The application also provides a computer program product comprising computer executable instructions for execution by a processor 102 to implement the method of controlling video bit rate of the application.

[0090] The application also provides a computer readable storage medium having stored thereon instructions which, when executed by a computer, cause the computer to perform the method of controlling video bit rate of the application.

[0091] It should be noted that the relative terms, such as first and second, etc., are used only to distinguish one entity or action from another, and do not necessarily require or imply that there is any such relationship or order between these entities or actions. Also, the terms "comprises", "comprising", or any other variations thereof are intended to cover a non-exclusive inclusion, so that a process, method, article, or apparatus that comprises a list of elements does not include only those elements, but can also include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without more limitations, an element defined by the statement "comprising a" does not exclude the existence of additional identical elements in the process, method, article, or apparatus that includes the element.

[0092] Although the application has been illustrated and described with reference to certain preferred embodiments thereof, it should be understood by those skilled in the art that various changes in form and detail can be made therein without departing from the spirit and scope of the application.

[0093] It should be noted that the above-mentioned sequence of the embodiments of the application is only for description, and does not represent the advantages and disadvantages of the embodiments. The above-mentioned specific embodiments of the present application are described. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multi-task processing and parallel processing are possible or advantageous.

[0094] It should be understood that the various features of the application sometimes are grouped together in a single embodiment, figure, or description of related features, for the purpose of streamlining the disclosure and aiding in the understanding of one or more of the various aspects of the application. The disclosure, however, is not to be interpreted in that manner. That is, the various aspects and features of the application can be used alone or in any combination(s) thereof. The application is not to be construed as requiring that the various aspects and features be used together in any particular embodiment or combination. Rather, the various aspects and features of the application are to be construed in that manner only if the application specifically states otherwise.

[0095] Those skilled in the art will appreciate that the modules in the apparatuses in the embodiments can be adapted and placed in one or more apparatuses other than the embodiments. The modules or units or components in the embodiments can be combined into one module or unit or component, and further can be divided into multiple sub-modules or sub-units or sub-components. Any combination of all the features disclosed in the specification (including the accompanying claims, abstract and drawings), and any method or apparatus so disclosed, can be taken in any combination, except that at least some of such features and / or processes or units are mutually exclusive. Unless explicitly stated otherwise, each feature disclosed in the specification (including the accompanying claims, abstract and drawings) can be replaced by alternative features that serve the same, equivalent or similar purpose.

[0096] Further, those skilled in the art will appreciate that the features of the different embodiments can be combined in any combination, which is meant to be within the scope of the application and forms different embodiments. For example, in the claims, any of the claimed embodiments can be used in any combination.

Claims

1. A method for controlling video bitrate, used in an electronic device, characterized in that, The method comprises: a decoding step of decoding an input video to obtain an input code rate of each macroblock in each frame of the input video; an identifying step of identifying a ROI region in each frame of the input video; a calculating step of calculating, for each macroblock in the ROI region, a first adjustment parameter based on the input code rate; an adjusting step of obtaining, for each macroblock in the ROI region, a first quantization parameter by using the first adjustment parameter, thereby obtaining a first adjusted code rate, the first adjustment parameter is calculated by using the following formula 1, ; wherein, represents the first adjustment parameter of the i-th macroblock in the ROI region, strength is a preset strength value of the ROI region, is a pixel number of the ROI region, is a pixel number of the m-th frame image, is the input code rate of the i-th macroblock in the ROI region, is the maximum input code rate among the input code rates of all macroblocks in the m-th frame image.

2. The method of claim 1, wherein, each frame of the input video further comprises a non-ROI region, wherein the calculating step further comprises: calculating, for each macroblock in the non-ROI region, a second adjustment parameter based on the input code rate, wherein the adjusting step further comprises: obtaining, for each macroblock in the non-ROI region, a second quantization parameter by using the second adjustment parameter, thereby obtaining a second adjusted code rate, wherein the second adjustment parameter is calculated by using the following formula 2, ; wherein, represents a second adjustment parameter of the i-th macroblock in the non-ROI region, _nroi is the input bit rate of the i-th macroblock in the non-ROI region.

3. The method of claim 1, wherein, in the adjusting step, for each macroblock in the ROI region, the initial quantization parameter of each macroblock is adjusted by using the first adjustment parameter of each macroblock, so as to obtain the first quantization parameter of each macroblock, and the first quantization parameter makes the first adjusted code rate of each macroblock greater than the input code rate.

4. The method of claim 2, wherein, in the adjusting step, for each macroblock in the non-ROI region, the initial quantization parameter of each macroblock is adjusted by using the second adjustment parameter of each macroblock, so as to obtain the second quantization parameter of each macroblock, and the second quantization parameter makes the second adjusted code rate of each macroblock less than the input code rate.

5. The method of claim 1, wherein, further comprising: encoding, according to the first adjusted code rate of each macroblock in the ROI region, the corresponding macroblock.

6. The method of claim 2, wherein, further comprising: encoding, according to the second adjusted code rate of each macroblock in the non-ROI region, the corresponding macroblock.

7. An apparatus for controlling a video bitrate, the apparatus comprising: The device comprises: a decoding unit configured to decode an input video to obtain an input code rate of each macroblock in each frame of the input video; an identifying unit configured to identify a ROI region in each frame of the input video; a calculating unit configured to calculate, for each macroblock in the ROI region, a first adjustment parameter based on the input code rate; an adjusting unit configured to obtain, for each macroblock in the ROI region, a first quantization parameter by using the first adjustment parameter, thereby obtaining a first adjusted code rate, the first adjustment parameter is calculated by using the following formula 1, ; wherein, represents the first adjustment parameter of the i-th macroblock in the ROI region, strength is a preset strength value of the ROI region, is a pixel number of the ROI region, is a pixel number of the m-th image, is the input code rate of the i-th macroblock in the ROI region, is the maximum input code rate of all macroblocks in the m-th image.

8. A computer program product comprising computer executable instructions, characterised in that, the instructions are executed by the processor to implement the method of controlling the video code rate according to any one of claims 1-6.

9. A computer-readable storage medium, characterized in that, The storage medium has instructions stored thereon, and the instructions, when executed on a computer, cause the computer to execute the method of controlling the video code rate according to any one of claims 1-6.

10. An electronic device, comprising: comprise: one or more processors; one or more memories; The one or more memories store one or more programs, which, when executed by the one or more processors, cause the electronic device to perform the method of controlling a video code rate according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Video transcoding method and device, electronic equipment and storage medium

    CN115002512A