Video coding method and device

By dynamically adjusting the subgroup quantization parameters in video encoding, the BD-Rate loss problem caused by bit rate limiting in CRF control mode is solved, and the balance of video encoding quality and efficiency is achieved.

CN118945351AInactive Publication Date: 2024-11-12ALIPAY (HANGZHOU) INFORMATION TECH CO LTD

Patent Information

Application Number
CN202411419796.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-11
Publication Date
2024-11-12
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

When using the fixed bit rate factor (CRF) control mode for video encoding, turning on the bit rate limit will lead to the damage of the quantization parameter allocation scheme, seriously affecting the efficiency and quality of video encoding, resulting in large BD-Rate losses.

Method used

By encoding the subgroups in the image group, the actual code rate is determined, and the quantization parameter value in the subgroup is dynamically adjusted based on the code rate to ensure that the actual code rate does not exceed the code rate limit, the quantization parameters are adjusted using the correction parameters, and the quantization parameters are adjusted to Close to the QP allocation result without considering the bit rate limit.

Benefits of technology

It effectively reduces the BD-Rate loss caused by the bit rate limit, ensures the balance of video encoding quality and efficiency, and tries to be close to the encoding results without considering the bit rate limit.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118945351A_ABST
    Figure CN118945351A_ABST
Patent Text Reader

Abstract

One or more embodiments of the present specification provide a video encoding method and apparatus. According to the method, under the condition that a CRF control mode is adopted for video coding and a maximum code rate limiting function is started, an image group is divided into a plurality of subgroups, and each subgroup can comprise a plurality of video frames. And then performing coding processing by taking the subgroup as a basic unit. For example, after the previous subgroup is coded, the corresponding actual code rate is obtained. Then, based on the actual code rate of the previous subgroup, determining a QP value corresponding to each video frame in the current subgroup; and so on, until the last sub-group in the image group is coded.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] One or more embodiments of the present specification relate to the field of video technology, and more particularly, to a video encoding method and apparatus. Background Art

[0002] With the development of information technology, video has become a major component of digital information. In order to facilitate transmission, the video needs to be compressed and encoded to make it smaller in space and with better picture quality.

[0003] The constant rate factor (CRF) control mode is a video encoding mode that calculates the quantization parameter QP allocation scheme for each video frame by setting the CRF value. Then, each video frame is encoded based on the QP allocation scheme.

[0004] However, when the CRF control mode is adopted and the bit rate limit is enabled, if the calculated QP allocation scheme exceeds the bit rate limit, the QP allocation scheme will be seriously damaged, thereby seriously affecting the efficiency and quality of video encoding, and ultimately resulting in a large BD-Rate loss. Therefore, it is necessary to provide a solution that minimizes the BD-Rate loss when the CRF control mode is adopted for video encoding and the maximum bit rate limit function is enabled. Summary of the invention

[0005] In order to minimize the BD-Rate loss when the CRF control mode is used for video encoding and the maximum bit rate limit function is enabled, one or more embodiments of the present specification provide a video encoding method and apparatus.

[0006] In a first aspect, one or more embodiments of the present specification provide a video encoding method, the method comprising: after encoding a kth subgroup in a current picture group, determining an actual bit rate of the kth subgroup; wherein the current picture group includes a plurality of subgroups, any of the subgroups includes at least one video frame; k is a positive integer greater than 0; Based on the actual bit rate of the k-th subgroup, determine the quantization parameter values ​​corresponding to each video frame in the k+1-th subgroup; wherein the k+1-th subgroup is the next subgroup of the k-th subgroup in the current image group; The k+1th subgroup is encoded based on the quantization parameter value.

[0007] In a possible implementation manner, the multiple sub-groups are obtained by dividing the current image group according to a preset rule.

[0008] In a possible implementation, the current image group includes an I frame and multiple non-I frames, wherein the I frame is the starting frame of the current image group, and the non-I frames include P frames and B frames; the preset rule includes using I frames and P frames as segmentation frames, respectively, to divide the current image group into the multiple sub-groups; wherein the sub-group with I frames as segmentation frames includes an I frame, and the sub-group with P frames as segmentation frames includes at least one B frame and one P frame.

[0009] In a possible implementation, based on the actual bit rate of the kth subgroup, the quantization parameter values ​​corresponding to each video frame in the k+1th subgroup are determined, including: based on the actual bit rate of the kth subgroup, determining the correction parameters for the k+1th subgroup; based on the correction parameters, determining the quantization parameter values ​​corresponding to each video frame in the k+1th subgroup.

[0010] In a possible implementation, the determining the correction parameter for the k+1th subgroup based on the actual code rate of the kth subgroup includes: judging the magnitude relationship between the actual code rate of the kth subgroup and a first code rate threshold and a second code rate threshold; wherein the first code rate threshold is greater than the second code rate threshold; if the actual code rate of the kth subgroup is greater than or equal to the first code rate threshold, determining the correction parameter for the k+1th subgroup to be a first correction parameter; wherein the first correction parameter is greater than the correction parameter corresponding to the kth subgroup; if the actual code rate of the kth subgroup is less than or equal to the second code rate threshold, determining the correction parameter for the k+1th subgroup to be a second correction parameter; wherein the second correction parameter is greater than the correction parameter corresponding to the kth subgroup; if the actual code rate of the kth subgroup is greater than the second code rate threshold and the actual code rate of the kth subgroup is less than the first code rate threshold, determining the correction parameter for the k+1th subgroup to be a third correction parameter; and the third correction parameter is equal to the correction parameter corresponding to the kth subgroup.

[0011] In a possible implementation, the third correction parameter is , the first correction parameter is +1, the second correction parameter is -1.

[0012] In a possible implementation manner, the first bitrate threshold is calculated based on a maximum bitrate of the current image group, and the second bitrate threshold is calculated based on a minimum bitrate of the current image group.

[0013] In a possible implementation, the first bitrate threshold is MaxRate×(1+f), and the second bitrate threshold is MinRate×(1-f), wherein MaxRate is the maximum bitrate of the current image group, MinRate is the minimum bitrate of the current image group, f is a preset parameter, and f is greater than zero.

[0014] In a possible implementation, based on the correction parameter, determining the quantization parameter values ​​corresponding to the respective video frames in the k+1th subgroup includes: if the k+1th subgroup includes an I frame, using a first relational expression to calculate the quantization parameter value corresponding to the I frame in the k+1th subgroup; if the k+1th subgroup includes a P frame and a B frame, using a second relational expression to calculate the quantization parameter value corresponding to the P frame in the k+1th subgroup, and using a third relational expression to calculate the quantization parameter value corresponding to the B frame in the k+1th subgroup; wherein the first relational expression is: ; The second relation is: ; The third relational expression is: ; in, represents a fixed bit rate factor, Correction parameter corresponding to the k+1th subgroup dq p is the preset parameter corresponding to the P frame, dqp B The preset parameters corresponding to the B frame; The clip function in the first and second equations satisfies the following fourth equation: (a, b, x) = ; Among them, round is the rounding function, C I and Fact I is the preset parameter corresponding to the I frame, C P and Fact P The preset parameters corresponding to the P frame; Cplx cur-I is the complexity corresponding to the current I frame, Cplx cur-P is the complexity corresponding to the current P frame, Cplx base is the baseline complexity; Cplx base The fifth relation is satisfied as follows:

[0015] in, Indicates the number of blocks in the width of the video frame, Indicates the number of blocks in the video frame height, represents the number of B frames in the k+1th subgroup; q c The following sixth relationship is satisfied:

[0016] In a possible implementation, the method is applied to a coding device, which adopts a fixed rate factor CRF control mode and has a rate limit.

[0017] In a second aspect, one or more embodiments of the present specification also provide a video encoding device, the device comprising: a bit rate determination module, used to determine the actual bit rate of the kth subgroup in the current image group after encoding the kth subgroup in the current image group; wherein the current image group includes multiple subgroups, and any of the subgroups includes at least one video frame; k is a positive integer greater than 0; a quantization parameter determination module, used to determine the quantization parameter values ​​corresponding to each video frame in the k+1th subgroup based on the actual bit rate of the kth subgroup; wherein the k+1th subgroup is the next subgroup of the kth subgroup in the current image group; an encoding module, used to encode the k+1th subgroup based on the quantization parameter value.

[0018] In a possible implementation manner, the multiple sub-groups are obtained by dividing the current image group according to a preset rule.

[0019] In a possible implementation, the current image group includes an I frame and multiple non-I frames, wherein the I frame is the starting frame of the current image group, and the non-I frames include P frames and B frames; the preset rule includes using I frames and P frames as segmentation frames, respectively, to divide the current image group into the multiple sub-groups; wherein the sub-group with I frames as segmentation frames includes an I frame, and the sub-group with P frames as segmentation frames includes at least one B frame and one P frame.

[0020] In a possible implementation, the quantization parameter determination module is used to determine the quantization parameter values ​​corresponding to each video frame in the k+1th subgroup based on the actual bit rate of the kth subgroup. Specifically, the quantization parameter determination module is used to determine the correction parameters for the k+1th subgroup based on the actual bit rate of the kth subgroup; based on the correction parameters, determine the quantization parameter values ​​corresponding to each video frame in the k+1th subgroup.

[0021] In a possible implementation, the quantization parameter determination module is used to determine the correction parameter for the k+1th subgroup based on the actual bit rate of the kth subgroup, specifically: The quantization parameter determination module is used to determine the size relationship between the actual bit rate of the kth subgroup and the first bit rate threshold and the second bit rate threshold; wherein the first bit rate threshold is greater than the second bit rate threshold; if the actual bit rate of the kth subgroup is greater than or equal to the first bit rate threshold, then determine that the correction parameter for the k+1th subgroup is the first correction parameter; wherein the first correction parameter is greater than the correction parameter corresponding to the kth subgroup; if the actual bit rate of the kth subgroup is less than or equal to the second bit rate threshold, then determine that the correction parameter for the k+1th subgroup is the second correction parameter; wherein the second correction parameter is greater than the correction parameter corresponding to the kth subgroup; if the actual bit rate of the kth subgroup is greater than the second bit rate threshold, and the actual bit rate of the kth subgroup is less than the first bit rate threshold, then determine that the correction parameter for the k+1th subgroup is the third correction parameter; and the third correction parameter is equal to the correction parameter corresponding to the kth subgroup.

[0022] In a possible implementation, the third correction parameter is , the first correction parameter is +1, the second correction parameter is -1.

[0023] In a possible implementation manner, the first bitrate threshold is calculated based on a maximum bitrate of the current image group, and the second bitrate threshold is calculated based on a minimum bitrate of the current image group.

[0024] In a possible implementation, the first bitrate threshold is MaxRate×(1+f), and the second bitrate threshold is MinRate×(1-f), wherein MaxRate is the maximum bitrate of the current image group, MinRate is the minimum bitrate of the current image group, f is a preset parameter, and f is greater than zero.

[0025] In a possible implementation, the quantization parameter determination module is used to determine the quantization parameter values ​​corresponding to each video frame in the k+1th subgroup based on the correction parameter, specifically: The quantization parameter determination module is used to calculate the quantization parameter value corresponding to the I frame in the k+1th subgroup using the first relational expression if the k+1th subgroup includes an I frame; if the k+1th subgroup includes a P frame and a B frame, calculate the quantization parameter value corresponding to the P frame in the k+1th subgroup using the second relational expression, and calculate the quantization parameter value corresponding to the B frame in the k+1th subgroup using the third relational expression; Wherein, the first relational expression is: ; The second relation is: ; The third relational expression is: ; in, represents a fixed bit rate factor, Correction parameter corresponding to the k+1th subgroup dq p is the preset parameter corresponding to the P frame, dqp B The preset parameters corresponding to the B frame; The clip function in the first and second equations satisfies the following fourth equation: (a, b, x) = ; Among them, round is the rounding function, C I and Fact I is the preset parameter corresponding to the I frame, C P and Fact P The preset parameters corresponding to the P frame; Cplx cur-I is the complexity corresponding to the current I frame, Cplx cur-P is the complexity corresponding to the current P frame, Cplx base is the baseline complexity; Cplx base The fifth relation is satisfied as follows:

[0026] in, Indicates the number of blocks in the width of the video frame, Indicates the number of blocks in the video frame height, represents the number of B frames in the k+1th subgroup; q c The following sixth relationship is satisfied:

[0027] In a possible implementation, the device adopts a fixed rate factor CRF control mode and has a rate limit.

[0028] In a third aspect, one or more embodiments of the present specification further provide an encoding device, comprising a memory and a processor; the memory is used to store a computer program product; the processor is used to execute the computer program product stored in the memory, and when the computer program product is executed, the video encoding method of the first aspect described above is implemented.

[0029] In a fourth aspect, one or more embodiments of the present specification further provide a computer-readable storage medium, wherein the computer-readable storage medium stores computer program instructions, and when the computer program instructions are executed, the video encoding method of the first aspect described above is implemented.

[0030] In summary, in order to minimize the BD-Rate loss when the CRF control mode is used for video encoding and the maximum bit rate limit function is turned on, one or more embodiments of the present specification provide a video encoding method and device. In this method, the QP allocation result of the current subgroup is predicted based on the actual bit rate of the previous subgroup, so that the actual bit rate of the current subgroup can be made to not exceed the corresponding bit rate limit. In addition, by dynamically adjusting the QP value of the subgroup based on the subgroup, when the actual bit rate of the subgroup does not exceed the maximum bit rate limit or the minimum bit rate limit, it can be ensured that the QP allocation result of the entire subgroup is consistent with the QP allocation result corresponding to the MiniGOP when the bit rate limit is not considered, so that the QP allocation result of the current image group is as close as possible to the corresponding QP allocation result when the bit rate limit is not considered, so as to minimize the BD-Rate loss caused by the maximum bit rate limit or the minimum bit rate limit. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] In order to more clearly illustrate the technical solutions of one or more embodiments of the present specification, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of one or more embodiments of the present specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0032] Figure 1 A schematic diagram of an application scenario provided for one or more embodiments of this specification; Figure 2 A schematic diagram of a video encoding method provided for one or more embodiments of this specification; Figure 3 A schematic diagram of allocation of multiple subgroups in an image group provided for one or more embodiments of this specification; Figure 4 A structural block diagram of a video encoding device provided for one or more embodiments of this specification; Figure 5 A structural block diagram of an encoding device provided for one or more embodiments of this specification. DETAILED DESCRIPTION

[0033] One or more embodiments of the present invention are further described in detail below through the accompanying drawings and examples. Through these descriptions, the features and advantages of one or more embodiments of the present invention will become clearer and more specific.

[0034] The word "exemplary" is used exclusively herein to mean "serving as an example, embodiment, or illustration." Any embodiment described herein as "exemplary" is not necessarily to be construed as preferred or advantageous over other embodiments. Although various aspects of the embodiments are shown in the drawings, the drawings are not necessarily drawn to scale unless otherwise noted.

[0035] In addition, the technical features involved in different implementations of one or more embodiments of this specification described below can be combined with each other as long as they do not conflict with each other.

[0036] To facilitate understanding, the application scenarios of the technical solutions provided by one or more embodiments of this specification are first described below.

[0037] Figure 1 This is a schematic diagram of an application scenario provided by one or more embodiments of this specification. Figure 1 The application scenario shown may include a terminal 10, a network 11, and a server 12. The terminal 10 is connected to the server 12 via the network 11. The terminal 10 may be a mobile phone, a PC, a tablet computer, etc., which is not limited in one or more embodiments of this specification. The server may be a cloud server, a physical server, a local server, etc., which is not limited in one or more embodiments of this specification.

[0038] The server 12 can respond to the video playback request of the terminal 10 and send the requested video to the terminal 10. Specifically, the server 12 first performs video encoding processing on the requested video to compress the video and reduce the size of the video data, thereby saving transmission bandwidth and improving transmission efficiency. After that, the server 12 sends the video data obtained after the encoding processing to the terminal 10 through the network 11. After receiving the video data, the terminal 10 decodes the video data to play the corresponding video on the terminal 10.

[0039] In order to facilitate the understanding of the video encoding method provided by one or more embodiments of this specification, some nouns or terms involved in the video encoding process are explained as follows.

[0040] 1. Constant rate factor (CRF) control mode: CRF control mode is a video encoding mode. CRF control mode controls the quality of the video by setting a fixed CRF value. Usually, CRF is a value between 0 and 51. Among them, a lower CRF value means higher image quality and higher bit rate, and a higher CRF value means lower image quality and lower bit rate.

[0041] 2. QP: quantization step size, also known as quantization parameter. Among them, the CRF control mode is mainly achieved by dynamically adjusting the QP of each frame. Generally, the higher the QP value, the more video details are lost, the lower the video quality, but the bit rate is also small. The lower the QP value, the more video details are retained, the higher the video quality, but the bit rate is also larger.

[0042] 3. Bit rate: refers to the amount of data transmitted or stored per second, and is a key indicator for measuring the size and quality of video files. The encoding device can control the bit rate by adjusting the QP value to achieve the desired compression effect and quality.

[0043] 4. Group of picture (GOP): During the video encoding process, the entire video can be divided into at least one GOP, each of which can contain multiple video frames. Then, the encoding process is performed in units of GOP.

[0044] The video frames can be divided into I frames, P frames and B frames. Usually, the entire video can be divided into multiple GOPs using I frames as segmentation frames. Each GOP includes an I frame and non-I frames between two I frames. For example, non-I frames can include P frames and B frames.

[0045] 5. Block: Any video frame in a GOP can be divided into at least one block. For example, the size of each block is 64 (pixels) × 64 (pixels).

[0046] 6. Frame-level QP allocation: In CRF control mode, the encoding device dynamically adjusts the QP value corresponding to each video frame according to the set CRF value to maintain consistent visual quality.

[0047] 7. Block-level QP allocation: In CRF control mode, the encoding device can further allocate QP for different blocks in each video frame.

[0048] In the process of encoding GOP video, frame-level QP allocation and block-level QP allocation can be used simultaneously.

[0049] 8. BD-Rate: It is an objective metric used in video compression to compare the rate-distortion performance or compression efficiency of two different video codecs or different settings of the same video codec within a range of bitrates or quality values. The greater the BD-Rate, the better the encoder performance.

[0050] In a possible implementation, video encoding can be implemented in the following manner: based on the set CRF value, the QP value corresponding to each video frame in the GOP can be calculated without considering the bit rate limit, and the frame-level QP allocation scheme corresponding to the current GOP can be obtained. Then, the block-level QP allocation scheme corresponding to each video frame can be calculated based on the QP value of each video frame. Finally, the GOP can be encoded based on the frame-level QP allocation scheme and the block-level QP allocation scheme.

[0051] Among them, the frame-level QP allocation scheme can allocate a suitable QP value for each video frame to ensure the balance between the quality and bit rate of the entire video. The block-level QP allocation scheme is further refined to each block in the video frame based on the frame-level QP allocation scheme, which can improve the local encoding quality.

[0052] It should be noted that when the CRF control mode is used for video encoding, you can choose to enable or disable the maximum bit rate limit function.

[0053] If you choose not to enable the maximum bitrate limit function, the bitrate will not affect the calculated frame-level QP allocation scheme and block-level QP allocation scheme. If you choose to enable the maximum bitrate limit function, if the maximum bitrate limit is triggered, the frame-level QP allocation scheme and block-level QP allocation scheme will be seriously damaged, which will seriously affect the efficiency and quality of video encoding, and ultimately lead to a large BD-Rate loss.

[0054] In order to minimize the BD-Rate loss when the CRF control mode is used for video encoding and the maximum bit rate limit function is enabled, one or more embodiments of this specification provide a video encoding method. The video encoding method can be applied to an encoding device. For example, the encoding device can be Figure 1 Of course, the encoding device may also be a terminal for performing video encoding processing, which is not limited in one or more embodiments of this specification.

[0055] Figure 2 A flowchart of a video encoding method provided by one or more embodiments of this specification is shown in FIG. Figure 2 As shown, the method may include the following steps: Step S102, after encoding the kth subgroup in the current group of pictures GOP, determine the actual bit rate of the kth subgroup, where k is a positive integer greater than 0.

[0056] Step S104: determining the quantization parameter values ​​corresponding to the respective video frames in the k+1th subgroup based on the actual bit rate of the kth subgroup.

[0057] Step S106: encoding the k+1th subgroup based on the quantization parameter value.

[0058] In the above steps S102 to S106, the current GOP is further divided into a plurality of subgroups MiniGOP. Then, the encoding process is performed based on the MiniGOP as a basic unit. Each MiniGOP may include at least one video frame.

[0059] Specifically, after the previous MiniGOP (i.e., the kth MiniGOP) is encoded, the actual bit rate corresponding to the previous MiniGOP is determined. Then, based on the actual bit rate, the QP values ​​corresponding to each video frame in the current MiniGOP (i.e., the k+1th MiniGOP) are determined. And based on the QP value, the current MiniGOP is encoded. And so on, until the last MiniGOP in the current GOP is encoded.

[0060] In this way, the above steps S102 to S106 predict the QP allocation result of the current MiniGOP based on the actual bit rate of the previous MiniGOP, so that the actual bit rate of the current MiniGOP can be made to not exceed the corresponding bit rate limit as much as possible. In addition, by dynamically adjusting the QP value of the MiniGOP based on the MiniGOP, when the actual bit rate of the MiniGOP does not exceed the maximum bit rate limit or the minimum bit rate limit, the entire QP allocation result of the MiniGOP can be guaranteed to be consistent with the QP allocation result corresponding to the MiniGOP when the bit rate limit is not considered, so that the QP allocation result of the current GOP is as close as possible to the corresponding QP allocation result when the bit rate limit is not considered, so as to minimize the BD-Rate loss caused by the maximum bit rate limit or the minimum bit rate limit.

[0061] Among them, multiple MiniGOPs in the current GOP can be obtained by dividing according to preset rules.

[0062] For example, Figure 3 As shown, the current GOP includes an I frame and multiple non-I frames, wherein the I frame is the start frame of the current GOP.

[0063] Optionally, the current GOP may be divided into multiple MiniGOPs using I frames and P frames as segmentation frames.

[0064] In this way, Figure 3As shown, the I frame in the current GOP can be used as the first MiniGOP1. Then, the three B frames and one P frame after the first MiniGOP1 are used as the second MiniGOP2. Similarly, the three B frames and one P frame after the second MiniGOP2 are used as the third MiniGOP3, and the three B frames and one P frame after the third MiniGOP3 are used as the fourth MiniGOP4.

[0065] The current GOP includes Figure 3 Taking the video frame shown as an example, the method of video encoding for the current GOP is exemplarily described.

[0066] First, based on the set CRF value, without considering the bit rate limit, the frame-level QP allocation scheme and the block-level QP allocation scheme corresponding to the current GOP can be calculated.

[0067] like Figure 3 As shown, for MiniGOP1, the I frame in MiniGOP1 can be encoded based on the QP value corresponding to the I frame in the frame-level QP allocation scheme. Then, the actual bit rate R1 corresponding to the encoded MiniGOP1 can be obtained.

[0068] For MiniGOP2, the QP1 values ​​corresponding to each B frame and P frame in MiniGOP2 can be predicted based on the actual bit rate R1. Specifically, if the actual bit rate R1 exceeds the maximum bit rate or minimum bit rate limit, the frame-level QP allocation scheme corresponding to the MiniGOP2 part is adjusted. Then, based on the adjusted QP1 values ​​corresponding to each video frame in MiniGOP2, the B frames and P frames in MiniGOP2 are encoded. If the actual bit rate R1 does not exceed the maximum bit rate or minimum bit rate limit, there is no need to adjust the frame-level QP allocation scheme corresponding to the MiniGOP2 part. Then, based on the frame-level QP allocation scheme corresponding to MiniGOP2, the B frames and P frames in MiniGOP2 are encoded. Afterwards, the actual bit rate R2 corresponding to the encoded MiniGOP2 can be obtained.

[0069] For MiniGOP3, the QP2 values ​​corresponding to each B frame and P frame in MiniGOP3 can be predicted based on the actual bit rate R2. Similarly, if the actual bit rate R2 exceeds the maximum bit rate or minimum bit rate limit, the frame-level QP allocation scheme corresponding to the MiniGOP3 part is adjusted. If the actual bit rate R2 does not exceed the maximum bit rate or minimum bit rate limit, there is no need to adjust the frame-level QP allocation scheme corresponding to the MiniGOP3 part. Then, based on the adjusted or unadjusted QP2 values, the B frames and P frames in MiniGOP3 are encoded. Afterwards, the actual bit rate R3 corresponding to the encoded MiniGOP3 can be obtained.

[0070] For MiniGOP4, the QP3 values ​​corresponding to each B frame and P frame in MiniGOP4 can be predicted based on the actual bit rate R3. Similarly, if the actual bit rate R3 exceeds the maximum bit rate or minimum bit rate limit, the frame-level QP allocation scheme corresponding to the MiniGOP4 portion is adjusted. If the actual bit rate R3 does not exceed the maximum bit rate or minimum bit rate limit, there is no need to adjust the frame-level QP allocation scheme corresponding to the MiniGOP4 portion. Then, based on the adjusted or unadjusted QP3 values, the B frames and P frames in MiniGOP4 are encoded.

[0071] At this point, the encoding process of the current GOP is completed. It should be understood that the above-mentioned method can be used to perform encoding process on any GOP.

[0072] It can be seen that when encoding the GOP, the frame-level QP allocation scheme corresponding to the current GOP can be calculated based on the set CRF value. Then, the first MiniGOP is encoded with the frame-level QP allocation scheme corresponding to the first MiniGOP. After that, the actual bit rate corresponding to the first MiniGOP is used to determine whether the frame-level QP allocation scheme corresponding to the second MiniGOP needs to be adjusted. If adjustment is required, the frame-level QP allocation scheme corresponding to the second MiniGOP is recalculated according to the preset adjustment rules, and the second MiniGOP is encoded with the recalculated frame-level QP allocation scheme corresponding to the second MiniGOP. And so on, until the last MiniGOP of the current GOP is encoded. In this way, performing frame-level QP allocation every four frames can increase the interval of frame-level QP allocation, so that the frame-level QP allocation results corresponding to each video frame can be changed as little as possible.

[0073] It should be noted that, in the above scheme, when encoding each MiniGOP, a block-level QP allocation scheme may be adopted, that is, the above scheme does not need to adjust the block-level QP allocation scheme.

[0074] It should also be noted that one or more embodiments of this specification only use I frames and P frames as segmented frames to divide the current GOP into multiple MiniGOPs for illustrative purposes, and do not limit the method of dividing MiniGOPs. For example, each subgroup consisting of non-I frames in a GOP can also be called a MiniGOP. Figure 3 When encoding the GOP shown in FIG. 1 , the I frame may be encoded based on the frame-level allocation scheme, and the three B frames and the P frame ( Figure 3 Then, determine Figure 3The actual bit rate of MiniGOP2 in Figure 3 The actual bit rate of MiniGOP2 in Figure 3 The frame-level QP allocation of MiniGOP3 in . And so on until Figure 3 The MiniGOP4 in is used for encoding.

[0075] The number of video frames included in different MiniGOPs may be the same or different, and the types of video frames included in different MiniGOPs may be the same or different.

[0076] The QP values ​​corresponding to the respective video frames in the k+1th MiniGOP are determined based on the actual bit rate of the kth MiniGOP, which can be implemented in the following manner: first, based on the actual bit rate of the kth MiniGOP, a correction parameter for the k+1th MiniGOP is determined. Then, based on the correction parameter, the QP values ​​corresponding to the respective video frames in the k+1th MiniGOP are determined.

[0077] In a possible implementation, based on the actual bit rate of the kth MiniGOP, the correction parameter for the k+1th MiniGOP is determined, which can be implemented in the following manner: first, the relationship between the actual bit rate of the kth MiniGOP and the first bit rate threshold and the second bit rate threshold is determined. The first bit rate threshold is greater than the second bit rate threshold.

[0078] The first bitrate threshold may be calculated based on the maximum bitrate MaxRate of the current GOP, and the second bitrate threshold may be calculated based on the minimum bitrate MinRate of the current GOP. For example, the first bitrate threshold is MaxRate×(1+f), and the second bitrate threshold is MinRate×(1-f), where f is a preset parameter and f is greater than zero.

[0079] The relationship between the actual bit rate of the kth MiniGOP and the first bit rate threshold and the second bit rate threshold includes the following three cases: (i) The actual bit rate of the kth MiniGOP is greater than or equal to the first bit rate threshold.

[0080] If the actual bit rate of the kth MiniGOP is greater than or equal to the first bit rate threshold, the correction parameter for the k+1th subgroup may be determined as the first correction parameter, wherein the first correction parameter is greater than the correction parameter corresponding to the kth MiniGOP.

[0081] That is, if the actual bit rate of the kth MiniGOP exceeds the corresponding maximum bit rate limit, the QP value of the k+1th MiniGOP can be increased by increasing the correction parameter of the k+1th MiniGOP, thereby reducing the bit rate of the k+1th MiniGOP.

[0082] It should be noted that, the larger the correction parameter of MiniGOP is, the larger the QP value corresponding to each video frame in MiniGOP is.

[0083] It should also be noted that, for the first MiniGOP in the current GOP, the corresponding correction parameter may be zero.

[0084] (ii) The actual bit rate of the kth MiniGOP is less than or equal to the second bit rate threshold.

[0085] If the actual bit rate of the kth MiniGOP is less than or equal to the second bit rate threshold, the correction parameter for the k+1th subgroup is determined to be the second correction parameter, wherein the second correction parameter is greater than the correction parameter corresponding to the kth subgroup.

[0086] That is, if the actual bit rate of the kth MiniGOP exceeds the corresponding minimum bit rate limit, the QP value of the k+1th MiniGOP can be reduced by reducing the correction parameter of the k+1th MiniGOP, thereby increasing the bit rate of the k+1th MiniGOP.

[0087] (iii) The actual bit rate of the kth MiniGOP is greater than the second bit rate threshold, and the actual bit rate is less than the first bit rate threshold.

[0088] If the actual bit rate of the kth MiniGOP is greater than the second bit rate threshold and less than the first bit rate threshold, the correction parameter for the k+1th subgroup is determined to be the third correction parameter. The third correction parameter is the correction parameter corresponding to the kth subgroup.

[0089] That is, if the actual bit rate of the kth MiniGOP is between the corresponding minimum bit rate and maximum bit rate, the correction parameter of the k+1th MiniGOP may be kept the same as the correction parameter of the kth MiniGOP.

[0090] In order to change the frame-level QP allocation result corresponding to each video frame in the MiniGOP as little as possible, the correction parameter of the k+1th MiniGOP can be adjusted according to the following relationship (1).

[0091] The relationship (1) is: = Relation (1) Among them, R represents the actual bit rate of the kth MiniGOP, represents the correction parameter of the kth MiniGOP, Indicates the correction parameters of the k+1th MiniGOP.

[0092] It can be seen from the above relationship (1) that when the actual bit rate R is greater than or equal to the first bit rate threshold, or less than or equal to the second bit rate threshold, the correction parameter of the k+1th MiniGOP is adjusted by adding 1 or -1 to the correction parameter of the kth MiniGOP each time. In this way, the frame-level QP allocation result of the MiniGOP can be changed as little as possible, thereby minimizing the BD-Rate loss.

[0093] It should be noted that one or more embodiments of this specification only use the above relationship (1) as an example for illustrative description, and do not limit the adjustment method of the correction parameter of the k+1th MiniGOP. For example, when the actual bit rate R is greater than or equal to the first bit rate threshold, the correction parameter of the k+1th MiniGOP may also be Determined as When the actual bit rate R is less than or equal to the second bit rate threshold, the correction parameter of the k+1th MiniGOP may also be Determined as -2, which are not listed here one by one. The smaller the adjustment value (eg, 1 or 2), the smaller the change to the frame-level QP allocation result of the MiniGOP.

[0094] Furthermore, based on the modified parameters of the k+1th MiniGOP, the QP values ​​corresponding to the respective video frames in the k+1th MiniGOP are determined, which can be implemented in the following manner: If the k+1th MiniGOP includes an I frame, the QP value corresponding to the I frame in the k+1th MiniGOP is calculated using equation (2).

[0095] If the k+1th MiniGOP includes a P frame and a B frame, the QP value corresponding to the P frame in the k+1th MiniGOP is calculated using equation (3), and the QP value corresponding to the B frame in equation (3) is calculated using equation (4).

[0096] The relationship (2) is: Relation (2) The relationship (3) is: Relation (3) The relationship (4) is: Relation (4) In the above equations (2), (3) and (4), Indicates the CRF value set by the encoding device. represents the correction parameter corresponding to the k+1th MiniGOP, where It can be determined based on the above relationship (1), which will not be described here.

[0097] From the above equations (2), (3) and (4), we can see that I-frames, P-frames and B-frames are all modified by introducing the correction parameter , adjust the QP value of each video frame. In this way, compared with the frame-level QP allocation result without considering the bit rate limit, the difference in QP values ​​between I frames, P frames and B frames remains unchanged, which helps to improve the overall video quality.

[0098] Among them, C I and Fact I is the preset parameter corresponding to the I frame, dqp p , C P and Fact P is the preset parameter corresponding to the P frame, dqp B The preset parameters corresponding to the B frame. I 、Fact I 、dqp p , C P 、Fact P and dqp B The value of can be a constant determined by simulation experiments of multiple video encodings using the CRF control mode and with bit rate limiting enabled, and will not be described in detail here.

[0099] The functions in equations (2) and (3) are The following relationship (5) is satisfied: (a, b, x) = Relation (5) For the above relationship (2), a=0, b= ,x= In this way, based on the relationship between x and a, Similarly, for the above equation (3), we can determine the value of The value of .

[0100] Among them, Cplx cur-I is the complexity corresponding to the current I frame, Cplx cur-P is the complexity corresponding to the current P frame, Cplxbase is the base complexity.

[0101] Cplx cur-I and Cplx cur-P It may be an intra / inter SAD (sum of absolute differences) cost calculated using the lookahead technique. The specific calculation method may refer to the relevant technology and will not be described in detail here.

[0102] Cplx base It can be calculated using the following relationship (6): Relation (6) in, Indicates the number of blocks in the width of the video frame, Indicates the number of blocks in the video frame height, Indicates the number of B frames in the k+1th MiniGOP.

[0103] That is, if the number of B frames in the k+1th MiniGOP is greater than zero, then the above equations (2) and (3) are = If the number of B frames in the k+1th MiniGOP is zero, then the above equations (2) and (3) are = .

[0104] In the above equations (2) and (3), The following relationship (7) is satisfied: Relation (7) in, (Coded Unit Tree) is a video encoding technology. For details, please refer to the related technologies and will not be described here.

[0105] That is, if the k+1th MiniGOP adopts For video encoding, The value is 1. On the contrary, if the k+1th MiniGOP does not use For video encoding, The value is 0.6.

[0106] Combining equations (2), (3) and (7), we can see that: If you use , The value is 1, then 1- = 0. Therefore, in equation (2) And in relation (3) The effect of is completely offset. In this case, and The value of depends more on other parameters, rather than on the complexity of the current frame, the baseline complexity and other parameters.

[0107] If not used , The value is 0.6, then 1- =0.4. This means that the impact of the ratio of the current frame complexity to the baseline complexity will be amplified by 0.4 times. In this case, and The value of will be significantly affected by the ratio of the current frame complexity to the baseline complexity, thus adjusting To cope with the complexity changes of video frames.

[0108] Thus, by adjusting The encoding device can flexibly control the degree of response to the complexity ratio in different situations. When the encoding device prefers stable quantization parameter adjustment instead of using When the encoding device is more sensitive to the change in complexity, it will adjust the quantization parameters according to the change in complexity. This helps to optimize the video quality and compression efficiency under different encoding strategies.

[0109] By combining the above equations (1), (2), (3), (4), (5), (6) and (7), the QP value corresponding to each video frame in the k+1th MiniGOP can be calculated.

[0110] In a specific example, when the CRF control mode is used for video encoding, and the maximum bit rate and minimum bit rate limit functions are enabled, when the above equations (1), (2), (3), (4), (5), (6) and (7) are used for video encoding, the corresponding global BD-Rate loss is less than 2%. The maximum bit rate is set to 2.5 Mbps, and the minimum bit rate is set to 1 Mbps.

[0111] In summary, in order to minimize the BD-Rate loss when the CRF control mode is used for video encoding and the bit rate limit function is turned on, the video encoding method provided by one or more embodiments of the present specification predicts the QP allocation result of the current MiniGOP based on the actual bit rate of the previous MiniGOP, so that the actual bit rate of the current MiniGOP does not exceed the corresponding bit rate limit. In addition, by dynamically adjusting the QP value of the MiniGOP based on the MiniGOP as a basic unit, when the actual bit rate of the MiniGOP does not exceed the maximum bit rate limit or the minimum bit rate limit, the QP allocation result of the entire MiniGOP can be guaranteed to be consistent with the QP allocation result corresponding to the MiniGOP when the bit rate limit is not considered, so that the QP allocation result of the current GOP is as close as possible to the corresponding QP allocation result when the bit rate limit is not considered, so as to minimize the BD-Rate loss caused by the maximum bit rate limit or the minimum bit rate limit.

[0112] It can be understood that the above embodiments are only examples and can be modified in actual implementation. Those skilled in the art can understand that the modification methods of the above embodiments without creative labor fall within the protection scope of one or more embodiments of this specification and will not be repeated in the embodiments.

[0113] Based on the same inventive concept, one or more embodiments of the present specification also provide a video encoding device. Since the principle of solving the problem by the video encoding device is similar to that of the aforementioned video encoding method, the implementation of the video encoding device can refer to the implementation of the aforementioned video encoding method, and the repeated parts will not be repeated.

[0114] See also Figure 4 , Figure 4 This is a structural block diagram of a video encoding device provided by one or more embodiments of this specification. Figure 4 As shown, the video encoding device 200 may include: a bit rate determination module 201, a quantization parameter determination module 202 and an encoding module 203. The bit rate determination module 201 can be used to determine the actual bit rate of the kth subgroup in the current image group after encoding the kth subgroup in the current image group; wherein the current image group includes multiple subgroups, and any of the subgroups includes at least one video frame; k is a positive integer greater than 0.

[0115] The quantization parameter determination module 202 can be used to determine the quantization parameter values ​​corresponding to each video frame in the k+1th subgroup based on the actual bit rate of the kth subgroup; wherein the k+1th subgroup is the next subgroup of the kth subgroup in the current image group.

[0116] The encoding module 23 may be configured to perform encoding processing on the k+1th subgroup based on the quantization parameter value.

[0117] In a possible implementation manner, the multiple sub-groups are obtained by dividing the current image group according to a preset rule.

[0118] In a possible implementation, the current group of pictures includes an I frame and a plurality of non-I frames, wherein the I frame is a start frame of the current group of pictures, and the non-I frames include a P frame and a B frame; The preset rule includes using I frames and P frames as segmentation frames respectively to divide the current image group into the multiple sub-groups; wherein the sub-group using I frames as segmentation frames includes one I frame, and the sub-group using P frames as segmentation frames includes at least one B frame and one P frame.

[0119] In a possible implementation, the quantization parameter determination module is used to determine the quantization parameter values ​​corresponding to each video frame in the k+1th subgroup based on the actual bit rate of the kth subgroup, specifically: The quantization parameter determination module is used to determine the correction parameter for the k+1th subgroup based on the actual bit rate of the kth subgroup; based on the correction parameter, determine the quantization parameter value corresponding to each video frame in the k+1th subgroup.

[0120] In a possible implementation, the quantization parameter determination module is used to determine the correction parameter for the k+1th subgroup based on the actual bit rate of the kth subgroup, specifically: The quantization parameter determination module is used to determine the size relationship between the actual bit rate of the kth subgroup and the first bit rate threshold and the second bit rate threshold; wherein the first bit rate threshold is greater than the second bit rate threshold; if the actual bit rate of the kth subgroup is greater than or equal to the first bit rate threshold, then determine that the correction parameter for the k+1th subgroup is the first correction parameter; wherein the first correction parameter is greater than the correction parameter corresponding to the kth subgroup; if the actual bit rate of the kth subgroup is less than or equal to the second bit rate threshold, then determine that the correction parameter for the k+1th subgroup is the second correction parameter; wherein the second correction parameter is greater than the correction parameter corresponding to the kth subgroup; if the actual bit rate of the kth subgroup is greater than the second bit rate threshold, and the actual bit rate of the kth subgroup is less than the first bit rate threshold, then determine that the correction parameter for the k+1th subgroup is the third correction parameter; and the third correction parameter is equal to the correction parameter corresponding to the kth subgroup.

[0121] In a possible implementation, the third correction parameter is , the first correction parameter is +1, the second correction parameter is -1.

[0122] In a possible implementation manner, the first bitrate threshold is calculated based on a maximum bitrate of the current image group, and the second bitrate threshold is calculated based on a minimum bitrate of the current image group.

[0123] In a possible implementation, the first bitrate threshold is MaxRate×(1+f), and the second bitrate threshold is MinRate×(1-f), wherein MaxRate is the maximum bitrate of the current image group, MinRate is the minimum bitrate of the current image group, f is a preset parameter, and f is greater than zero.

[0124] In a possible implementation, the quantization parameter determination module is used to determine the quantization parameter values ​​corresponding to each video frame in the k+1th subgroup based on the correction parameter, specifically: The quantization parameter determination module is used to calculate the quantization parameter value corresponding to the I frame in the k+1th subgroup using the first relational expression if the k+1th subgroup includes an I frame; if the k+1th subgroup includes a P frame and a B frame, calculate the quantization parameter value corresponding to the P frame in the k+1th subgroup using the second relational expression, and calculate the quantization parameter value corresponding to the B frame in the k+1th subgroup using the third relational expression; Wherein, the first relational expression is: ; The second relation is: ; The third relational expression is: ; in, represents a fixed bit rate factor, Correction parameter corresponding to the k+1th subgroup dq p is the preset parameter corresponding to the P frame, dqp B The preset parameters corresponding to the B frame; The clip function in the first and second equations satisfies the following fourth equation: (a, b, x) = .

[0125] Among them, round is the rounding function, C I and Fact I is the preset parameter corresponding to the I frame, C P and Fact P The preset parameters corresponding to the P frame; Cplxcur-I is the complexity corresponding to the current I frame, Cplx cur-P is the complexity corresponding to the current P frame, Cplx base is the baseline complexity; Cplx base The fifth relation is satisfied as follows:

[0126] in, Indicates the number of blocks in the width of the video frame, Indicates the number of blocks in the video frame height, represents the number of B frames in the k+1th subgroup; q c The following sixth relationship is satisfied:

[0127] In a possible implementation, the device adopts a fixed rate factor CRF control mode and has a rate limit.

[0128] See also Figure 5 , Figure 5 This is a structural block diagram of a coding device provided in one or more embodiments of this specification. Figure 5 As shown, the encoding device 300 may include a processor 301 and a memory 302; the memory 302 may be coupled to the processor 301. It is worth noting that the Figure 5 is exemplary; other types of structures may also be used to supplement or replace this structure to implement telecommunication functions or other functions.

[0129] In a possible implementation, the functions of the video encoding apparatus 200 may be integrated into the processor 301. The processor 301 may be configured to perform the following operations: After encoding the kth subgroup in the current picture group, determining the actual bit rate of the kth subgroup; wherein the current picture group includes a plurality of subgroups, any of the subgroups includes at least one video frame; k is a positive integer greater than 0; Based on the actual bit rate of the k-th subgroup, determine the quantization parameter values ​​corresponding to each video frame in the k+1-th subgroup; wherein the k+1-th subgroup is the next subgroup of the k-th subgroup in the current image group; The k+1th subgroup is encoded based on the quantization parameter value.

[0130] In another possible implementation, the video encoding device 200 may be configured separately from the processor 301 . For example, the video encoding device 200 may be configured as a chip connected to the processor 301 , and video encoding is implemented under the control of the processor 301 .

[0131] In addition, in some optional implementations, the encoding device 300 may also include: a communication module, an input unit, an audio processor, a display, a power supply, etc. It is worth noting that the encoding device 300 does not necessarily include Figure 5 In addition, the encoding device 300 may also include Figure 5 For components not shown, reference may be made to the prior art.

[0132] In some optional implementations, the processor 301, sometimes also referred to as a controller or operation control, may include a microprocessor or other processor device and / or logic device, which receives input and controls the operation of various components of the encoding device 300.

[0133] The memory 302 may be, for example, a cache, a flash memory, a hard drive, a removable medium, a volatile memory, a non-volatile memory or other suitable devices. The memory 302 may store the above-mentioned information related to the video encoding device 400, and may also store a program for executing the related information. The processor 301 may execute the program stored in the memory 302 to implement information storage or processing.

[0134] The input unit can provide input to the processor 301. The input unit is, for example, a key or a touch input device. The power supply can be used to provide power to the encoding device 300. The display can be used to display display objects such as images and text. The display can be, for example, an LCD display, but is not limited thereto.

[0135] The memory 302 may be a solid-state memory, such as a read-only memory (ROM), a random access memory (RAM), a SIM card, etc. It may also be a memory that saves information even when the power is off, can be selectively erased, and is provided with more data, examples of which are sometimes referred to as EPROMs, etc. The memory 302 may also be some other type of device. The memory 302 includes a buffer memory (sometimes referred to as a buffer). The memory 302 may include an application / function storage unit for storing application programs and function programs or processes for executing the operation of the encoding device 300 through the processor 301.

[0136] The memory 302 may also include a data storage unit for storing data, such as contacts, digital data, pictures, sounds, and / or any other data used by the electronic device. The driver storage unit of the memory 302 may include various drivers for the communication function of the computer device and / or for executing other functions of the computer device (such as a messaging application, a contact book application, etc.).

[0137] The communication module is a transmitter / receiver that sends and receives signals via an antenna. The communication module (transmitter / receiver) is coupled to the processor 301 to provide input signals and receive output signals, which may be the same as in a conventional mobile communication terminal.

[0138] Based on different communication technologies, multiple communication modules may be provided in the same computer device, such as a cellular network module, a Bluetooth module and / or a wireless local area network module, etc. The communication module (transmitter / receiver) is also coupled to a speaker and a microphone via an audio processor to provide an audio output via the speaker and receive an audio input from the microphone, thereby realizing a common telecommunication function. The audio processor may include any suitable buffer, decoder, amplifier, etc. In addition, the audio processor is also coupled to the processor 301, so that recording can be performed on the machine through the microphone, and the sound stored on the machine can be played through the speaker.

[0139] One or more embodiments of the present specification also provide a computer-readable storage medium capable of implementing all the steps of the video encoding method in the above embodiment. The computer-readable storage medium stores a computer program. When the computer program is executed by a processor, all the steps of the video encoding method in the above embodiment are implemented. For example, when the processor executes the computer program, the following steps are implemented: After encoding the kth subgroup in the current picture group, determining the actual bit rate of the kth subgroup; wherein the current picture group includes a plurality of subgroups, any of the subgroups includes at least one video frame; k is a positive integer greater than 0; Based on the actual bit rate of the k-th subgroup, determine the quantization parameter values ​​corresponding to each video frame in the k+1-th subgroup; wherein the k+1-th subgroup is the next subgroup of the k-th subgroup in the current image group; The k+1th subgroup is encoded based on the quantization parameter value.

[0140] Although one or more embodiments of this specification provide method operation steps as described in the embodiments or flowcharts, more or fewer operation steps may be included based on conventional or non-creative labor. The order of steps listed in the embodiments is only one way of executing the order of many steps and does not represent the only execution order. When the actual device or client product is executed, it can be executed in the order of the method shown in the embodiments or the drawings or in parallel (for example, in a parallel processor or multi-threaded processing environment).

[0141] Those skilled in the art should understand that the embodiments of this specification may be provided as methods, devices (systems) or computer program products. Therefore, the embodiments of this specification may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, one or more embodiments of this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

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

[0143] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

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

[0145] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device and system embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.

[0146] In this article, relational terms such as first and second, etc. are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. For those of ordinary skill in the art, the specific meaning of the above terms in one or more embodiments of this specification can be understood according to the specific circumstances.

[0147] It should be noted that, in the absence of conflict, one or more embodiments of this specification and the features in the embodiments may be combined with each other. One or more embodiments of this specification are not limited to any single aspect, nor to any single embodiment, nor to any combination and / or replacement of these aspects and / or embodiments. Moreover, each aspect and / or embodiment of one or more embodiments of this specification may be used alone or in combination with one or more other aspects and / or embodiments thereof.

[0148] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of one or more embodiments of this specification, rather than to limit them. Although one or more embodiments of this specification are described in detail with reference to the aforementioned embodiments, a person of ordinary skill in the art should understand that the technical solutions described in the aforementioned embodiments can still be modified, or some or all of the technical features therein can be replaced by equivalents. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of one or more embodiments of this specification, and they should all be included in the scope of one or more embodiments of this specification.

[0149] One or more embodiments of this specification are described above in conjunction with optional implementation methods, but these implementation methods are only exemplary and serve only as an illustration. On this basis, multiple replacements and improvements can be made to one or more embodiments of this specification, all of which fall within the scope of protection of one or more embodiments of this specification.

Claims

1. A video encoding method, characterized in that: The method comprises: After encoding the kth subgroup in the current group of pictures, an actual bit rate of the kth subgroup is determined; wherein the current group of pictures includes a plurality of subgroups, any of which includes at least one video frame; k is a positive integer greater than 0; Based on the actual bit rate of the k-th subgroup, determine the quantization parameter values ​​corresponding to each video frame in the k+1-th subgroup; wherein the k+1-th subgroup is the next subgroup of the k-th subgroup in the current image group; The k+1th subgroup is encoded based on the quantization parameter value.

2. The method according to claim 1, characterized in that The multiple sub-groups are obtained by dividing the current image group according to a preset rule.

3. The method according to claim 2, characterized in that The current group of pictures includes an I frame and a plurality of non-I frames, wherein the I frame is the starting frame of the current group of pictures, and the non-I frames include P frames and B frames; The preset rule includes using I frames and P frames as segmentation frames respectively to divide the current image group into the multiple sub-groups; wherein the sub-group using I frames as segmentation frames includes one I frame, and the sub-group using P frames as segmentation frames includes at least one B frame and one P frame.

4. The method according to claim 1, characterized in that Determining quantization parameter values ​​corresponding to respective video frames in the k+1th subgroup based on the actual bit rate of the kth subgroup includes: Determining a correction parameter for the k+1th subgroup based on an actual bit rate of the kth subgroup; Based on the correction parameter, the quantization parameter value corresponding to each video frame in the k+1th subgroup is determined.

5. The method according to claim 4, characterized in that The determining, based on the actual code rate of the kth subgroup, a correction parameter for the k+1th subgroup comprises: Determine the relationship between the actual bit rate of the kth subgroup and a first bit rate threshold and a second bit rate threshold; wherein the first bit rate threshold is greater than the second bit rate threshold; If the actual bit rate of the k-th subgroup is greater than or equal to the first bit rate threshold, determining that the correction parameter for the k+1-th subgroup is a first correction parameter; wherein the first correction parameter is greater than the correction parameter corresponding to the k-th subgroup; If the actual bit rate of the k-th subgroup is less than or equal to the second bit rate threshold, determining that the correction parameter for the k+1-th subgroup is a second correction parameter; wherein the second correction parameter is greater than the correction parameter corresponding to the k-th subgroup; If the actual bit rate of the kth subgroup is greater than the second bit rate threshold, and the actual bit rate of the kth subgroup is less than the first bit rate threshold, the correction parameter for the k+1th subgroup is determined to be a third correction parameter; the third correction parameter is equal to the correction parameter corresponding to the kth subgroup.

6. The method according to claim 5, characterized in that The third correction parameter is , the first correction parameter is +1, the second correction parameter is -1.

7. The method according to claim 5, characterized in that The first bitrate threshold is calculated based on the maximum bitrate of the current image group, and the second bitrate threshold is calculated based on the minimum bitrate of the current image group.

8. The method according to claim 7, characterized in that The first bit rate threshold is MaxRate×(1+f), and the second bit rate threshold is MinRate×(1-f), wherein MaxRate is the maximum bit rate of the current image group, MinRate is the minimum bit rate of the current image group, f is a preset parameter, and f is greater than zero.

9. The method according to any one of claims 4 to 8, characterized in that: Determining the quantization parameter values ​​corresponding to the respective video frames in the k+1th subgroup based on the correction parameter includes: If the k+1th subgroup includes an I frame, the quantization parameter value corresponding to the I frame in the k+1th subgroup is calculated using the first relational expression; If the k+1th subgroup includes a P frame and a B frame, the quantization parameter value corresponding to the P frame in the k+1th subgroup is calculated using the second relational expression, and the quantization parameter value corresponding to the B frame in the k+1th subgroup is calculated using the third relational expression; Wherein, the first relational expression is: ; The second relation is: ; The third relational expression is: ; in, represents a fixed bit rate factor, Correction parameter corresponding to the k+1th subgroup dq p is the preset parameter corresponding to the P frame, dqp B The preset parameters corresponding to the B frame; The clip function in the first and second equations satisfies the following fourth equation: (a,b,x)= ; Among them, round is the rounding function, C I and Fact I is the preset parameter corresponding to the I frame, C P and Fact P The preset parameters corresponding to the P frame; Cplx cur-I is the complexity corresponding to the current I frame, Cplx cur-P is the complexity corresponding to the current P frame, Cplx base is the baseline complexity; Cplx base The fifth relation is satisfied as follows: in, Indicates the number of blocks in the width of the video frame, Indicates the number of blocks in the video frame height, represents the number of B frames in the k+1th subgroup; q c The following sixth relationship is satisfied:

10. The method according to claim 1, characterized in that The method is applied to a coding device, which adopts a fixed rate factor (CRF) control mode and has a rate limit.

11. A video encoding device, characterized in that: The device comprises: A bit rate determination module, configured to determine an actual bit rate of the kth subgroup after encoding the kth subgroup in the current image group; wherein the current image group includes a plurality of subgroups, any of which includes at least one video frame; and k is a positive integer greater than 0; A quantization parameter determination module, used to determine the quantization parameter values ​​corresponding to each video frame in the k+1th subgroup based on the actual bit rate of the kth subgroup; wherein the k+1th subgroup is the next subgroup of the kth subgroup in the current image group; An encoding module is used to perform encoding processing on the k+1th subgroup based on the quantization parameter value.

12. The device according to claim 11, characterized in that The multiple sub-groups are obtained by dividing the current image group according to a preset rule.

13. The device according to claim 12, characterized in that The current group of pictures includes an I frame and a plurality of non-I frames, wherein the I frame is the starting frame of the current group of pictures, and the non-I frames include P frames and B frames; The preset rule includes using I frames and P frames as segmentation frames respectively to divide the current image group into the multiple sub-groups; wherein the sub-group using I frames as segmentation frames includes one I frame, and the sub-group using P frames as segmentation frames includes at least one B frame and one P frame.

14. The device according to claim 11, characterized in that The quantization parameter determination module is used to determine the quantization parameter values ​​corresponding to each video frame in the k+1th subgroup based on the actual bit rate of the kth subgroup, specifically: The quantization parameter determination module is used to determine the correction parameter for the k+1th subgroup based on the actual bit rate of the kth subgroup; based on the correction parameter, determine the quantization parameter value corresponding to each video frame in the k+1th subgroup.

15. The device according to claim 14, characterized in that The quantization parameter determination module is used to determine the correction parameter for the k+1th subgroup based on the actual bit rate of the kth subgroup, specifically: The quantization parameter determination module is used to determine the size relationship between the actual bit rate of the kth subgroup and the first bit rate threshold and the second bit rate threshold; wherein the first bit rate threshold is greater than the second bit rate threshold; if the actual bit rate of the kth subgroup is greater than or equal to the first bit rate threshold, then determine that the correction parameter for the k+1th subgroup is the first correction parameter; wherein the first correction parameter is greater than the correction parameter corresponding to the kth subgroup; if the actual bit rate of the kth subgroup is less than or equal to the second bit rate threshold, then determine that the correction parameter for the k+1th subgroup is the second correction parameter; wherein the second correction parameter is greater than the correction parameter corresponding to the kth subgroup; if the actual bit rate of the kth subgroup is greater than the second bit rate threshold, and the actual bit rate of the kth subgroup is less than the first bit rate threshold, then determine that the correction parameter for the k+1th subgroup is the third correction parameter; and the third correction parameter is equal to the correction parameter corresponding to the kth subgroup.

16. The device according to claim 15, characterized in that The third correction parameter is , the first correction parameter is +1, the second correction parameter is -1.

17. The device according to claim 15, characterized in that The first bitrate threshold is calculated based on the maximum bitrate of the current image group, and the second bitrate threshold is calculated based on the minimum bitrate of the current image group.

18. The device according to claim 17, characterized in that The first bit rate threshold is MaxRate×(1+f), and the second bit rate threshold is MinRate×(1-f), wherein MaxRate is the maximum bit rate of the current image group, MinRate is the minimum bit rate of the current image group, f is a preset parameter, and f is greater than zero.

19. The device according to any one of claims 14 to 18, characterized in that: The quantization parameter determination module is used to determine the quantization parameter values ​​corresponding to each video frame in the k+1th subgroup based on the correction parameter, specifically: The quantization parameter determination module is used to calculate the quantization parameter value corresponding to the I frame in the k+1th subgroup by using the first relational expression if the k+1th subgroup includes the I frame; If the k+1th subgroup includes a P frame and a B frame, the quantization parameter value corresponding to the P frame in the k+1th subgroup is calculated using the second relational expression, and the quantization parameter value corresponding to the B frame in the k+1th subgroup is calculated using the third relational expression; Wherein, the first relational expression is: ; The second relation is: ; The third relational expression is: ; in, represents a fixed bit rate factor, Correction parameter corresponding to the k+1th subgroup dq p is the preset parameter corresponding to the P frame, dqp B The preset parameters corresponding to the B frame; The clip function in the first and second equations satisfies the following fourth equation: (a,b,x)= ; Among them, round is the rounding function, C I and Fact I is the preset parameter corresponding to the I frame, C P and Fact P The preset parameters corresponding to the P frame; Cplx cur-I is the complexity corresponding to the current I frame, Cplx cur-P is the complexity corresponding to the current P frame, Cplx base is the baseline complexity; Cplx base The fifth relation is satisfied as follows: in, Indicates the number of blocks in the width of the video frame, Indicates the number of blocks in the video frame height, represents the number of B frames in the k+1th subgroup; q c The following sixth relationship is satisfied:

20. The device according to claim 11, characterized in that The device adopts a fixed rate factor CRF control mode and has a rate limit.

21. A coding device, characterized in that: The encoding device comprises: A memory for storing a computer program product; A processor is used to execute the computer program product stored in the memory, and when the computer program product is executed, the method described in any one of claims 1 to 10 is implemented.

22. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer program instructions, which, when executed, implement the method described in any one of claims 1 to 10.

Citation Information

Patent Citations

  • Video code rate processing method and device

    CN107872669A

  • Video frame encoding method and terminal

    CN109413427A

  • Code rate control method and device based on layered B frame and electronic equipment

    CN109862359A

  • Code rate control method and device for video coding

    CN110225343A

  • Image coding method and device, equipment and storage medium

    CN113766226A

Cited By

  • Image frame verification method and device, sending end equipment and storage medium

    CN119363980A

  • Video coding method and device, electronic equipment, storage medium and computer program product

    CN121000871A

  • A video encoding method and apparatus, electronic device, storage medium, and computer program product

    CN121000871B