A video encoding constant bit rate control method, system and electronic device
By working together with the scene detection module, video encoding module, and VBV caching module, the video encoding quality level is adaptively adjusted, solving the problems of high computational load and high hardware requirements in existing technologies, and achieving constant bit rate output suitable for low-latency applications.
Patent Information
- Application Number
- CN202111624083.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-28
- Publication Date
- 2025-11-11
- Estimated Expiration
- 2041-12-28
AI Technical Summary
Existing video coding technologies require a large amount of computation and high hardware requirements to achieve constant bit rate control, and different coding standards require separate algorithm development, making them difficult to adapt to low-latency applications.
Through the collaborative work of the scene detection module, video encoding module, VBV buffer module and bitrate control module, the video encoding quality level is adaptively adjusted to achieve constant bitrate output and avoid VBV buffer overflow or underflow.
It does not rely on the internal calculations of the video encoder, is suitable for low-latency applications, has low hardware configuration requirements, is compatible with different encoding standards, and achieves stable constant bit rate output.
Smart Images

Figure CN114363618B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of constant bit rate control technology, and in particular to a video coding constant bit rate control method, system and electronic device. Background Technology
[0002] In the broadcasting industry, a crucial issue is how to stably transmit video programs under fixed bandwidth. This requires video encoding equipment to achieve constant bitrate control and provide the highest possible image quality. This invention provides a bitrate control method for video encoding. This method, through the collaborative work of a scene detection module, a video encoding module, a VBV buffer module, and a bitrate control module, adaptively adjusts the video encoding quality level, ensuring constant bitrate output and avoiding VBV overflow and underflow. This meets the broadcasting industry's requirements for constant bitrate input and output.
[0003] To achieve constant bitrate control, a common approach is to set the target bitrate to the video encoder, which then calculates and analyzes the image complexity to determine a suitable encoding method to match the target bitrate. The drawbacks of this approach are its dependence on the video encoder; different standard video encoders (such as MPEG2, H.264, and H.265) require separate development of appropriate bitrate control algorithms, placing high demands on the encoder. Furthermore, this approach involves significant computation, especially since some calculations require secondary encoding, resulting in slow encoding speeds, high hardware requirements, and unsuitability for low-latency applications. Summary of the Invention
[0004] The technical problem to be solved by the present invention is to address the shortcomings of the prior art by providing a constant bit rate control method, system and electronic device for video encoding.
[0005] The technical solution of the constant bit rate control method for video coding of the present invention is as follows:
[0006] The scene detection module detects whether there is a scene transition between every two adjacent video frames in the input video, generates a scene transition identifier for each video frame, and sends it to the bitrate control module.
[0007] The video encoding module determines the encoding type of the received current video frame and sends the encoding type of the current video frame to the bitrate control module;
[0008] The bitrate control module calculates the quality level corresponding to the current video frame based on the scene transition identifier corresponding to the current video frame, the encoding type of the current video frame, and the current VBV Level information obtained from the VBV cache module, and sends the quality level corresponding to the current video frame to the video encoding module. The current VBV Level information represents the percentage of the current cached data in the VBV cache module to the total cache space.
[0009] The video encoding module encodes the current video frame according to the quality level corresponding to the current video frame, and sends the encoded data to the VBV cache module;
[0010] The VBV caching module receives and caches the encoded data, and outputs it at a constant bit rate, where VBVSize max =VBVDelay × BitRate, where BitRate represents the constant bit rate, VBVSize max This indicates the total cache space size of the VBV cache module.
[0011] The beneficial effects of the constant bit rate control method for video coding of the present invention are as follows:
[0012] Instead of relying on the internal calculations of the video encoder, this application configures the video encoder by adding external modules such as a scene detection module, a VBV caching module, and a bitrate control module. Furthermore, this application is independent of the encoding standard; it only requires the video encoder to report statistical information and perform encoding quality control. This does not affect the encoder's performance, has relatively low hardware configuration requirements, and is suitable for low-latency application services.
[0013] The technical solution of a constant bit rate control system for video encoding according to the present invention is as follows:
[0014] It includes a scene detection module, a video encoding module, a bitrate control module, and a VBV caching module;
[0015] The scene detection module is used to: detect whether there is a scene transition between every two adjacent video frames in the input video, generate a scene transition identifier corresponding to each video frame, and send it to the bitrate control module;
[0016] The video encoding module is used to: determine the encoding type of the received current video frame, and send the encoding type of the current video frame to the bitrate control module;
[0017] The bitrate control module is used to: calculate the quality level corresponding to the current video frame based on the scene transition identifier corresponding to the current video frame, the encoding type of the current video frame, and the current VBV Level information obtained from the VBV cache module, and send the quality level corresponding to the current video frame to the video encoding module, wherein the current VBV Level information represents the percentage of the current cached data in the VBV cache module to the total cache space;
[0018] The video encoding module is further configured to: encode the current video frame according to the quality level corresponding to the current video frame, and send the encoded data to the VBV cache module;
[0019] The VBV caching module is used to: receive and cache encoded data, and output it at a constant bit rate, wherein VBVSize max =VBVDelay × BitRate, where BitRate represents the constant bit rate, VBVSize max This indicates the total cache space size of the VBV cache module.
[0020] The beneficial effects of the constant bit rate control system for video encoding of the present invention are as follows:
[0021] Instead of relying on the internal calculations of the video encoder, this application configures the video encoder by adding external modules such as a scene detection module, a VBV caching module, and a bitrate control module. Furthermore, this application is independent of the encoding standard; it only requires the video encoder to report statistical information and perform encoding quality control. This does not affect the encoder's performance, has relatively low hardware configuration requirements, and is suitable for low-latency application services.
[0022] The technical solution of an electronic device according to the present invention is as follows:
[0023] The method includes a memory, a processor, and a program stored in the memory and running on the processor, wherein the processor executes the program to implement the steps of a video coding constant bit rate control method as described in any of the preceding claims. Attached Figure Description
[0024] Figure 1 This is one of the flowcharts illustrating a constant bit rate control method for video encoding according to an embodiment of the present invention;
[0025] Figure 2 This is a second flowchart illustrating a constant bit rate control method for video encoding according to an embodiment of the present invention.
[0026] Figure 3 This is a schematic diagram of a video coding constant bit rate control system according to an embodiment of the present invention; Detailed Implementation
[0027] like Figure 1 and Figure 2 As shown, an embodiment of the present invention provides a video coding constant bit rate control method, which includes the following steps:
[0028] S1. The scene detection module 210 detects whether there is a scene transition between every two adjacent video frames in the input video, generates a scene transition identifier for each video frame, and sends it to the bitrate control module 230.
[0029] S2. The video encoding module 220 determines the encoding type of the received current video frame and sends the encoding type of the current video frame to the bitrate control module 230.
[0030] S3. The bitrate control module 230 calculates the quality level corresponding to the current video frame based on the scene transition identifier corresponding to the current video frame, the encoding type of the current video frame, and the current VBV Level information obtained from the VBV cache module 240, and sends the quality level corresponding to the current video frame to the video encoding module 220. The current VBV Level information represents the percentage of the current cached data in the VBV cache module 240 to the total cache space.
[0031] The Quality Level (QL) represents the quality level at which the video encoding module 220 encodes the current video frame. A higher quality level results in less image quality loss for the current video frame and a larger encoded data size. Quality levels are used because the encoder may employ different encoding standards such as MPEG2, H.264, or H.265. The quality level is an abstract quality rating, and different encoding standards correspond to different encoding parameters. In this invention, there are 52 quality levels (from 0 to 51), defined as: QL = 51 - QP, where QP (Quantization Parameter) is the quantization parameter defined in the encoding standard.
[0032] S4. The video encoding module 220 encodes the current video frame according to the quality level corresponding to the current video frame, and sends the encoded data to the VBV buffer module 240; specifically:
[0033] The video encoding module 220 encodes the current video frame according to the encoding parameters corresponding to the quality level of the current video frame and sends the encoded data to the VBV buffer module 240. The encoded data can also be referred to as ES data.
[0034] S5 and VBV buffer module 240 receive and buffer the encoded data, and output it at a constant bit rate, where VBVSize max=VBVDelay × BitRate, where BitRate represents a constant bit rate, and VBVSize max This indicates the total cache size of the VBV cache module 240.
[0035] In other words, the VBV (Virtual Buffer Verifier) buffer module is responsible for receiving and buffering the encoded video data, and then outputting it at a constant bit rate (CBR). VBVDelay is the maximum VBV delay time set, which is generally in the range of [0.5, 1] seconds. In this application, VBVDelay is set to 0.8 seconds. BitRate is CBR, which is constant bit rate, and the unit is bits per second.
[0036] The importance of the VBV buffer in the VBV buffer module 240 lies in ensuring that data for CBR (Constant Bit Rate) output is always available. If there is no data output for CBR at any time, or if there is no data in the buffer space of the VBV buffer module 240, the video output stream will be interrupted, thereby reducing the video bit rate and resulting in inefficient use of output bandwidth. If the input data to the VBV buffer is too fast, while the output CBR is relatively slow, it can easily lead to VBV buffer overflow, resulting in data loss.
[0037] This application presents a constant bit rate control method for video encoding that does not rely on the internal calculations of the video encoder. Instead, it configures the video encoder by adding external modules such as a scene detection module, a VBV buffer module, and a bit rate control module. Specifically, it sets the quality level (QL) only for the current video frame encoding, without restricting the relationship between the quality level of a specific encoder and the internal parameter settings of the encoder. Each video encoder can set the parameter settings corresponding to the quality level according to its own encoding standard and encoding mechanism. Furthermore, this application is independent of the encoding standard. It only requires the video encoder to report statistical information and perform encoding quality control, without affecting encoder performance. It has relatively low hardware configuration requirements and is suitable for low-latency application services.
[0038] After the encoded data corresponding to each video frame arrives in the buffer area, the VBV buffer module 240 reports the percentage of the current data volume in the buffer area relative to the total buffer size (VBV Level), i.e., the current VBV Level information, to the bitrate control module 230.
[0039] Optionally, in the above technical solution, the process by which the bitrate control module 230 calculates the quality level corresponding to the current video frame includes:
[0040] S30. Calculate the estimated size of the encoded data of the current video frame based on the scene transition identifier and the encoding type of the current video frame.
[0041] S31. Calculate the quality level corresponding to the current video frame based on the estimated size of the encoded data of the current video frame and the current VBV Level information obtained from the VBV cache module 240.
[0042] Optionally, in the above technical solution, the process by which the scene detection module 210 generates a scene transition identifier corresponding to each video frame includes:
[0043] S10. Sequentially assign sequence numbers to multiple video frames in the input video, namely 1, 2...N-1, N. Calculate the scene transition identifier F of the nth video frame according to the first formula. sc [n], the first formula is: Where n∈[1,N], S represents the number of pixels in the nth video frame, Y p [n] represents the Y value of the pixel with pixel index p in the nth video frame, Cb p [n] represents the Cb value of the pixel with pixel index p in the nth video frame, Cr p [n] represents the Cr value of the pixel with pixel index p in the nth video frame, and k represents the bit depth of the nth video frame.
[0044] Optionally, in the above technical solution, the process by which the bitrate control module 230 calculates an estimated value of the data size after encoding the current video frame includes:
[0045] S300. When the scene transition flag of the current video frame is 0, and the current video frame is not the first video frame, determine the estimated value of the data size of the current video frame after encoding based on the encoded data size of the encoded video frames.
[0046] S301. When the scene transition flag of the current video frame is 1, the estimated value of the encoded data size of the current video frame (ECFS) is determined using the second formula. type [n′], the second formula is:
[0047] Where 'type' indicates the encoding type of the current video frame: I-frame, P-frame, or B-frame, CFS type [n′-1] represents the encoded data size of the n′-1th video frame when the encoding type of the current video frame is I-frame, P-frame, or B-frame.
[0048] The adjustment parameter of the bitrate control module 230 is QL. The specific implementation of the bitstream control module is as follows:
[0049] Under the same video encoding standard such as MPEG2, H.264, or H.265, with the same encoding parameters (unchanged video encoder configuration parameters and the same QL), the same encoding type (I-frame, P-frame, or B-frame), and the same video scene (without scene transitions), the size of the encoded frame data (CFS[N]) remains basically consistent without significant changes. Therefore, based on the summary of the sizes of the encoded video frames, the possible size of the current frame after encoding can be calculated, thereby selecting an appropriate QL and controlling the amount of data in the buffer of the VBV buffer module 240 within a safe range. Then:
[0050] The bitrate control module 230 calculates the quality level corresponding to the current video frame based on the estimated data size after encoding the current video frame and the current VBV Level information obtained from the VBV buffer module 240, including:
[0051] S310, When n′=1 or F sc When [n′]=1, the quality level of the current video frame is determined as the initial quality level, specifically:
[0052] 1) When n′=1, it means that the current video frame is the first video frame and encoding has not yet been performed. Therefore, the quality level of the current video frame is determined as the initial quality level. The process of obtaining the initial QL value, i.e., the initial quality level, is as follows:
[0053] By testing the encoder offline at different bitrates, the average QL value for normal operation at these bitrates was obtained. Different encoding standards correspond to a table of bitrate and initial QL value, i.e., the initial quality level. In use, the initial QL value, i.e., the initial quality level, is obtained by looking up the table at the bitrate.
[0054] 2) When F sc When [n′]=1, it indicates that a scene transition has occurred between the current video frame and the previous video frame. All internal parameters and calculation results of the bitstream control module are cleared, and the initial value of QL is reset. In other words, the quality level of the current video frame is determined as the initial quality level.
[0055] S311, when n′>1 and F sc When [n′] = 0, obtain the quality level of the (n′-1)th video frame as the initial quality level of the current video frame, and determine VBV[n′-1]. Level ×VBVSize max +ECFS type [n′] Whether it is in Q1×VBVSize max ~Q2×VBVSize maxIf the initial quality level is specified, it is used as the quality level of the current video frame. If not, the initial quality level is adjusted until the percentage of the current cached data in the VBV cache module 240 relative to the total cache space is within a preset safe percentage range. The adjusted initial quality level is then used as the quality level of the current video frame, where VBV[n′-1]... Level This represents the VBV Level value, or VBV Level information, of the (n′-1)th video frame. VBVSize max This indicates the total cache space size of the VBV cache module 240. Q1 represents the first preset percentage, and Q2 represents the second preset percentage.
[0056] The bitrate control module 230 estimates the quality level (QL) required for encoding the current video frame based on the VBV Level information obtained from the VBV cache module 240, the scene transition identifier corresponding to the current video frame obtained from the scene detection module 210, and the encoding type (e.g., I-frame, P-frame, or B-frame) corresponding to the current video frame obtained from the video encoding module 220. It then sends the QL to the video encoding module 220, instructing it to encode the video according to the QL. After encoding according to the QL, the video encoding module 220 sends the encoded frame data size to the bitrate control module 230 to enhance the accuracy of bitrate control for subsequent video frames.
[0057] The goal of the bitrate control module 230 is to ensure that the amount of data in the VBV buffer is always within a safe range during the video encoding process. This scheme defines the safe range as the range of [50%, 80%] of the maximum size of the VBV buffer, i.e., Q1 = 50%, Q2 = 80%.
[0058] The specific implementation of the S311 body is as follows:
[0059] S3110, when n′>1 and F sc When [n′]=0, obtain the quality level of the (n′-1)th video frame and use it as the initial quality level of the current video frame;
[0060] S3111, If VBV[n′-1] Level When the value is greater than 80%, then VBV[n′-1] Level ×VBVSize max It did not fall within 50% × VBVSize max ~80% × VBVSize max Between these, it is indicated that there is too much data in the buffer of the VBV buffer module 240, so the quality level corresponding to the current video frame should be reduced, so let QL[n′]=QL[n′]-1;
[0061] S3112. Substituting QL[n′]=QL[n′]-1 into the second formula, if VBV[n′-1]... Level ×VBVSize max +ECFS type [n ′ ]>80%×VBVSize max Then let QL[n′] = QL[n′] - 1. Repeat this process until VBV[n′ - 1]. Level ×VBVSize max +ECFS type [n′] will fall within 50% × VBVSize max ~80% × VBVSize max Between these points, the latest value of QL[n′] is obtained, which is the adjusted initial quality level. In other words, the latest QL[n′] is used as the quality level of the current video frame.
[0062] It should be noted that multiple values of QL[n′] may fall within 50% × VBVSize. max ~80% × VBVSize max Generally, the first value that falls into 50% × VBVSize is selected. max ~80% × VBVSize max The interval between VBV[n′-1] Level ×VBVSize max +ECFS type The QL[n′] corresponding to [n′] serves as the adjusted initial quality level, which can greatly guarantee the image quality of the current video frame.
[0063] S311 can also be implemented in the following ways:
[0064] S3113, when n′>1 and F sc When [n′]=0, obtain the quality level of the (n′-1)th video frame and use it as the initial quality level of the current video frame;
[0065] S3114. If VBV[n′-1] Level <50%, at this time VBV[n′-1] Level ×VBVSize max It did not fall within 50% × VBVSize max ~80% × VBVSize max Between these, it is indicated that the data in the buffer of the VBV buffer module 240 is too small, so the quality level corresponding to the current video frame should be increased, so let QL[n′] = QL[n′] + 1;
[0066] S3115. Substituting QL[n′]=QL[n′]+1 into the second formula, if VBV[n′-1]... Level ×VBVSize max +ECFS type [n′]<50%×VBVSize max Then let QL[n′] = QL[n′] + 1. Repeat this process until VBV[n′-1]. Level ×VBVSize max +ECFS type [n′] will fall within 50% × VBVSize max ~80% × VBVSize max Between these points, the latest QL[n′] is obtained, which is the adjusted initial quality level. In other words, the latest QL[n′] is used as the quality level of the current video frame.
[0067] It should be noted that multiple values of QL[n′] may fall within 50% × VBVSize. max ~80% × VBVSize max Generally, the last value is selected as 50% × VBVSize. max ~80% × VBVSize max The interval between VBV[n′-1] Level ×VBVSize max +ECFS type The QL[n′] corresponding to [n′] serves as the adjusted initial quality level, which can greatly guarantee the image quality of the current video frame.
[0068] Terminology Explanation:
[0069] Constant Bit Rate (CBR): A constant (fixed) bit rate refers to a transmission rate that remains constant per second. CBR is characterized by a stable bit rate, reducing the impact of network jitter and making it suitable for applications with stringent bandwidth requirements.
[0070] Video Buffer Verifier (VBV): A theoretical decoding buffer model that will neither overflow nor underflow when the input bitstream conforms to the MPEG standard.
[0071] In the above embodiments, although the steps are numbered S1, S2, etc., they are only specific embodiments given in this application. Those skilled in the art can adjust the execution order of S1, S2, etc. according to the actual situation, which is also within the protection scope of this invention. It can be understood that in some embodiments, some or all of the above embodiments may be included.
[0072] like Figure 3 As shown, a constant bit rate video encoding control system according to an embodiment of the present invention includes a scene detection module 210, a video encoding module 220, a bit rate control module 230, and a VBV buffer module 240.
[0073] The scene detection module 210 is used to: detect whether there is a scene transition between every two adjacent video frames in the input video, generate a scene transition identifier for each video frame, and send it to the bitrate control module 230;
[0074] The video encoding module 220 is used to: determine the encoding type of the received current video frame and send the encoding type of the current video frame to the bitrate control module 230;
[0075] The bitrate control module 230 is used to: calculate the quality level corresponding to the current video frame based on the scene transition identifier corresponding to the current video frame, the encoding type of the current video frame, and the current VBV Level information obtained from the VBV cache module 240, and send the quality level corresponding to the current video frame to the video encoding module 220. The current VBV Level information represents the percentage of the current cached data in the VBV cache module 240 to the total cache space.
[0076] The video encoding module 220 is also used to: encode the current video frame according to the quality level corresponding to the current video frame, and send the encoded data to the VBV buffer module 240;
[0077] VBV buffer module 240 is used to: receive and buffer encoded data, and output it at a constant bit rate, wherein VBVSize max =VBVDelay × BitRate, where BitRate represents a constant bit rate, and VBVSize max This indicates the total cache size of the VBV cache module 240.
[0078] Optionally, in the above technical solution, the process by which the bitrate control module 230 calculates the quality level corresponding to the current video frame includes:
[0079] Based on the scene transition identifier corresponding to the current video frame and the encoding type of the current video frame, calculate the estimated data size of the current video frame after encoding;
[0080] The quality level corresponding to the current video frame is calculated based on the estimated data size after encoding the current video frame and the current VBV Level information obtained from the VBV cache module 240.
[0081] Optionally, in the above technical solution, the process by which the scene detection module 210 generates a scene transition identifier corresponding to each video frame includes:
[0082] For multiple video frames in the input video, assign sequential numbers 1, 2...N-1, N. Calculate the scene transition identifier F of the nth video frame according to the first formula. sc [n], the first formula is: Where n∈[1,N], S represents the number of pixels in the nth video frame, Y p [n] represents the Y value of the pixel with pixel index p in the nth video frame, Cb p [n] represents the Cb value of the pixel with pixel index p in the nth video frame, Cr p [n] represents the Cr value of the pixel with pixel index p in the nth video frame, and k represents the bit depth of the nth video frame.
[0083] Optionally, in the above technical solution, the process by which the bitrate control module 230 calculates an estimated value of the data size after encoding the current video frame includes:
[0084] When the scene transition flag of the current video frame is 0, and the current video frame is not the first video frame, the estimated value of the data size of the current video frame after encoding is determined based on the encoded data size of the already encoded video frames.
[0085] When the scene transition flag of the current video frame is 1, the estimated size of the encoded data of the current video frame (ECFS) is determined using the second formula. type [n′], the second formula is:
[0086] Where 'type' indicates the encoding type of the current video frame: I-frame, P-frame, or B-frame, CFS type [n′-1] represents the encoded data size of the n′-1th video frame when the encoding type of the current video frame is I-frame, P-frame, or B-frame.
[0087] Optionally, in the above technical solution, the process by which the bitrate control module 230 calculates the quality level corresponding to the current video frame based on the estimated data size after encoding the current video frame and the current VBV Level information obtained from the VBV cache module 240 includes:
[0088] When n′=1 or F sc When [n′]=1, the quality level of the current video frame is determined as the initial quality level;
[0089] When n′>1 and F scWhen [n′] = 0, obtain the quality level of the (n′-1)th video frame as the initial quality level of the current video frame, and determine VBV[n′-1]. Level ×VBVSize max +ECFS type [n′] Whether it is in Q1×VBVSize max ~Q2×VBVSize max If the initial quality level is specified, it is used as the quality level of the current video frame. If not, the initial quality level is adjusted until the percentage of the current cached data in the VBV cache module 240 relative to the total cache space is within a preset safe percentage range. The adjusted initial quality level is then used as the quality level of the current video frame, where VBV[n′-1]... Level This represents the VBV Level value, or VBV Level information, of the (n′-1)th video frame. VBVSize max This indicates the total cache space size of the VBV cache module 240. Q1 represents the first preset percentage, and Q2 represents the second preset percentage.
[0090] The steps for implementing the corresponding functions of each parameter and each unit module in the video coding constant bit rate control system of the present invention described above can be referred to the parameters and steps in the embodiments of the video coding constant bit rate control method described above, and will not be repeated here.
[0091] An electronic device according to an embodiment of the present invention includes a memory, a processor, and a program stored in the memory and running on the processor. When the processor executes the program, it implements the steps of a video coding constant bit rate control method according to any of the above embodiments.
[0092] The electronic device can be a computer, mobile phone, etc., and the corresponding program is computer software or mobile APP, etc. The parameters and steps of the above-mentioned electronic device of the present invention can be referred to the parameters and steps of the embodiment of the video coding constant bit rate control method in the above text, and will not be repeated here.
[0093] Those skilled in the art will know that this invention can be implemented as a system, method, or computer program product.
[0094] Therefore, this disclosure can be implemented in the following forms: it can be entirely hardware, entirely software (including firmware, resident software, microcode, etc.), or a combination of hardware and software, generally referred to herein as a "circuit," "module," or "system." Furthermore, in some embodiments, the invention can also be implemented as a computer program product in one or more computer-readable media, the computer-readable medium containing computer-readable program code.
[0095] Any combination of one or more computer-readable media may be used. A computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in connection with an instruction execution system, apparatus, or device.
[0096] Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.
Claims
1. A constant bit rate control method for video coding, characterized in that, include: The scene detection module detects whether there is a scene transition between every two adjacent video frames in the input video, generates a scene transition identifier for each video frame, and sends it to the bitrate control module. The video encoding module determines the encoding type of the received current video frame and sends the encoding type of the current video frame to the bitrate control module; The bitrate control module calculates the quality level corresponding to the current video frame based on the scene transition identifier corresponding to the current video frame, the encoding type of the current video frame, and the current VBV Level information obtained from the VBV cache module, and sends the quality level corresponding to the current video frame to the video encoding module. The current VBV Level information represents the percentage of the current cached data in the VBV cache module to the total cache space. The video encoding module encodes the current video frame according to the quality level corresponding to the current video frame, and sends the encoded data to the VBV cache module; The VBV caching module receives and caches the encoded data, and outputs it at a constant bit rate, where VBVSize max =VBVDelay × BitRate, where BitRate represents the constant bit rate, VBVSize max This indicates the total cache space size of the VBV cache module, and VBVDelay indicates the maximum VBV delay time; The process by which the bitrate control module calculates the quality level corresponding to the current video frame includes: Based on the scene transition identifier corresponding to the current video frame and the encoding type of the current video frame, calculate an estimated value of the data size of the current video frame after encoding; The quality level corresponding to the current video frame is calculated based on the estimated data size after encoding the current video frame and the current VBV Level information obtained from the VBV cache module. The process by which the scene detection module generates a scene transition identifier for each video frame includes: For multiple video frames in the input video, assign sequential numbers 1, 2...N-1, N. Calculate the scene transition identifier F of the nth video frame according to the first formula. sc [n], the first formula is: Where n∈[1,N], S represents the number of pixels in the nth video frame, Y p [n] represents the Y value of the pixel with pixel index p in the nth video frame, Cb p [n] represents the Cb value of the pixel with pixel index p in the nth video frame, Cr p [n] represents the Cr value of the pixel with pixel index p in the nth video frame, and k represents the bit depth of the nth video frame; The process by which the bitrate control module calculates an estimated value of the encoded data size of the current video frame includes: When the scene transition flag of the current video frame is 0, and the current video frame is not the first video frame, the estimated value of the encoded data size of the current video frame is determined based on the encoded data size of the encoded video frames. When the scene transition flag of the current video frame is 1, the estimated size of the encoded data of the current video frame (ECFS) is determined using the second formula. type [n′], the second formula is: Wherein, type indicates that the encoding type of the current video frame is I-frame, P-frame, or B-frame, CFS type [n′-1] represents the encoded data size of the (n′-1)th video frame when the encoding type of the current video frame is I-frame, P-frame, or B-frame. The process by which the bitrate control module calculates the quality level corresponding to the current video frame based on an estimated value of the encoded data size of the current video frame and the current VBV Level information obtained from the VBV cache module includes: When n′=1 or F sc When [n′]=1, the quality level of the current video frame is determined as the initial quality level; When n′>1 and F sc When [n′] = 0, obtain the quality level of the (n′-1)th video frame as the initial quality level of the current video frame, and determine VBV[n′-1]. Level ×VBVSize max +ECFS type [n′] Whether it is in Q1×VBVSize max ~Q2×VBVSize max If the initial quality level is within the specified range, then the initial quality level is used as the quality level of the current video frame; otherwise, the initial quality level is adjusted until the percentage of the current cached data in the VBV cache module relative to the total cache space is within a preset safe percentage range. The adjusted initial quality level is then used as the quality level of the current video frame, where VBV[n′-1]... Level VBVSize represents the VBV Level value of the (n′-1)th video frame. max Q1 represents the total cache space size of the VBV cache module, Q2 represents the first preset percentage, and Q1 represents the second preset percentage.
2. A constant bit rate control system for video encoding, characterized in that, It includes a scene detection module, a video encoding module, a bitrate control module, and a VBV caching module; The scene detection module is used to: detect whether there is a scene transition between every two adjacent video frames in the input video, generate a scene transition identifier corresponding to each video frame, and send it to the bitrate control module; The video encoding module is used to: determine the encoding type of the received current video frame, and send the encoding type of the current video frame to the bitrate control module; The bitrate control module is used to: calculate the quality level corresponding to the current video frame based on the scene transition identifier corresponding to the current video frame, the encoding type of the current video frame, and the current VBV Level information obtained from the VBV cache module, and send the quality level corresponding to the current video frame to the video encoding module, wherein the current VBV Level information represents the percentage of the current cached data in the VBV cache module to the total cache space; The video encoding module is further configured to: encode the current video frame according to the quality level corresponding to the current video frame, and send the encoded data to the VBV cache module; The VBV caching module is used to: receive and cache encoded data, and output it at a constant bit rate, wherein VBVSize max =VBVDelay × BitRate, where BitRate represents the constant bit rate, VBVSize max This indicates the total cache space size of the VBV cache module, and VBVDelay indicates the maximum VBV delay time; The process by which the bitrate control module calculates the quality level corresponding to the current video frame includes: Based on the scene transition identifier corresponding to the current video frame and the encoding type of the current video frame, calculate an estimated value of the data size of the current video frame after encoding; The quality level corresponding to the current video frame is calculated based on the estimated data size after encoding the current video frame and the current VBV Level information obtained from the VBV cache module. The process by which the scene detection module generates a scene transition identifier for each video frame includes: For multiple video frames in the input video, assign sequential numbers 1, 2...N-1, N. Calculate the scene transition identifier F of the nth video frame according to the first formula. sc [n], the first formula is: Where n∈[1,N], S represents the number of pixels in the nth video frame, Y p [n] represents the Y value of the pixel with pixel index p in the nth video frame, Cb p [n] represents the Cb value of the pixel with pixel index p in the nth video frame, Cr p [n] represents the Cr value of the pixel with pixel index p in the nth video frame, and k represents the bit depth of the nth video frame; The process by which the bitrate control module calculates an estimated value of the encoded data size of the current video frame includes: When the scene transition flag of the current video frame is 0, and the current video frame is not the first video frame, the estimated value of the encoded data size of the current video frame is determined based on the encoded data size of the encoded video frames. When the scene transition flag of the current video frame is 1, the estimated size of the encoded data of the current video frame (ECFS) is determined using the second formula. type [n′], the second formula is: Wherein, type indicates that the encoding type of the current video frame is I-frame, P-frame, or B-frame, CFS type [n′-1] represents the encoded data size of the (n′-1)th video frame when the encoding type of the current video frame is I-frame, P-frame, or B-frame. The bitrate control module calculates the quality level corresponding to the current video frame based on the estimated size of the encoded data and the current VBV Level information obtained from the VBV cache module. This process includes: When n′=1 or F sc When [n′]=1, the quality level of the current video frame is determined as the initial quality level; When n′>1 and F sc When [n′] = 0, obtain the quality level of the (n′-1)th video frame as the initial quality level of the current video frame, and determine VBV[n′-1]. Level ×VBVSize max +ECFS type [n′] Whether it is in Q1×VBVSize max ~Q2×VBVSize max If the initial quality level is specified, it is used as the quality level of the current video frame; otherwise, the initial quality level is adjusted until the percentage of the current cached data in the VBV cache module (240) to the total cache space is within a preset safe percentage range. The adjusted initial quality level is then used as the quality level of the current video frame, where VBV[n′-1] is the initial quality level. Level This represents the VBV Level value, or VBV Level information, of the (n′-1)th video frame. VBVSize max W1 represents the total cache space of the VBV cache module (240), W2 represents the first preset percentage, and W1 represents the second preset percentage.
3. An electronic device comprising a memory, a processor, and a program stored in the memory and running on the processor, characterized in that, When the processor executes the program, it implements the steps of the video encoding constant bit rate control method as described in claim 1.
Citation Information
Patent Citations
Method and apparatus for rate control for constant-bit-rate-finite-buffer-size video encoder
US20070147512A1