Code rate control method and device, electronic equipment and computer program product
By predicting the encoding complexity of video frames and adjusting the bit rate quantization scale, the delay and lag caused by bit rate fluctuations in real-time video transmission is solved, and a more stable video playback experience is achieved.
Patent Information
- Application Number
- CN202411613136.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-12
- Publication Date
- 2025-02-18
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In real-time video transmission scenarios such as live video broadcast and remote meetings, the bit rate fluctuations after video encoding are unstable, resulting in decoding delay and playback stuttering.
By predicting the encoding complexity of the frame to be encoded, the initial code rate quantization scale is obtained, and the code rate quantization scale is adjusted according to the code rate prediction value, ensuring that the total cached code rate is within a reasonable range and avoiding code rate overflow.
It improves the effect of bit rate control, reduces the delay in the encoding process, and improves the stability and user experience of video playback.
Smart Images

Figure CN119484826A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a rate control method, a rate control device, an electronic device, and a computer program product. Background Art
[0002] In real-time video transmission scenarios such as live video broadcasting and remote conferencing, whether the bit rate fluctuation of the video stream after encoding is stable greatly affects the user's playback experience.
[0003] Frames with higher bit rates often take more time to decode, and the drastic changes in bit rates will cause huge differences in the decoding time of each frame, which will cause playback jams.
[0004] In view of this, there is an urgent need in the art for a rate control method that can improve the rate control effect and reduce the delay of the encoding process.
[0005] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention
[0006] The purpose of the present disclosure is to provide a rate control method, a rate control device, an electronic device and a computer program product, thereby at least to a certain extent being able to improve the rate control effect and reduce the delay of the encoding process.
[0007] According to a first aspect of the present disclosure, a rate control method is provided, comprising:
[0008] Predicting the coding complexity of the frame to be coded according to the frame type of the frame to be coded and the coding complexity of multiple frames of the same type before the frame to be coded, wherein the frame to be coded includes the current frame to be coded and subsequent frames to be coded;
[0009] Acquire an initial rate quantization scale of the frame to be encoded, and obtain a rate prediction value of the frame to be encoded according to the encoding complexity of the frame to be encoded and the initial rate quantization scale;
[0010] Obtaining a predicted value of a total buffered bit rate after encoding all the frames to be encoded according to the bit rate predicted value of the frames to be encoded;
[0011] When the cached total bit rate prediction value is outside the bit rate overflow interval, adjusting the bit rate quantization scale of the current frame to be encoded according to the cached total bit rate prediction value, and updating the cached total bit rate prediction value according to the adjusted bit rate quantization scale;
[0012] When the cached total bit rate prediction value is within the bit rate overflow interval, the current frame to be encoded is encoded.
[0013] In an exemplary embodiment of the present disclosure, predicting the coding complexity of the frame to be coded according to the frame type of the frame to be coded and the coding complexity of multiple frames of the same type before the frame to be coded includes:
[0014] According to the frame type of the frame to be encoded and a preset sliding calculation window, the encoding complexity of multiple frames of the same type before the frame to be encoded and the number of the frames of the same type are obtained;
[0015] Obtaining cumulative coding complexity according to coding complexities of a plurality of frames of the same type before the frame to be coded and a preset attenuation coefficient;
[0016] Determining weight parameters of the frames to be encoded according to the number of the same type of frames and the encoding order of the frames to be encoded;
[0017] The predicted coding complexity of the frame to be encoded is obtained according to the accumulated coding complexity and the weight parameter.
[0018] In an exemplary embodiment of the present disclosure, the obtaining of the initial rate quantization scale of the frame to be encoded includes:
[0019] Acquire an initial quantization parameter of the current frame to be encoded, and obtain an initial rate quantization scale of the current frame to be encoded according to the initial quantization parameter of the current frame to be encoded;
[0020] Determining, according to the frame type of the current frame to be encoded and the frame type of the subsequent frame to be encoded, a quantization scale conversion ratio between the subsequent frame to be encoded and the current frame to be encoded;
[0021] The initial rate quantization scale of the subsequent frame to be encoded is obtained according to the initial rate quantization scale of the current frame to be encoded and the quantization scale conversion ratio.
[0022] In an exemplary embodiment of the present disclosure, obtaining a rate prediction value of the frame to be encoded according to the encoding complexity of the frame to be encoded and the initial rate quantization scale includes:
[0023] A code rate prediction value of the frame to be encoded is obtained according to the code rate prediction parameter, the encoding complexity of the frame to be encoded and the initial code rate quantization scale.
[0024] In an exemplary embodiment of the present disclosure, obtaining a predicted value of a cached total bit rate after encoding all the frames to be encoded according to the bit rate predicted value of the frame to be encoded includes:
[0025] Obtaining a total buffered bit rate corresponding to a previous frame of the current frame to be encoded and the number of frames to be encoded;
[0026] According to the total buffered bit rate corresponding to the previous frame, the number of the frames to be encoded and the bit rate prediction value of each of the frames to be encoded, a total buffered bit rate prediction value after encoding all the frames to be encoded is obtained.
[0027] In an exemplary embodiment of the present disclosure, the method further includes:
[0028] Get the bitrate overflow threshold and bitrate underflow threshold;
[0029] An upper limit value of the code rate overflow interval is determined according to the code rate overflow threshold and the cache size, and a lower limit value of the code rate overflow interval is determined according to the code rate underflow threshold and the cache size.
[0030] In an exemplary embodiment of the present disclosure, obtaining the bit rate underflow threshold includes:
[0031] The bit rate underflow threshold is determined according to the distance between the current frame to be encoded and the previous key frame, and a preset key frame interval.
[0032] In an exemplary embodiment of the present disclosure, the adjusting the rate quantization scale of the current frame to be encoded according to the cached total rate prediction value includes:
[0033] If the cached total bit rate prediction value is greater than the upper limit of the bit rate overflow interval, reducing the bit rate quantization scale of the current frame to be encoded according to a preset adjustment ratio;
[0034] If the cached total bit rate prediction value is less than the lower limit of the bit rate overflow interval, the bit rate quantization scale of the current frame to be encoded is enlarged according to a preset adjustment ratio.
[0035] In an exemplary embodiment of the present disclosure, when the predicted value of the total buffered bit rate is within the bit rate overflow interval, the method further includes:
[0036] The rate prediction parameters used in calculating the rate prediction value are updated according to the actual rate of the frame to be encoded and the rate quantization scale, as well as the actual encoding complexity of the frame to be encoded.
[0037] According to a second aspect of the present disclosure, a rate control device is provided, including:
[0038] A complexity prediction module is configured to predict the coding complexity of the frame to be coded according to the frame type of the frame to be coded and the coding complexities of multiple frames of the same type before the frame to be coded, wherein the frame to be coded includes the current frame to be coded and subsequent frames to be coded;
[0039] A rate prediction module is configured to obtain an initial rate quantization scale of the frame to be encoded, and obtain a rate prediction value of the frame to be encoded according to the encoding complexity of the frame to be encoded and the initial rate quantization scale;
[0040] A total bit rate prediction module is configured to execute, based on the bit rate prediction value of the frame to be encoded, to obtain a cached total bit rate prediction value after encoding all the frames to be encoded;
[0041] a quantization scale adjustment module, configured to adjust the rate quantization scale of the current frame to be encoded according to the cached total rate prediction value when the cached total rate prediction value is outside the rate overflow interval, and update the cached total rate prediction value according to the adjusted rate quantization scale;
[0042] The current frame encoding module is configured to encode the current frame to be encoded when the cached total bit rate prediction value is within the bit rate overflow interval.
[0043] In an exemplary embodiment of the present disclosure, the complexity prediction module includes:
[0044] A same type complexity acquisition unit is configured to acquire, according to the frame type of the frame to be encoded and a preset sliding calculation window, the encoding complexity of a plurality of frames of the same type before the frame to be encoded and the number of the frames of the same type;
[0045] A cumulative coding complexity determining unit, configured to obtain a cumulative coding complexity according to coding complexities of a plurality of frames of the same type before the frame to be encoded and a preset attenuation coefficient;
[0046] A weight parameter determination unit, configured to determine the weight parameter of the frame to be encoded according to the number of the same type of frames and the encoding order of the frame to be encoded;
[0047] The coding complexity prediction unit is configured to obtain the predicted coding complexity of the to-be-coded frame according to the accumulated coding complexity and the weight parameter.
[0048] In an exemplary embodiment of the present disclosure, the bit rate prediction module includes:
[0049] A current frame quantization scale determining unit is configured to obtain an initial quantization parameter of the current frame to be encoded, and obtain an initial rate quantization scale of the current frame to be encoded according to the initial quantization parameter of the current frame to be encoded;
[0050] a quantization scale conversion ratio determining unit, configured to determine a quantization scale conversion ratio between the subsequent frame to be encoded and the current frame to be encoded according to the frame type of the current frame to be encoded and the frame type of the subsequent frame to be encoded;
[0051] The subsequent frame quantization scale determining unit is configured to obtain the initial rate quantization scale of the subsequent frame to be encoded according to the initial rate quantization scale of the current frame to be encoded and the quantization scale conversion ratio.
[0052] In an exemplary embodiment of the present disclosure, the bit rate prediction module further includes:
[0053] The rate prediction value determining unit is configured to obtain the rate prediction value of the frame to be encoded according to the rate prediction parameter, the encoding complexity of the frame to be encoded and the initial rate quantization scale.
[0054] In an exemplary embodiment of the present disclosure, the total bit rate prediction module includes:
[0055] A previous cache total bit rate determination unit, configured to execute acquisition of the cache total bit rate corresponding to the previous frame of the current frame to be encoded and the number of the frames to be encoded;
[0056] The cache total bit rate prediction value determination unit is configured to execute, according to the cache total bit rate corresponding to the previous frame, the number of the frames to be encoded and the bit rate prediction value of each of the frames to be encoded, to obtain the cache total bit rate prediction value after encoding all the frames to be encoded.
[0057] In an exemplary embodiment of the present disclosure, the bit rate control device further includes a bit rate overflow interval determination module, and the bit rate overflow interval determination module includes:
[0058] A bit rate overflow threshold acquisition unit is configured to execute acquisition of a bit rate overflow threshold and a bit rate underflow threshold;
[0059] The interval upper and lower limit determination unit is configured to determine the upper limit value of the code rate overflow interval according to the code rate overflow threshold and the cache size, and determine the lower limit value of the code rate overflow interval according to the code rate underflow threshold and the cache size.
[0060] In an exemplary embodiment of the present disclosure, the bit rate overflow threshold acquisition unit includes:
[0061] The bit rate underflow threshold determination unit is configured to determine the bit rate underflow threshold according to the distance between the current frame to be encoded and the previous key frame, and a preset key frame interval.
[0062] In an exemplary embodiment of the present disclosure, the quantization scale adjustment module includes:
[0063] a quantization scale reduction unit, configured to reduce the rate quantization scale of the current frame to be encoded according to a preset adjustment ratio if the cached total rate prediction value is greater than the upper limit of the rate overflow interval;
[0064] The quantization scale enlarging unit is configured to enlarge the rate quantization scale of the current frame to be encoded according to a preset adjustment ratio if the cached total rate prediction value is less than the lower limit of the rate overflow interval.
[0065] In an exemplary embodiment of the present disclosure, the rate control device also includes a rate prediction parameter updating module, which is configured to update the rate prediction parameters when calculating the rate prediction value according to the actual rate of the frame to be encoded and the rate quantization scale, as well as the actual encoding complexity of the frame to be encoded.
[0066] According to a third aspect of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement any one of the above-mentioned bit rate control methods.
[0067] According to a fourth aspect of the present disclosure, a computer program product is provided, including a computer program, wherein when the computer program is executed by a processor, the bit rate control method described in any one of the above is implemented.
[0068] The exemplary embodiments of the present disclosure may have the following beneficial effects:
[0069] In the code rate control method of the exemplary implementation of the present disclosure, the coding complexity of the frame to be encoded is predicted by the coding complexity of multiple frames of the same type before the frame to be encoded, and the code rate prediction value of the frame to be encoded is obtained according to the coding complexity of the frame to be encoded and the initial code rate quantization scale, and on this basis, the cache total code rate prediction value after encoding all the frames to be encoded is obtained. Then, by judging the relationship between the cache total code rate prediction value and the code rate overflow interval, when the cache total code rate prediction value is outside the code rate overflow interval, the code rate quantization scale of the current frame to be encoded is adjusted according to the cache total code rate prediction value, and the cache total code rate prediction value is updated according to the adjusted code rate quantization scale; when the cache total code rate prediction value is within the code rate overflow interval, the current frame to be encoded is encoded. The rate control method in the example implementation of the present disclosure is aimed at the low-latency video transmission scenario. On the one hand, by utilizing the high temporal correlation of video content in the real-time transmission scenario, the coding complexity of multiple frames of the same type before the frame to be encoded is counted according to the frame type to predict the coding complexity of the frame to be encoded. Without introducing additional coding delay, more frame information of the frames to be encoded can be obtained, so that the prediction of the total cache bit rate is more accurate. On the other hand, by calculating the predicted value of the total cache bit rate after encoding all the frames to be encoded, and adjusting the bit rate quantization scale of the current frame to be encoded based on the predicted value of the total cache bit rate, the adjusted bit rate quantization scale is more reasonable, thereby further improving the rate control effect.
[0070] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0071] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification are used to explain the principles of the present disclosure. Obviously, the accompanying drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without creative work.
[0072] Figure 1 A schematic diagram of a video cache checker in a specific embodiment of the present disclosure is shown;
[0073] Figure 2 A schematic diagram showing cache bit rate control of a video cache checker in a specific implementation manner of the present disclosure is shown;
[0074] Figure 3 A schematic diagram showing a flow chart of a rate control method according to an exemplary embodiment of the present disclosure;
[0075] Figure 4A schematic diagram showing a flow chart of predicting the coding complexity of a frame to be coded according to an exemplary embodiment of the present disclosure;
[0076] Figure 5 A schematic diagram of a process of obtaining an initial rate quantization scale of a frame to be encoded according to an exemplary embodiment of the present disclosure is shown;
[0077] Figure 6 A schematic flow chart of a rate control method based on pre-analysis in a related embodiment of the present disclosure is shown;
[0078] Figure 7 A schematic flow chart of a rate control method in a specific implementation of the present disclosure is shown;
[0079] Figure 8 A block diagram showing a rate control device according to an exemplary embodiment of the present disclosure is shown;
[0080] Fig. 9 A schematic diagram of the structure of a computer system suitable for implementing the electronic device of the embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0081] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.
[0082] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein.
[0083] The following example embodiments can be implemented in a variety of forms and should not be construed as being limited to the examples set forth herein; on the contrary, these embodiments are provided so that the present disclosure will be more comprehensive and complete, and the concepts of the example embodiments are fully conveyed to those skilled in the art. The described features, structures, or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present disclosure. However, those skilled in the art will appreciate that the technical solutions of the present disclosure may be practiced while omitting one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known technical solutions are not shown or described in detail to avoid obscuring various aspects of the present disclosure.
[0084] In addition, the accompanying drawings are only schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the figures represent the same or similar parts, and their repeated description will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and / or processor devices and / or microcontroller devices.
[0085] In the process of video transmission, in order to reduce the fluctuation of bit rate, a virtual video buffer can be established at the encoding end to simulate a series of operations from receiving bit stream to decoding at the decoding end, so as to smooth the output bit rate of the encoding end. Figure 1 As shown, the module is called VBV (Video Buffer Verifier).
[0086] The bit rate control based on VBV can be summarized as follows: Figure 2 The leaky bucket model shown in the figure. Since the simulation is the process of the decoding end, the input bit rate of the VBV cache is constant, that is, the maximum bit rate set by the encoding end, and the output is the actual encoding bit rate of each frame. In order to ensure the stable fluctuation of the bit rate, the number of bits in the VBV cache can be kept within a reasonable range, that is, between the upper and lower thresholds, to avoid cache overflow and underflow.
[0087] In some related embodiments, the complexity of the current frame i to be encoded and the subsequent N frames to be encoded can be obtained by pre-analysis to estimate the fullness of the VBV buffer after all the N+1 frames are encoded, that is, the total number of bits in the VBV buffer. If the fullness of the buffer exceeds the overflow warning line, the QP (Quantization Parameters) of the current frame needs to be lowered. On the contrary, if the fullness of the buffer is lower than the underflow warning line, the QP of the current frame is increased.
[0088] This VBV code control algorithm based on pre-analysis is more effective for video transmission scenarios with low latency requirements. However, for low-latency application scenarios, pre-analysis will introduce additional encoding delay. Therefore, it is necessary to accurately estimate the number of encoding bits of subsequent frames to be encoded under the condition of delay constraints.
[0089] Based on the above problems, this exemplary embodiment first provides a rate control method. Figure 3 As shown, the above-mentioned rate control method may include the following steps:
[0090] Step S310: predict the coding complexity of the frame to be coded according to the frame type of the frame to be coded and the coding complexities of multiple frames of the same type before the frame to be coded.
[0091] The frames to be encoded include the current frame to be encoded and the subsequent frames to be encoded.
[0092] Step S320: Acquire an initial rate quantization scale of the frame to be encoded, and obtain a rate prediction value of the frame to be encoded according to the encoding complexity of the frame to be encoded and the initial rate quantization scale.
[0093] Step S330: According to the bit rate prediction value of the frame to be encoded, a buffer total bit rate prediction value after encoding all the frames to be encoded is obtained.
[0094] Step S340: When the cached total bit rate prediction value is outside the bit rate overflow interval, the bit rate quantization scale of the current frame to be encoded is adjusted according to the cached total bit rate prediction value, and the cached total bit rate prediction value is updated according to the adjusted bit rate quantization scale.
[0095] Step S350: When the cached total bit rate prediction value is within the bit rate overflow interval, encode the current frame to be encoded.
[0096] The rate control method in the example implementation of the present disclosure is aimed at the low-latency video transmission scenario. On the one hand, by utilizing the high temporal correlation of video content in the real-time transmission scenario, the coding complexity of multiple frames of the same type before the frame to be encoded is counted according to the frame type to predict the coding complexity of the frame to be encoded. Without introducing additional coding delay, more frame information of the frames to be encoded can be obtained, so that the prediction of the total cache bit rate is more accurate. On the other hand, by calculating the predicted value of the total cache bit rate after encoding all the frames to be encoded, and adjusting the bit rate quantization scale of the current frame to be encoded based on the predicted value of the total cache bit rate, the adjusted bit rate quantization scale is more reasonable, thereby further improving the rate control effect.
[0097] Next, combine Figures 4 to 5 The above steps of this exemplary embodiment are described in more detail.
[0098] In step S310, the coding complexity of the frame to be coded is predicted according to the frame type of the frame to be coded and the coding complexities of multiple frames of the same type before the frame to be coded.
[0099] The frames to be encoded include the current frame to be encoded and the subsequent frames to be encoded.
[0100] In this example implementation, the frame types of the frames to be encoded may include three types: I, P, and B. The I frame is an intra-frame coded frame, i.e., a key frame, which can be understood as the complete retention of this frame. During decoding, the complete image can be reconstructed using only the data of the I frame. The I frame is a reference frame for the P frame and the B frame. The P frame is a forward predictive coded frame. The P frame represents the difference between this frame and a previous key frame (or P frame). During decoding, the previously cached picture needs to be superimposed on the difference defined by this frame to generate the final picture. The B frame is a bidirectional predictive interpolation coded frame, which records the difference between this frame and the previous and next frames. When decoding the B frame, the final picture can be obtained by superimposing the previous and next pictures with the data of this frame. In real-time transmission scenarios, a fixed frame type structure is often used, i.e., the arrangement order of the frame types is determined, so the frame types of subsequent frames can be directly obtained.
[0101] The frames before the current frame to be encoded are already encoded frames. For the encoded frames, the source image can be downsampled by 1 / 2 and divided into small encoding blocks, for example, it can be divided into multiple 8x8 encoding blocks, and then the encoding complexity is calculated in units of encoding blocks. Specifically, the intra-frame prediction loss (cost intra ), and inter-frame prediction loss (cost inter ), are measured using the SATD (Sum of Absolute Transformed Difference) metric. The coding complexity of the coded frame can be obtained by summing the complexity of all m×n 8x8 coding blocks. Therefore, the coding complexity of the coded frame can be expressed as:
[0102]
[0103] In this example implementation, Figure 4 As shown, according to the frame type of the frame to be encoded and the encoding complexity of multiple frames of the same type before the frame to be encoded, the encoding complexity of the frame to be encoded is predicted, which may specifically include the following steps:
[0104] Step S410: According to the frame type of the frame to be encoded and a preset sliding calculation window, the encoding complexity of multiple frames of the same type before the frame to be encoded and the number of frames of the same type are obtained.
[0105] Taking advantage of the fact that video content in application scenarios such as live broadcast is relatively static and changes relatively smoothly, a complexity sliding window can be simulated for the current frame and subsequent frames. The encoding complexity of multiple frames of the same type before the frame to be encoded, as well as the number of frames of the same type, can be counted according to the frame type.
[0106] Step S420: Obtain cumulative coding complexity according to coding complexities of multiple frames of the same type before the frame to be coded and a preset attenuation coefficient.
[0107] Step S430: Determine the weight parameters of the frames to be encoded according to the number of frames of the same type and the encoding order of the frames to be encoded.
[0108] After the encoder encodes each frame, the encoding complexity of each frame of the same type in the complexity sliding window can be accumulated using the exponential smoothing method according to the frame type. The specific calculation method is as follows:
[0109]
[0110] in, is the cumulative coding complexity of the same type of frames, is the cumulative value of the number of frames of the same type, which can be used as the weight parameter of the frame to be encoded, indicating that the earlier the frame, the greater the weight. type is the frame type corresponding to the i-th frame, including three frame types: I, P, and B. 0.95 is the attenuation coefficient of the exponential smoothing method.
[0111] Step S440: Obtain the predicted coding complexity of the frame to be encoded according to the accumulated coding complexity and the weight parameter.
[0112] According to the cumulative coding complexity With weight parameters The ratio of can be used to obtain the predicted coding complexity of the frame to be encoded.
[0113] By calculating the cumulative coding complexity of multiple frames of the same type before the frame to be coded using the exponential smoothing method and then taking the weighted average, more frame information can be obtained to improve the accuracy of subsequent bit rate prediction and bit rate control effect.
[0114] When obtaining the average cumulative complexity of different frame types, other weighted average methods besides the exponential smoothing method may also be used, which is not specifically limited in this example implementation.
[0115] In step S320, an initial rate quantization scale of the frame to be encoded is obtained, and a rate prediction value of the frame to be encoded is obtained according to the encoding complexity of the frame to be encoded and the initial rate quantization scale.
[0116] The quantization parameter (QP) indicates the compression of the image space details and determines the image quality to a certain extent. The quantization scale (Qscale) is obtained by converting the quantization parameter and can be easily calculated.
[0117] In this example implementation, Figure 5 As shown, obtaining the initial rate quantization scale of the frame to be encoded may specifically include the following steps:
[0118] Step S510: Acquire an initial quantization parameter of the current frame to be encoded, and obtain an initial rate quantization scale of the current frame to be encoded according to the initial quantization parameter of the current frame to be encoded.
[0119] The initial quantization parameter of the current frame to be encoded can be obtained according to the preset target bit rate or CRF (Constant rate factor, constant quality factor) value. The conversion formula between the quantization parameter QP and the quantization scale Qscale is as follows:
[0120] Qscale=0.85×2 (QP-12) / 6
[0121] According to the above conversion formula, the initial quantization parameter of the current frame to be encoded can be converted into a corresponding initial code rate quantization scale.
[0122] Step S520: Determine a quantization scale conversion ratio between the subsequent frame to be encoded and the current frame to be encoded according to the frame type of the current frame to be encoded and the frame type of the subsequent frame to be encoded.
[0123] Step S530: Obtain an initial rate quantization scale of a subsequent frame to be encoded according to the initial rate quantization scale of the current frame to be encoded and the quantization scale conversion ratio.
[0124] The Qscale of the subsequent frames can be obtained based on the Qscale of the current frame and the conversion ratio of Qscale between different frame types. The conversion formula is as follows:
[0125] Qsclae I =Qsclae P / IPratio
[0126] Qsclae B =Qsclae P *PBratio
[0127] Among them, Ipratio is the quantization scale conversion ratio between I frame and P frame, PBratio is the quantization scale conversion ratio between P frame and B frame, IPratio and PBratio can be set by the user, for example, they can be set to the default values of 1.40 and 1.30. Through the quantization scale conversion ratio between different types of frames, the initial bit rate quantization scale of the subsequent frame to be encoded can be quickly obtained.
[0128] In this example implementation, the rate prediction value of the frame to be encoded may be obtained according to the rate prediction parameter, the encoding complexity of the frame to be encoded, and the initial rate quantization scale.
[0129] Since real-time transmission scenarios are mostly application scenarios where video content changes slowly, such as live video and remote conferencing, the frame structure of the code is relatively fixed, and the variation range of the coding complexity is also small. Based on this feature, the fixed frame structure and cumulative coding complexity can be used to more accurately estimate the bit rate prediction value of the subsequent frames to be encoded. The calculation formula for the bit rate prediction value is as follows:
[0130]
[0131] The coefficient coeff and the offset value offset are rate prediction parameters used when calculating the rate prediction value.
[0132] In step S330, a predicted value of the total buffered bit rate after encoding all frames to be encoded is obtained according to the bit rate prediction value of the frame to be encoded.
[0133] In this example implementation, the total cache bit rate corresponding to the previous frame of the current frame to be encoded and the number of frames to be encoded can be obtained, and based on the total cache bit rate corresponding to the previous frame, the number of frames to be encoded and the bit rate prediction value of each frame to be encoded, the total cache bit rate prediction value after encoding all frames to be encoded is obtained.
[0134] After obtaining the coding complexity of the frames to be coded from the i-th frame to the N-th frame in the entire sliding window, the cache fullness of the VBV cache after encoding the N+1 frame can be estimated, that is, the total cache bit rate prediction value:
[0135]
[0136] Among them, VBVMaxRate is the maximum bit rate of VBV, and FPS is the frame rate.
[0137] Based on the total buffer rate prediction value, it can be determined whether the buffer fullness after encoding N+1 frames exceeds the overflow warning value of the VBV buffer, thereby adjusting the quantization scale used in the bit rate prediction.
[0138] In step S340, when the cached total bit rate prediction value is outside the bit rate overflow interval, the bit rate quantization scale of the current frame to be encoded is adjusted according to the cached total bit rate prediction value, and the cached total bit rate prediction value is updated according to the adjusted bit rate quantization scale.
[0139] After obtaining the cache total bit rate prediction value after encoding N+1 frames, the relationship between the cache total bit rate prediction value and the bit rate overflow interval of VBV can be determined, that is, whether the cache total bit rate prediction value is higher than the upper limit of the bit rate overflow interval, or lower than the lower limit of the bit rate overflow interval.
[0140] In this example implementation, a rate overflow threshold and a rate underflow threshold may be obtained, and an upper limit of a rate overflow interval may be determined based on the rate overflow threshold and the cache size, and a lower limit of a rate overflow interval may be determined based on the rate underflow threshold and the cache size.
[0141] Make the estimated total cache bitrate prediction value between the upper and lower limits of the VBV bitrate overflow interval. Otherwise, you need to adjust the Qscale of the current frame. The adjustment method is as follows:
[0142]
[0143] Among them, BufferSize is the cache size of VBV, Th underflow And Th overflow are the underflow and overflow thresholds, which can be fixed values, such as 0.5 and 0.8 respectively. In addition, the code rate underflow threshold can also be adjusted according to the frame type of the subsequent frame.
[0144] In this example implementation, the bit rate underflow threshold can be determined based on the distance between the current frame to be encoded and the previous key frame, and the preset key frame interval. The specific adjustment method is as follows:
[0145] Th underflow =(1-d I / P IDR )*BufferSize
[0146] Among them, d I is the distance between the current frame and the previous key frame, that is, the I frame, P IDR The pre-set I frame interval. Real-time transmission scenes are relatively static, and the correlation between frames is high. Improving the quality of I frames helps improve encoding performance. By linking the underflow threshold of the VBV cache with the distance between the current frame and the next I frame, if an I frame is to be encoded immediately after the current frame, the underflow threshold is increased to reserve space for the I frame. After the I frame is encoded, the underflow threshold is lowered to allow subsequent frames to occupy more cache space, thereby improving the quality of subsequent frames.
[0147] In this example implementation, by designing an adaptive adjustment algorithm for the VBV underflow threshold, the VBV underflow threshold is dynamically adjusted according to the frame type of the frame to be encoded, so that a more reasonable bit rate allocation can be performed, thereby improving the encoding efficiency.
[0148] When adaptively deciding the VBV underflow threshold, in addition to considering the position of subsequent I frames, the complexity of the previous frames in the sliding window can also be used to weight the complexity of subsequent frames to adjust the VBV underflow threshold, which is not specifically limited in this example implementation.
[0149] In this example implementation, when adjusting the rate quantization scale of the current frame to be encoded, if the cached total rate prediction value is greater than the upper limit value of the rate overflow interval, the rate quantization scale of the current frame to be encoded is reduced according to a preset adjustment ratio; if the cached total rate prediction value is less than the lower limit value of the rate overflow interval, the rate quantization scale of the current frame to be encoded is enlarged according to the preset adjustment ratio.
[0150] If the current cache total bit rate prediction value meets the requirement, the loop is exited. Otherwise, the Qscale value can be adjusted according to the Qscale adjustment method above to obtain Restart the next round of bit rate prediction and Qscale adjustment to improve the accuracy of bit rate prediction.
[0151] In step S350, when the cached total bit rate prediction value is within the bit rate overflow interval, the current frame to be encoded is encoded.
[0152] When the cached total bit rate prediction value is within the bit rate overflow interval, the current frame to be encoded can be encoded, and the actual bit rate of the current frame to be encoded can be output.
[0153] In this example implementation, after encoding the current frame to be encoded, the rate prediction parameters used in calculating the rate prediction value may be updated according to the actual rate and rate quantization scale of the frame to be encoded and the actual encoding complexity of the frame to be encoded.
[0154] After encoding the i-th frame, the bit rate prediction parameters need to be updated according to the Qscale used in the actual encoding and the number of bits obtained. The specific updating method is as follows;
[0155]
[0156] in, is the actual bit rate quantization scale, After updating the bit rate prediction parameters, the accuracy of bit rate prediction can be further improved.
[0157] Figure 6 A schematic flow chart of a rate control method based on pre-analysis in a related embodiment of the present disclosure is shown, and the specific steps of the flow chart are as follows:
[0158] Step S610: Calculate the quantization scale Qscale of the i-th frame.
[0159] The initial Qscale of the current frame to be encoded is obtained according to the initial QP of the current frame to be encoded, and then the initial Qscale of the subsequent frame to be encoded is obtained according to the quantization scale conversion ratio between different frame types.
[0160] Step S620: Calculate the current cache fullness.
[0161] Step S630: Calculate the bit rates of the i~i+N frames of images.
[0162] The pre-analysis module analyzes the coding complexity and frame type of the current frame and the following N frames. The coding complexity prediction method is as follows:
[0163]
[0164] Step S640: Determine whether the total bit rate is within the upper and lower limit range.
[0165] The sum of the bit rates of the i-i+N frames can be predicted by the coding complexity and Qscale of the current frame and subsequent frames. If the total bit rate is greater than the upper limit of the interval, proceed to step S650; if the total bit rate is less than the lower limit of the interval, proceed to step S660. If the total bit rate is within the upper and lower limits, proceed to step S670.
[0166] Step S650: Qscale down by 1%.
[0167] Step S660. Qscale is enlarged by 1%.
[0168] Step S670: Encode the i-th frame.
[0169] Encode the current frame to be encoded and output the actual bit rate of the current frame to be encoded.
[0170] Step S680: Update prediction parameters.
[0171] Update the prediction parameters coeff and offset of the bit rate prediction value.
[0172] The pre-analysis-based rate control method in the above-mentioned related implementation method will introduce additional coding delay and is not very suitable for real-time video transmission with delay constraints. In addition, the upper and lower overflow thresholds of the rate overflow interval are fixed values, and no corresponding adaptive adjustment is made according to the subsequent frame type and complexity.
[0173] like Figure 7 The figure is a flow chart of a bit rate control method in a specific embodiment of the present disclosure, which is an example of the present embodiment. Figures 3 to 5 The specific steps of the flowchart are as follows:
[0174] Step S710: Calculate the quantization scale Qscale of the i-th frame.
[0175] The initial Qscale of the current frame to be encoded is obtained according to the initial QP of the current frame to be encoded, and then the initial Qscale of the subsequent frame to be encoded is obtained according to the quantization scale conversion ratio between different frame types.
[0176] Step S720: Calculate the current cache fullness.
[0177] Step S730: Predict the bit rates of i~i+N frames of images according to the cumulative coding complexity.
[0178] According to the frame type, the coding complexity of each frame of the same type in the complexity sliding window is accumulated using the exponential smoothing method:
[0179]
[0180] Using the fixed frame structure and cumulative coding complexity, the bit rate prediction value of the frame to be encoded is estimated:
[0181]
[0182] Then estimate the total bitrate prediction of the VBV cache after encoding the N+1 frames:
[0183]
[0184] Step S740: Determine whether the total bit rate is within the upper and lower limit range.
[0185] If the total bit rate is greater than the upper limit of the interval, proceed to step S750; if the total bit rate is less than the lower limit of the interval, proceed to step S760. If the total bit rate is within the upper and lower limit interval, proceed to step S770. The lower limit of the bit rate overflow interval can be adjusted adaptively.
[0186] Step S750. Qscale is reduced by 1%.
[0187] Step S760. Qscale is enlarged by 1%.
[0188] Step S770: Encode the i-th frame.
[0189] Encode the current frame to be encoded and output the actual bit rate of the current frame to be encoded.
[0190] Step S780: Update prediction parameters.
[0191] Update the prediction parameters coeff and offset of the bit rate prediction value.
[0192] Step S790: Cumulative coding complexity update.
[0193] The accumulated coding complexity corresponding to the next frame to be encoded is updated, and the next frame to be encoded is predicted.
[0194] The rate control method in this example implementation can obtain more frame information of the frames to be encoded for low-latency video transmission scenarios without introducing additional encoding delays, thereby making the prediction of the total cache bit rate more accurate and improving the rate control effect. At the same time, by adaptively adjusting the VBV underflow threshold, a more reasonable rate allocation can be performed, thereby improving the encoding efficiency.
[0195] In actual tests, the above bit rate control method can be used to obtain BD-rate ( rate, the bit rate difference between the two encoding algorithms under the same quality evaluation index, negative numbers indicate bit rate savings) PSNR (Peak signal-to-noise ratio) is about -2.56%, and BD-rate SSIM (Structural Similarity) is about -3.969%.
[0196] It should be noted that although the steps of the method in the present disclosure are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.
[0197] Furthermore, the present disclosure also provides a bit rate control device. Figure 8 As shown, the bit rate control device may include a complexity prediction module 810, a bit rate prediction module 820, a total bit rate prediction module 830, a quantization scale adjustment module 840 and a current frame encoding module 850. Among them:
[0198] The complexity prediction module 810 is configured to predict the coding complexity of the frame to be coded according to the frame type of the frame to be coded and the coding complexity of multiple frames of the same type before the frame to be coded, wherein the frame to be coded includes the current frame to be coded and subsequent frames to be coded;
[0199] The rate prediction module 820 is configured to obtain an initial rate quantization scale of the frame to be encoded, and obtain a rate prediction value of the frame to be encoded according to the encoding complexity of the frame to be encoded and the initial rate quantization scale;
[0200] The total bit rate prediction module 830 is configured to obtain a buffered total bit rate prediction value after encoding all frames to be encoded according to the bit rate prediction value of the frame to be encoded;
[0201] The quantization scale adjustment module 840 is configured to adjust the rate quantization scale of the current frame to be encoded according to the cached total rate prediction value when the cached total rate prediction value is outside the rate overflow interval, and update the cached total rate prediction value according to the adjusted rate quantization scale;
[0202] The current frame encoding module 850 is configured to encode the current frame to be encoded when the cached total bit rate prediction value is within the bit rate overflow interval.
[0203] In some exemplary embodiments of the present disclosure, the complexity prediction module 810 may include a same type complexity acquisition unit, a cumulative coding complexity determination unit, a weight parameter determination unit, and a coding complexity prediction unit.
[0204] The same type complexity acquisition unit is configured to acquire the coding complexity of multiple frames of the same type before the frame to be encoded and the number of frames of the same type according to the frame type of the frame to be encoded and the preset sliding calculation window;
[0205] The cumulative coding complexity determination unit is configured to obtain the cumulative coding complexity according to the coding complexities of multiple frames of the same type before the frame to be encoded and a preset attenuation coefficient;
[0206] The weight parameter determination unit is configured to determine the weight parameter of the frame to be encoded according to the number of frames of the same type and the encoding order of the frames to be encoded;
[0207] The coding complexity prediction unit is configured to obtain the predicted coding complexity of the to-be-coded frame according to the accumulated coding complexity and the weight parameter.
[0208] In some exemplary embodiments of the present disclosure, the code rate prediction module 820 may include a current frame quantization scale determination unit, a quantization scale conversion ratio determination unit, and a subsequent frame quantization scale determination unit.
[0209] The current frame quantization scale determination unit is configured to obtain an initial quantization parameter of the current frame to be encoded, and obtain an initial rate quantization scale of the current frame to be encoded according to the initial quantization parameter of the current frame to be encoded;
[0210] The quantization scale conversion ratio determination unit is configured to determine the quantization scale conversion ratio between the subsequent frame to be encoded and the current frame to be encoded according to the frame type of the current frame to be encoded and the frame type of the subsequent frame to be encoded;
[0211] The subsequent frame quantization scale determining unit is configured to obtain an initial rate quantization scale of a subsequent frame to be encoded according to the initial rate quantization scale of the current frame to be encoded and the quantization scale conversion ratio.
[0212] In some exemplary embodiments of the present disclosure, the rate prediction module 820 may further include a rate prediction value determination unit configured to obtain a rate prediction value of the frame to be encoded based on the rate prediction parameters, the encoding complexity of the frame to be encoded, and the initial rate quantization scale.
[0213] In some exemplary embodiments of the present disclosure, the total bit rate prediction module 830 may include a previous cache total bit rate determination unit and a cache total bit rate prediction value determination unit.
[0214] The previous cache total bit rate determination unit is configured to obtain the cache total bit rate corresponding to the previous frame of the current frame to be encoded and the number of frames to be encoded;
[0215] The cache total bit rate prediction value determination unit is configured to obtain the cache total bit rate prediction value after encoding all frames to be encoded according to the cache total bit rate corresponding to the previous frame, the number of frames to be encoded and the bit rate prediction value of each frame to be encoded.
[0216] In some exemplary embodiments of the present disclosure, a rate control device provided by the present disclosure may further include a rate overflow interval determination module, which may include a rate overflow threshold acquisition unit and an interval upper and lower limit determination unit.
[0217] The bit rate overflow threshold acquisition unit is configured to acquire a bit rate overflow threshold and a bit rate underflow threshold;
[0218] The interval upper and lower limit determination unit is configured to determine the upper limit value of the rate overflow interval according to the rate overflow threshold and the buffer size, and determine the lower limit value of the rate overflow interval according to the rate underflow threshold and the buffer size.
[0219] In some exemplary embodiments of the present disclosure, the rate overflow threshold acquisition unit may include a rate underflow threshold determination unit, which is configured to determine the rate underflow threshold according to the distance between the current frame to be encoded and the previous key frame, and a preset key frame interval.
[0220] In some exemplary embodiments of the present disclosure, the quantization scale adjustment module 840 may include a quantization scale reduction unit and a quantization scale enlargement unit.
[0221] The quantization scale reduction unit is configured to reduce the rate quantization scale of the current frame to be encoded according to a preset adjustment ratio if the cached total rate prediction value is greater than the upper limit value of the rate overflow interval;
[0222] The quantization scale enlargement unit is configured to enlarge the rate quantization scale of the current frame to be encoded according to a preset adjustment ratio if the cached total rate prediction value is less than the lower limit of the rate overflow interval.
[0223] In some exemplary embodiments of the present disclosure, a rate control device provided by the present disclosure may also include a rate prediction parameter updating module, which is configured to update the rate prediction parameters when calculating the rate prediction value according to the actual rate and rate quantization scale of the frame to be encoded, and the actual encoding complexity of the frame to be encoded.
[0224] The specific details of each module / unit in the above-mentioned bit rate control device have been described in detail in the corresponding method embodiment part, and will not be repeated here.
[0225] Fig. 9 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present invention is shown.
[0226] It should be noted that Fig. 9 The computer system 900 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0227] like Fig. 9 As shown, the computer system 900 includes a central processing unit (CPU) 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage part 908 into a random access memory (RAM) 903. In the RAM 903, various programs and data required for system operation are also stored. The CPU 901, the ROM 902, and the RAM 903 are connected to each other via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.
[0228] The following components are connected to the I / O interface 905: an input section 906 including a keyboard, a mouse, etc.; an output section 907 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 908 including a hard disk, etc.; and a communication section 909 including a network interface card such as a LAN card, a modem, etc. The communication section 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to the I / O interface 905 as needed. A removable medium 911, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 910 as needed, so that a computer program read therefrom is installed into the storage section 908 as needed.
[0229] In particular, according to an embodiment of the present invention, the process described below with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present invention includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication section 909, and / or installed from a removable medium 911. When the computer program is executed by a central processing unit (CPU) 901, various functions defined in the system of the present application are executed.
[0230] The exemplary embodiment of the present disclosure also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the information prompt method for reward redemption is implemented.
[0231] In one embodiment, the computer program product may be a tangible product containing a computer program, such as a computer-readable storage medium storing a computer program. The readable storage medium may be a storage medium based on electrical, magnetic, optical, electromagnetic, infrared, or other signals, including but not limited to: random access memory (RAM), read-only memory (ROM), magnetic tape, floppy disk, flash memory (Flash), mechanical hard disk (HDD), solid-state drive (SSD), and the like. Exemplarily, the computer program product may be implemented as a non-volatile storage medium storing a computer program, such as a read-only memory, a NAND flash memory, and the like.
[0232] In one embodiment, the computer program product may be an intangible product including a computer program. Exemplarily, the computer program product may be implemented as a virtual digital product, such as a digital file storing an executable file, an installation package, etc. of the computer program.
[0233] The code of the computer program can be written in one or more programming languages. Programming languages such as C language, Java, C++, etc. The program code can be executed entirely on the user computing device, or partially on the user computing device, or as a separate software package, or partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, such as a local area network (LAN), a wide area network (WAN), etc., or can be connected to an external computing device (e.g., an Internet connection provided by an operator).
[0234] The computer program may be carried or transmitted via electrical, magnetic, optical, electromagnetic, infrared, or other signals. The electronic device may convert the signal carrying the computer program into a digital signal, thereby running the computer program. When the computer program is run on the electronic device, its code is used to enable the electronic device to execute (more specifically, the processor of the electronic device may execute) the method steps of various exemplary embodiments of the present disclosure, such as the information prompt method for reward redemption described above.
[0235] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0236] It should be noted that, although several modules of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules described above can be concretized in one module. Conversely, the features and functions of one module described above can be further divided into multiple modules to be concretized.
[0237] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary technical means in the art that are not disclosed in the present disclosure.
[0238] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A rate control method, characterized in that: include: Predicting the coding complexity of the frame to be coded according to the frame type of the frame to be coded and the coding complexity of multiple frames of the same type before the frame to be coded, wherein the frame to be coded includes the current frame to be coded and subsequent frames to be coded; Acquire an initial rate quantization scale of the frame to be encoded, and obtain a rate prediction value of the frame to be encoded according to the encoding complexity of the frame to be encoded and the initial rate quantization scale; Obtaining a predicted value of a total buffered bit rate after encoding all the frames to be encoded according to the bit rate predicted value of the frames to be encoded; When the cached total bit rate prediction value is outside the bit rate overflow interval, adjusting the bit rate quantization scale of the current frame to be encoded according to the cached total bit rate prediction value, and updating the cached total bit rate prediction value according to the adjusted bit rate quantization scale; When the cached total bit rate prediction value is within the bit rate overflow interval, the current frame to be encoded is encoded.
2. The bit rate control method according to claim 1, characterized in that: The predicting, according to the frame type of the frame to be encoded and the encoding complexities of a plurality of frames of the same type before the frame to be encoded, to obtain the encoding complexity of the frame to be encoded comprises: According to the frame type of the frame to be encoded and a preset sliding calculation window, the encoding complexity of multiple frames of the same type before the frame to be encoded and the number of the frames of the same type are obtained; Obtaining cumulative coding complexity according to coding complexities of a plurality of frames of the same type before the frame to be coded and a preset attenuation coefficient; Determining weight parameters of the frames to be encoded according to the number of the same type of frames and the encoding order of the frames to be encoded; The predicted coding complexity of the frame to be encoded is obtained according to the accumulated coding complexity and the weight parameter.
3. The bit rate control method according to claim 1, characterized in that: The obtaining of the initial rate quantization scale of the frame to be encoded includes: Acquire an initial quantization parameter of the current frame to be encoded, and obtain an initial rate quantization scale of the current frame to be encoded according to the initial quantization parameter of the current frame to be encoded; Determining, according to the frame type of the current frame to be encoded and the frame type of the subsequent frame to be encoded, a quantization scale conversion ratio between the subsequent frame to be encoded and the current frame to be encoded; The initial rate quantization scale of the subsequent frame to be encoded is obtained according to the initial rate quantization scale of the current frame to be encoded and the quantization scale conversion ratio.
4. The bit rate control method according to claim 1, characterized in that: The obtaining the code rate prediction value of the frame to be encoded according to the encoding complexity of the frame to be encoded and the initial code rate quantization scale includes: A code rate prediction value of the frame to be encoded is obtained according to the code rate prediction parameter, the encoding complexity of the frame to be encoded and the initial code rate quantization scale.
5. The bit rate control method according to claim 1, characterized in that: The step of obtaining a predicted value of a total buffered bit rate after encoding all the frames to be encoded according to the bit rate predicted value of the frames to be encoded comprises: Obtaining a total buffered bit rate corresponding to a previous frame of the current frame to be encoded and the number of frames to be encoded; According to the total buffered bit rate corresponding to the previous frame, the number of the frames to be encoded and the bit rate prediction value of each of the frames to be encoded, a total buffered bit rate prediction value after encoding all the frames to be encoded is obtained.
6. The bit rate control method according to claim 1, characterized in that: The method further comprises: Get the bitrate overflow threshold and bitrate underflow threshold; An upper limit value of the code rate overflow interval is determined according to the code rate overflow threshold and the cache size, and a lower limit value of the code rate overflow interval is determined according to the code rate underflow threshold and the cache size.
7. The bit rate control method according to claim 6, characterized in that: Obtaining the bit rate underflow threshold includes: The bit rate underflow threshold is determined according to the distance between the current frame to be encoded and the previous key frame, and a preset key frame interval.
8. The bit rate control method according to claim 6, characterized in that: The adjusting the rate quantization scale of the current frame to be encoded according to the cached total rate prediction value includes: If the cached total bit rate prediction value is greater than the upper limit of the bit rate overflow interval, reducing the bit rate quantization scale of the current frame to be encoded according to a preset adjustment ratio; If the cached total bit rate prediction value is less than the lower limit of the bit rate overflow interval, the bit rate quantization scale of the current frame to be encoded is enlarged according to a preset adjustment ratio.
9. The bit rate control method according to claim 1, characterized in that: When the cache total bit rate prediction value is within the bit rate overflow interval, the method further includes: The rate prediction parameters used in calculating the rate prediction value are updated according to the actual rate of the frame to be encoded and the rate quantization scale, as well as the actual encoding complexity of the frame to be encoded.
10. A bit rate control device, characterized in that: include: A complexity prediction module is configured to predict the coding complexity of the frame to be coded according to the frame type of the frame to be coded and the coding complexities of multiple frames of the same type before the frame to be coded, wherein the frame to be coded includes the current frame to be coded and subsequent frames to be coded; A rate prediction module is configured to obtain an initial rate quantization scale of the frame to be encoded, and obtain a rate prediction value of the frame to be encoded according to the encoding complexity of the frame to be encoded and the initial rate quantization scale; A total bit rate prediction module is configured to execute, based on the bit rate prediction value of the frame to be encoded, to obtain a cached total bit rate prediction value after encoding all the frames to be encoded; a quantization scale adjustment module, configured to adjust the rate quantization scale of the current frame to be encoded according to the cached total rate prediction value when the cached total rate prediction value is outside the rate overflow interval, and update the cached total rate prediction value according to the adjusted rate quantization scale; The current frame encoding module is configured to encode the current frame to be encoded when the cached total bit rate prediction value is within the bit rate overflow interval.
11. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the bit rate control method according to any one of claims 1 to 9.
12. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the rate control method according to any one of claims 1 to 9 is implemented.
Citation Information
Patent Citations
Video coding rate control method
CN104754335A
Video coding method and device, computer readable storage medium and computer equipment
CN110213585A
Video code rate control method, device and equipment and storage device
CN111787318A
Video decision code rate determination method and device, storage medium and electronic device
CN117640920A
Code rate control method based on video buffer verification
CN117880511A
Cited By
Code rate control method and device, electronic equipment, medium and product
CN120512538A