A video encoding method

By obtaining the target bit rate and number of encoded frames of the target video, calculating the current bit rate budget trend value and frame drop period, the problem of quality, delay and accuracy that cannot be taken into account in video encoding methods is solved, and a stable video encoding effect is achieved.

CN118714320BActive Publication Date: 2025-09-26湖南芒果融创科技有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410795587.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-19
Publication Date
2025-09-26
Estimated Expiration
2044-06-19

AI Technical Summary

Technical Problem

Existing video coding methods have difficulty in striking a balance between quality, delay, and accuracy. Moreover, system performance deteriorates when coding parameters and usage scenarios change, and their versatility is low.

Method used

By obtaining the target bitrate, number of encoded frames, and bitrate budget value of the target video, the current bitrate budget trend value and frame drop period are calculated. Unencoded frames are encoded according to these values ​​to ensure the practicality and stability of the bitrate budget value. A frame drop period is introduced to reduce the encoding output speed and avoid delays.

Benefits of technology

It achieves the goal of improving the accuracy and quality of video encoding while meeting the target bit rate, reducing latency, and ensuring the stability and adaptability of the encoding process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118714320B_ABST
    Figure CN118714320B_ABST
Patent Text Reader

Abstract

The present application relates to the field of video coding technology and provides a video coding method. The video coding method includes: calculating the current bit rate budget value based on the target bit rate and the bit rate budget value at the N-1th moment; calculating the current bit rate budget trend value and the historical bit rate budget trend value based on all bit rate budget values, the current bit rate budget value, the number of all encoded frames and the number of unencoded frames; obtaining the continuous downward trend coefficient and the continuous upward trend coefficient of the bit rate budget value at the current moment based on the current bit rate budget trend value and the historical bit rate budget trend value; obtaining the frame discarding period based on the encoding state of the target video at the N-1th moment, the continuous downward trend coefficient, the continuous upward trend coefficient, and the current bit rate budget value; encoding all unencoded frames in sequence according to the current bit rate budget value and the frame discarding period. The video coding method of the present application can reduce the transmission delay while improving the quality and accuracy of video encoding.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of video encoding technology, and in particular to a video encoding method. Background Art

[0002] Real-time communication (RTC) systems primarily use packet-based transmission protocols to transmit audio and video data. From acquisition at the transmitter to decoding and rendering at the receiver, audio and video data must pass through multiple network nodes, each with its own bandwidth bottleneck. RTC performs real-time link bandwidth estimation when transmitting audio and video data, and uses this bandwidth estimation to control the end-to-end audio and video data volume.

[0003] Rate control for RTC video data transmission typically consists of two parts: rate control during the video encoding process and rate control during video transmission. The main goals of video encoding rate control are to improve encoding quality, reduce latency, and increase encoding rate control accuracy. The characteristics of video encoding technology create conflicting objectives between these goals. In actual engineering applications, customized strategies are often designed by combining multiple factors.

[0004] The technical solution of finely controlling the encoding process to improve encoding accuracy will increase the difference in encoding quality in the spatial domain and the temporal domain, thereby degrading the final encoding quality.

[0005] In technical solutions that fine-tune the encoding process to improve encoding quality, special encoding parameters are usually designed for special types of frames (key frames, motion frames, screen switching frames, etc.). Such designs will produce obvious bit rate peaks when encoding special frames, thereby reducing the accuracy of encoding control.

[0006] At the same time, the more refined the rate control scheme design, the more it balances quality, latency, and accuracy. However, the more deeply it couples with encoder implementations, video encoding protocols, and service scenarios. Changes to encoding parameters, usage scenarios, encoder implementations, and other factors can actually degrade system performance, making the approach very incompatible. This demonstrates that existing video encoding methods struggle to balance quality, latency, and accuracy. Summary of the Invention

[0007] The present application provides a video encoding method that can solve the problem of video encoding quality, delay and accuracy that cannot be taken into account at the same time.

[0008] In a first aspect, an embodiment of the present application provides a video encoding method, the video encoding method comprising:

[0009] Obtain the target bitrate of the target video, the number of coded frames and the bitrate budget at the N-1 moments before the Nth moment, multiple uncoded frames at the Nth moment, and the encoding status at the N-1th moment; the Nth moment is the current moment, the target bitrate is the preset encoding bitrate of the target video, the bitrate budget is the maximum encoding bitrate, the bitrate budget is greater than or equal to the target bitrate, and the encoding status is used to describe the status of the bitrate budget of the target video;

[0010] Calculate the current bitrate budget value at the current moment based on the target bitrate and the bitrate budget value at the N-1th moment;

[0011] Based on the number of coded frames and the bitrate budget value at the previous N-1 moments, the current bitrate budget value, and the number of uncoded frames, calculate the current bitrate budget trend value at the current moment and the historical bitrate budget trend value at the N-1th moment;

[0012] Obtain a continuous downward trend coefficient and a continuous upward trend coefficient of the current rate budget value based on the current rate budget trend value and the historical rate budget trend value. The continuous downward trend coefficient is used to describe the decrease in the rate budget value between the current time and the N-1th time, and the continuous upward trend coefficient is used to describe the increase in the rate budget value between the current time and the N-1th time.

[0013] Based on the encoding state of the target video at the N-1th moment, the continuous downward trend coefficient, the continuous upward trend coefficient, and the current bit rate budget value, the frame discarding period at the current moment is obtained; the frame discarding period is used to describe the interval for discarding unencoded frames;

[0014] All uncoded frames at the current moment are encoded in sequence according to the current bit rate budget value and the frame dropping period.

[0015] Optionally, the current bitrate budget value at the current moment is calculated based on the target bitrate and the bitrate budget value at the N-1th moment, including:

[0016] By formula:

[0017] B N =B N-1 +(T N -T N-1 )×R×RF

[0018] Calculate the current bitrate budget value B at the current moment N ;

[0019] Among them, B N-1 Indicates the bit rate budget value at the N-1th moment, T N Indicates the system time corresponding to the current moment, T N-1represents the system time corresponding to the N-1th moment, R represents the target bit rate, and RF represents the rate control strength coefficient.

[0020] Optionally, based on the number of coded frames and the bitrate budget value at the previous N-1 moments, the current bitrate budget value, and the number of uncoded frames, a current bitrate budget trend value at the current moment and a historical bitrate budget trend value at the N-1th moment are calculated, including:

[0021] Calculate the average bitrate budget based on the bitrate budget values ​​at the previous N-1 moments and the current bitrate budget value;

[0022] Calculate the average number of coded frames based on the number of coded frames and the number of uncoded frames in the previous N-1 moments;

[0023] Calculate the current rate budget trend value at the current moment based on the average rate budget, the average number of coded frames, the number of coded frames and rate budget values ​​at the previous N-1 moments, the current rate budget value, and the number of uncoded frames;

[0024] Calculate the historical rate budget trend value at the N-1th moment based on the rate budget average, the average number of coded frames, the number of coded frames at the previous N-1 moments, and the rate budget value.

[0025] Optionally, the bitrate budget average is calculated based on the bitrate budget values ​​at the previous N-1 moments and the current bitrate budget value, including:

[0026] By formula:

[0027]

[0028] Calculate the bitrate budget average value B avg ;

[0029] Among them, B t Indicates the code rate budget value at the tth moment. When t=N, B N Represents the current bitrate budget value, and N represents the current moment;

[0030] The average number of coded frames is calculated based on the number of coded frames and the number of uncoded frames in the previous N-1 moments, including:

[0031] By formula:

[0032]

[0033] Calculate the average number of coded frames C avg ;

[0034] Among them, C t Indicates the number of coded frames at the tth moment. When t=N, C N Indicates the number of uncoded frames.

[0035] Optionally, the current rate budget trend value at the current moment is calculated based on the rate budget average, the average number of coded frames, the number of coded frames and the rate budget value at the previous N-1 moments, the current rate budget value, and the number of uncoded frames, including:

[0036] By formula:

[0037]

[0038] Calculate the current bitrate budget trend value Q at the current moment N ;

[0039] Calculate the historical bitrate budget trend value at the N-1th moment based on the bitrate budget average, the average number of coded frames, the number of coded frames at the previous N-1 moments, and the bitrate budget value, including:

[0040] By formula:

[0041]

[0042] Calculate the historical bitrate budget trend value Q at the N-1th moment N-1 .

[0043] Optionally, based on the current bitrate budget trend value and the historical bitrate budget trend value, a continuous downward trend coefficient and a continuous upward trend coefficient of the bitrate budget value at the current moment are obtained, including:

[0044] If the historical bitrate budget trend value is less than -Q th , and the current bitrate budget trend value is less than -Q th , then the continuous downward trend coefficient at the current moment is set to the continuous downward trend coefficient at the N-1th moment plus 1, and the continuous upward trend coefficient at the current moment is set to 0; where Q th Indicates the bitrate budget trend threshold;

[0045] If the historical bitrate budget trend value is greater than Q th , and the current bitrate budget trend value is greater than Q th , then the continuous rising trend coefficient at the current moment is set to the continuous rising trend coefficient at the N-1th moment plus 1, and the continuous falling trend coefficient at the current moment is set to 0;

[0046] If the historical bitrate budget trend value is less than -Q th , and the current bitrate budget trend value is greater than Q th , then the continuous downward trend coefficient and the continuous upward trend coefficient at the current moment are both set to 0;

[0047] If the historical bitrate budget trend value is greater than Q th, and the current bitrate budget trend value is less than -Q th , then the continuous downward trend coefficient and the continuous upward trend coefficient at the current moment are both set to 0.

[0048] Optionally, the coding state is one of a budget sufficient state, a budget decreasing state, a budget increasing state, and a budget deficit state;

[0049] The frame dropping period at the current moment is obtained based on the encoding state, the continuous decreasing trend coefficient, the continuous increasing trend coefficient, and the current bitrate budget value of the target video at the N-1th moment, including:

[0050] When the encoding state of the target video at the N-1th moment is a sufficient budget state, if the continuous decreasing trend coefficient at the current moment is greater than or equal to the decreasing coefficient threshold, the encoding state of the target video at the current moment is a decreasing budget state, the frame dropping period is set to the frame dropping period upper limit value, and the continuous decreasing trend coefficient is set to 0;

[0051] If the continuous downward trend coefficient at the current moment is less than the downward coefficient threshold, the encoding state of the target video at the current moment is a sufficient budget state, and the frame dropping period is the frame dropping period at the N-1th moment.

[0052] Optionally, obtaining a frame dropping period at a current moment based on the encoding state, the continuous decreasing trend coefficient, the continuous increasing trend coefficient, and the current bitrate budget value of the target video at the N-1th moment also includes:

[0053] When the encoding state of the target video at time N-1 is in the budget reduction state, if the bitrate budget value at the current moment is greater than the bitrate budget lower limit, the encoding state of the target video at the current moment is in the budget reduction state, and the frame dropping period is set to the frame dropping period upper limit minus one;

[0054] If the continuous rising trend coefficient at the current moment is greater than or equal to the rising coefficient threshold, the encoding state of the target video at the current moment is the budget rising state, the continuous rising trend coefficient is set to 0, and it is determined whether the frame dropping period at the N-1th moment is less than the frame dropping period upper limit. If so, the frame dropping period is set to the frame dropping period at the N-1th moment plus 1; otherwise, the frame dropping period is set to the frame dropping period upper limit.

[0055] If the bitrate budget value at the current moment is less than or equal to the bitrate budget lower limit, the encoding state of the target video at the current moment is a budget deficit state. It is determined whether the frame drop period at the N-1th moment is greater than the frame drop period lower limit. If so, the frame drop period is set to the frame drop period at the N-1th moment minus 1; otherwise, the frame drop period is set to the frame drop period lower limit.

[0056] Optionally, obtaining a frame dropping period at a current moment based on the encoding state, the continuous decreasing trend coefficient, the continuous increasing trend coefficient, and the current bitrate budget value of the target video at the N-1th moment also includes:

[0057] When the encoding state of the target video at the N-1th moment is the budget increasing state, if the bitrate budget value at the current moment is less than the bitrate budget upper limit value, the encoding state of the target video at the current moment is the budget increasing state, and it is determined whether the frame dropping period at the N-1th moment is less than the frame dropping period upper limit value. If so, the frame dropping period is set to the frame dropping period at the N-1th moment plus 1; otherwise, the frame dropping period is set to the frame dropping period upper limit value;

[0058] If the current bitrate budget is greater than or equal to the bitrate budget upper limit, the encoding state of the target video at the current moment is sufficient budget, and the frame drop period is 0;

[0059] If the continuous downward trend coefficient at the current moment is greater than or equal to the downward coefficient threshold, the encoding state of the target video at the current moment is the budget reduction state, the continuous downward trend coefficient is set to 0, and the frame dropping period is the frame dropping period at the N-1th moment.

[0060] Optionally, obtaining a frame dropping period at a current moment based on the encoding state, the continuous decreasing trend coefficient, the continuous increasing trend coefficient, and the current bitrate budget value of the target video at the N-1th moment also includes:

[0061] When the encoding state of the target video at the N-1th moment is a budget deficit state, if the continuous rising trend coefficient at the current moment is less than the rising coefficient threshold, the encoding state of the target video at the current moment is a budget deficit state, and it is determined whether the frame dropping period at the N-1th moment is greater than the frame dropping period lower limit. If so, the frame dropping period is set to the frame dropping period at the N-1th moment minus 1; otherwise, the frame dropping period is set to the frame dropping period lower limit.

[0062] If the continuous rising trend coefficient at the current moment is greater than or equal to the rising coefficient threshold, the encoding state of the target video at the current moment is the budget rising state, and it is determined whether the frame dropping period at the N-1th moment is less than the upper limit of the frame dropping period. If so, the frame dropping period is set to the frame dropping period at the N-1th moment plus 1; otherwise, the frame dropping period is set to the upper limit of the frame dropping period.

[0063] In a second aspect, an embodiment of the present application provides a video encoding device, including:

[0064] A first acquisition module acquires a target bit rate of a target video, the number of encoded frames and the bit rate budget at the N-1 moments before the Nth moment, multiple unencoded frames at the Nth moment, and an encoding status at the N-1th moment; the Nth moment is the current moment, the target bit rate is a preset encoding bit rate of the target video, the bit rate budget is a maximum encoding bit rate, the bit rate budget is greater than or equal to the target bit rate, and the encoding status is used to describe the status of the bit rate budget of the target video;

[0065] A first calculation module calculates a current bit rate budget value at a current moment according to a target bit rate and a bit rate budget value at the N-1th moment;

[0066] A second calculation module calculates a current rate budget trend value at the current moment and a historical rate budget trend value at the N-1th moment based on the number of coded frames and the rate budget value at the previous N-1 moments, the current rate budget value, and the number of uncoded frames;

[0067] The second acquisition module acquires a continuous downward trend coefficient and a continuous upward trend coefficient of the bitrate budget value at the current moment based on the current bitrate budget trend value and the historical bitrate budget trend value; the continuous downward trend coefficient is used to describe the decrease in the bitrate budget value between the current moment and the N-1th moment, and the continuous upward trend coefficient is used to describe the increase in the bitrate budget value between the current moment and the N-1th moment;

[0068] The frame discarding period acquisition module obtains the current frame discarding period based on the encoding state of the target video at the N-1th time, the continuous downward trend coefficient, the continuous upward trend coefficient, and the current bit rate budget value; the frame discarding period is used to describe the interval for discarding unencoded frames;

[0069] The encoding module encodes all unencoded frames at the current moment in sequence according to the current bit rate budget value and the frame dropping period.

[0070] In a third aspect, an embodiment of the present application provides a terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned video encoding method when executing the above-mentioned computer program.

[0071] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, implements the above-mentioned video encoding method.

[0072] The above solution of the present application has the following beneficial effects:

[0073] In an embodiment of the present application, a target bit rate of a target video, the number of coded frames and the rate budget value at the N-1th moment before the Nth moment, multiple uncoded frames at the Nth moment, and the coding state at the N-1th moment are obtained. Then, a current rate budget value at the current moment is calculated based on the target bit rate and the rate budget value at the N-1th moment. Then, a current rate budget trend value at the current moment and a historical rate budget trend value at the N-1th moment are calculated based on the number of coded frames and the rate budget value at the N-1th moment before the N-1th moment, the current rate budget value, and the number of uncoded frames. Then, based on the current rate budget trend value and the historical rate budget trend value, a continuous decreasing trend coefficient and a continuous increasing trend coefficient of the rate budget value at the current moment are obtained. Then, based on the coding state, the continuous decreasing trend coefficient, the continuous increasing trend coefficient, and the current rate budget value of the target video at the N-1th moment, a frame dropping period at the current moment is obtained. Finally, all uncoded frames at the current moment are encoded sequentially according to the current rate budget value and the frame dropping period. Among them, the bit rate budget value is calculated based on the target bit rate, and the actual bit rate target of the target video is taken into consideration, so that the bit rate budget value is practical. The subsequent video encoding steps are performed according to the practical bit rate budget value, which can ensure the accuracy of video encoding. At the same time, using the bit rate budget value for video encoding can reserve a spare budget while meeting the target bit rate, which is convenient for special processing of special unencoded frames, improving the quality and stability of video encoding, and introducing a frame discarding period for video encoding, so that the number of unencoded frames encoded at the current moment is reduced, the output speed of encoding is reduced, and the situation of output congestion caused by too fast encoding is avoided, thereby reducing delay.

[0074] Other beneficial effects of the present application will be described in detail in the subsequent specific implementation section. BRIEF DESCRIPTION OF THE DRAWINGS

[0075] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments or descriptions of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0076] Figure 1 A flowchart of a video encoding method provided in one embodiment of the present application;

[0077] Figure 2 A schematic diagram of an encoding state provided in an embodiment of the present application;

[0078] Figure 3 A quantization parameter curve diagram provided in an embodiment of the present application;

[0079] Figure 4A transmission delay curve diagram provided in an embodiment of the present application;

[0080] Figure 5 This is a coding rate curve diagram provided by an embodiment of the present application;

[0081] Figure 6 A bit rate budget curve diagram provided in an embodiment of the present application;

[0082] Figure 7 This is a graph showing an encoder input skip rate according to an embodiment of the present application;

[0083] Figure 8 A schematic diagram of the structure of a video encoding device provided in one embodiment of the present application;

[0084] Figure 9 A schematic diagram of the structure of a terminal device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0085] In the following description, specific details such as specific system structures and techniques are provided for purposes of illustration rather than limitation to facilitate a thorough understanding of the embodiments of the present application. However, it will be apparent to those skilled in the art that the present application may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to avoid obscuring the description of the present application with unnecessary detail.

[0086] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or collections thereof.

[0087] It will also be understood that the term "and / or" used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.

[0088] As used in this specification and the appended claims, the term "if" can be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]," depending on the context.

[0089] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.

[0090] References to "one embodiment" or "some embodiments" in this specification mean that a particular feature, structure, or characteristic described in conjunction with that embodiment is included in one or more embodiments of the present application. Thus, phrases such as "in one embodiment," "in some embodiments," "in other embodiments," and "in other embodiments" appearing in various places in this specification do not necessarily refer to the same embodiment, but rather mean "one or more but not all embodiments," unless otherwise specifically emphasized. The terms "including," "comprising," "having," and variations thereof all mean "including but not limited to," unless otherwise specifically emphasized.

[0091] In order to solve the problem that the quality, delay and accuracy of video encoding cannot be taken into account at the same time, an embodiment of the present application provides a video encoding method, which obtains the target bit rate of the target video, the number of encoded frames and the bit rate budget value at the N-1 moments before the Nth moment, multiple unencoded frames at the Nth moment, and the encoding state at the N-1th moment, and then calculates the current bit rate budget value at the current moment based on the target bit rate and the bit rate budget value at the N-1th moment, and then calculates the current bit rate budget value based on the number of encoded frames and the bit rate budget value at the N-1 moments before the Nth moment, the current bit rate budget value and the unencoded frames. , calculate the current rate budget trend value at the current moment and the historical rate budget trend value at the N-1th moment, then obtain the continuous downward trend coefficient and the continuous upward trend coefficient of the rate budget value at the current moment based on the current rate budget trend value and the historical rate budget trend value, then obtain the frame dropping period at the current moment based on the encoding state of the target video at the N-1th moment, the continuous downward trend coefficient, the continuous upward trend coefficient, and the current rate budget value, finally encode all unencoded frames at the current moment in sequence according to the current rate budget value and the frame dropping period. Among them, the bit rate budget value is calculated based on the target bit rate, and the actual bit rate target of the target video is taken into consideration, so that the bit rate budget value is practical. The subsequent video encoding steps are performed according to the practical bit rate budget value, which can ensure the accuracy of video encoding. At the same time, using the bit rate budget value for video encoding can reserve a spare budget while meeting the target bit rate, which is convenient for special processing of special unencoded frames, improving the quality and stability of video encoding, and introducing a frame discarding period for video encoding, so that the number of unencoded frames encoded at the current moment is reduced, the output speed of encoding is reduced, and the situation of output congestion caused by too fast encoding is avoided, thereby reducing delay.

[0092] Next, the video encoding method provided in this application is described exemplarily.

[0093] like Figure 1 As shown, the video encoding method provided by this application includes the following steps:

[0094] Step 11: Obtain the target bit rate of the target video, the number of coded frames and the bit rate budget at the Nth moment before the Nth moment, multiple uncoded frames at the Nth moment, and the coding status at the Nth moment.

[0095] The Nth moment is the current moment, the above-mentioned target bit rate is the preset encoding bit rate of the target video, the bit rate budget value is the maximum value of the amount of information corresponding to the encoding bit rate, and the bit rate budget value is greater than or equal to the value of the information amount corresponding to the target bit rate multiplied by RF. For example, the value of the target bit rate multiplied by RF is 20, and the bit rate budget value can be 25. The encoding status is used to describe the status of the bit rate budget value of the target video.

[0096] It should be noted that the target video is the video to be encoded, the Nth moment may be the 5th moment, and the N-1 moments before the Nth moment are the 1st moment, the 2nd moment, the 3rd moment, and the 4th moment respectively.

[0097] In some embodiments of the present application, video encoders such as H264 and AV1 can be used to obtain the number of encoded frames (i.e., the number of encoded frames) and the bit rate budget value of the target video at the N-1 moment before the Nth moment, multiple unencoded frames at the Nth moment, and the encoding status at the N-1th moment. The target bit rate can be preset according to the bit rate requirements of the target video.

[0098] Step 12: Calculate the current bit rate budget value at the current moment according to the target bit rate and the bit rate budget value at the N-1th moment.

[0099] Specifically, through the formula:

[0100] B N =B N-1 +(T N -T N-1 )×R×RF

[0101] Calculate the current bitrate budget value B at the current moment N .

[0102] Among them, B N-1 Indicates the bit rate budget value at the N-1th moment, T N Indicates the system time corresponding to the current moment, T N-1 Indicates the system time corresponding to the N-1th moment, R represents the target bit rate, and RF represents the rate control strength coefficient, which can be a value from 1 to 1.33.

[0103] For example, the above formula can be run using mathematical calculation computer software such as Mathematica to obtain the current bit rate budget value.

[0104] It is worth mentioning that in order to ensure that special situations can be adapted while meeting the target bit rate (such as a frame being a key frame, a still switching motion frame, a screen switching frame, and other special frames that require a high encoding bit rate), a bit rate budget value slightly larger than the value obtained by multiplying the amount of information corresponding to the target bit rate by RF is calculated, which can improve the stability of encoding the target video.

[0105] Step 13: Calculate the current rate budget trend value at the current moment and the historical rate budget trend value at the N-1th moment based on the number of coded frames and the rate budget value at the previous N-1 moments, the current rate budget value, and the number of uncoded frames.

[0106] The above-mentioned bitrate budget trend value is used to describe the change of the bitrate budget value over a period of time.

[0107] In some embodiments of the present application, the current rate budget trend value at the current moment and the historical rate budget trend value at the N-1th moment are calculated based on the number of coded frames and the rate budget value at the previous N-1 moments, the current rate budget value, and the number of uncoded frames as follows:

[0108] In the first step, the average bitrate budget is calculated based on the bitrate budget values ​​at the previous N-1 moments and the current bitrate budget value.

[0109] By formula:

[0110]

[0111] Calculate the bitrate budget average value B avg .

[0112] Among them, B t Indicates the code rate budget value at the tth moment. When t=N, B N Represents the current bitrate budget value, and N represents the current time.

[0113] In the second step, the average number of coded frames is calculated based on the number of coded frames and the number of uncoded frames in the previous N-1 moments.

[0114] By formula:

[0115]

[0116] Calculate the average number of coded frames C avg .

[0117] Among them, C t Indicates the number of coded frames at the tth moment. When t=N, CN Indicates the number of uncoded frames.

[0118] The third step is to calculate the current rate budget trend value at the current moment based on the rate budget average, the average number of coded frames, the number of coded frames and rate budget value at the previous N-1 moments, the current rate budget value, and the number of uncoded frames.

[0119] By formula:

[0120]

[0121] Calculate the current bitrate budget trend value Q at the current moment N .

[0122] The fourth step is to calculate the historical bitrate budget trend value at the N-1th moment based on the bitrate budget average value, the average number of coded frames, the number of coded frames at the previous N-1 moments, and the bitrate budget value.

[0123] Specifically, through the formula:

[0124]

[0125] Calculate the historical bitrate budget trend value Q at the N-1th moment N-1 .

[0126] It should be noted that the rate budget trend value can be compared with the rate budget trend threshold to analyze the change of the rate budget value over a period of time, and the larger the absolute value of the rate budget trend value, the greater the change in the rate budget value.

[0127] For example, the current bitrate budget trend value is 3, which is greater than the bitrate budget trend value threshold of 2, indicating that the bitrate budget value shows an increasing trend in the time period from the first moment to the current moment. If the bitrate budget trend value is -3, which is less than -2, it indicates that the bitrate budget value shows a decreasing trend in this time period.

[0128] It is worth mentioning that by calculating the current bitrate budget trend value and the historical bitrate budget trend value, the changes in the bitrate budget value in the time period from the first moment to the current moment and in the time period from the first moment to the N-1th moment can be analyzed.

[0129] Step 14: Obtain a continuous decreasing trend coefficient and a continuous increasing trend coefficient of the bit rate budget value at the current moment according to the current bit rate budget trend value and the historical bit rate budget trend values.

[0130] The continuous downward trend coefficient is used to describe the decrease in the bit rate budget between the current moment and the N-1th moment, and the continuous upward trend coefficient is used to describe the increase in the bit rate budget between the current moment and the N-1th moment.

[0131] Specifically, if the historical bitrate budget trend value is less than -Q th , and the current bitrate budget trend value is less than -Q th , then the continuous downward trend coefficient at the current moment is set to the continuous downward trend coefficient at the N-1th moment plus 1, and the continuous upward trend coefficient at the current moment is set to 0. th Indicates the bitrate budget trend threshold.

[0132] If the historical bitrate budget trend value is greater than Q th , and the current bitrate budget trend value is greater than Q th , then the continuous rising trend coefficient at the current moment is set to the continuous rising trend coefficient at the N-1th moment plus 1, and the continuous falling trend coefficient at the current moment is set to 0.

[0133] If the historical bitrate budget trend value is less than -Q th , and the current bitrate budget trend value is greater than Q th , then the continuous downward trend coefficient and the continuous upward trend coefficient at the current moment are both set to 0.

[0134] If the historical bitrate budget trend value is greater than Q th , and the current bitrate budget trend value is less than -Q th , then the continuous downward trend coefficient and the continuous upward trend coefficient at the current moment are both set to 0.

[0135] Exemplarily, the continuous downward trend coefficient at the N-1th moment is 1, and the continuous upward trend coefficient at the N-1th moment is 3. If the historical rate budget trend value and the current rate budget trend value are both less than the negative value of the rate budget trend threshold 5, then the continuous downward trend coefficient at the current moment is 2, and the continuous upward trend coefficient is 0; if the historical rate budget trend value and the current rate budget trend value are both greater than 5, then the continuous upward trend coefficient at the current moment is 4, and the continuous downward trend coefficient is 0; if the historical rate budget trend value is less than -5, and the current rate budget trend value is greater than 5, then the continuous downward trend coefficient and the continuous upward trend coefficient at the current moment are both 0; if the historical rate budget trend value is greater than 5, and the current rate budget trend value is less than -5, then the continuous downward trend coefficient and the continuous upward trend coefficient at the current moment are both 0.

[0136] It is worth mentioning that by obtaining the continuous downward trend coefficient and the continuous upward trend coefficient at the current moment, the rising and falling conditions of the bit rate budget value can be described, providing the change information of the bit rate budget value for subsequent steps.

[0137] Step 15: Obtain a frame dropping period at the current moment based on the encoding state of the target video at the N-1th moment, the continuous decreasing trend coefficient, the continuous increasing trend coefficient, and the current bit rate budget value.

[0138] The frame dropping period describes the interval at which unencoded frames are discarded. For example, if the frame dropping period is 5, one unencoded frame is discarded for every five unencoded frames during the encoding process. The encoding status is one of the following: sufficient budget, decreasing budget, increasing budget, or insufficient budget. The sufficient budget indicates that the bitrate budget is stable and can meet the encoding requirements of the target video; the decreasing budget indicates that the bitrate budget is decreasing; the increasing budget indicates that the bitrate budget is increasing; and the insufficient budget indicates that the bitrate budget is less than the lower limit of the bitrate budget.

[0139] It should be noted that, before the target video starts to be encoded, the encoding state of the target video is recorded as the startup state. At this time, each unencoded frame of the target video is loaded in sequence. When the number of loaded unencoded frames reaches the unencoded frame number threshold, the budget is sufficient state is entered, and the target video is started to be encoded. At this time, the frame discarding period is set to 0, indicating that the unencoded frames are not discarded, and the continuous rising trend coefficient and the continuous falling trend coefficient are both set to 0. That is, when the target video is encoded, the initial values ​​of the frame discarding period, the continuous rising trend coefficient, and the continuous falling trend coefficient are all 0.

[0140] In some embodiments of the present application, the step of obtaining the frame dropping period at the current moment based on the encoding state, the continuous decreasing trend coefficient, the continuous increasing trend coefficient, and the current bitrate budget value of the target video at the N-1th moment includes:

[0141] When the encoding state of the target video at the N-1th moment is a sufficient budget state, if the continuous downward trend coefficient at the current moment is greater than or equal to the downward coefficient threshold, the encoding state of the target video at the current moment is a downward budget state, the frame discarding period is set to the upper limit value of the frame discarding period, and the continuous downward trend coefficient is set to 0.

[0142] If the continuous downward trend coefficient at the current moment is less than the downward coefficient threshold, the encoding state of the target video at the current moment is a sufficient budget state, and the frame dropping period is the frame dropping period at the N-1th moment.

[0143] When the encoding state of the target video at the N-1th moment is the budget reduction state, if the bitrate budget value at the current moment is greater than the bitrate budget lower limit value, the encoding state of the target video at the current moment is the budget reduction state, and the frame dropping period is set to the frame dropping period upper limit value minus one.

[0144] If the continuous rising trend coefficient at the current moment is greater than or equal to the rising coefficient threshold, the encoding state of the target video at the current moment is the budget rising state, the continuous rising trend coefficient is set to 0, and it is determined whether the frame discarding period at the N-1th moment is less than the upper limit of the frame discarding period. If so, the frame discarding period is set to the frame discarding period at the N-1th moment plus 1, otherwise, the frame discarding period is set to the upper limit of the frame discarding period.

[0145] If the bitrate budget value at the current moment is less than or equal to the bitrate budget lower limit, the encoding state of the target video at the current moment is a budget deficit state. It is determined whether the frame drop period at the N-1th moment is greater than the frame drop period lower limit. If so, the frame drop period is set to the frame drop period at the N-1th moment minus 1; otherwise, the frame drop period is set to the frame drop period lower limit.

[0146] When the encoding state of the target video at the N-1th moment is the budget-increasing state, if the bitrate budget value at the current moment is less than the bitrate budget upper limit value, the encoding state of the target video at the current moment is the budget-increasing state, and it is determined whether the frame drop period at the N-1th moment is less than the frame drop period upper limit value. If so, the frame drop period is set to the frame drop period at the N-1th moment plus 1; otherwise, the frame drop period is set to the frame drop period upper limit value.

[0147] If the bitrate budget value at the current moment is greater than or equal to the bitrate budget upper limit value, the encoding state of the target video at the current moment is a sufficient budget state, and the frame dropping period is 0.

[0148] If the continuous downward trend coefficient at the current moment is greater than or equal to the downward coefficient threshold, the encoding state of the target video at the current moment is the budget reduction state, the continuous downward trend coefficient is set to 0, and the frame dropping period is the frame dropping period at the N-1th moment.

[0149] When the encoding state of the target video at the N-1th moment is a budget deficit state, if the continuous rising trend coefficient at the current moment is less than the rising coefficient threshold, the encoding state of the target video at the current moment is a budget deficit state, and it is determined whether the frame drop period at the N-1th moment is greater than the lower limit of the frame drop period. If so, the frame drop period is set to the frame drop period at the N-1th moment minus 1; otherwise, the frame drop period is set to the lower limit of the frame drop period.

[0150] If the continuous rising trend coefficient at the current moment is greater than or equal to the rising coefficient threshold, the encoding state of the target video at the current moment is the budget rising state, and it is determined whether the frame dropping period at the N-1th moment is less than the upper limit of the frame dropping period. If so, the frame dropping period is set to the frame dropping period at the N-1th moment plus 1; otherwise, the frame dropping period is set to the upper limit of the frame dropping period.

[0151] Exemplarily, before encoding the target video, it is in a startup state, which can be recorded as the 0th moment. When the startup state changes to a sufficient budget state, encoding of the target video begins, which is recorded as the 1st moment. At the 1st moment, multiple unencoded frames of the target video are encoded, and the encoding state and frame discarding period of the second moment are obtained according to the above steps. At the second moment, multiple unencoded frames are encoded according to the frame discarding period, and so on, until the encoding of the target video is completed.

[0152] It should be noted that in the above steps, after obtaining the encoding status of the target video at the current moment, the continuous rising trend coefficient or the continuous falling trend coefficient is set to 0 in order to facilitate the calculation of the continuous rising trend coefficient or the continuous falling trend coefficient at the next moment after the current moment.

[0153] It is worth mentioning that the encoding status at the current moment and the frame drop period are obtained based on the encoding status of the target video at the previous moment, the continuous downward trend coefficient, the continuous upward trend coefficient, and the current bit rate budget value. The encoding status at the previous moment, the changing trend of the encoding budget value, and the value of the encoding budget value are taken into consideration, so that the accuracy of the frame drop period is improved.

[0154] The above encoding state is exemplarily described below with reference to a specific example.

[0155] like Figure 2 As shown, the target video enters the budget sufficient state after the startup phase (i.e., the startup state mentioned above) ends. The budget sufficient state can be switched to the budget decreasing state and the budget sufficient state. The budget decreasing state can be switched to the budget deficit state, the budget increasing state, and the budget decreasing state. The budget deficit state can be switched to the budget increasing state and the budget deficit state. The budget increasing state can be switched to the budget sufficient state, the budget decreasing state, and the budget increasing state. The line with an arrow in the figure indicates the state switching direction.

[0156] Step 16: Encode all unencoded frames at the current moment in sequence according to the current bit rate budget value and the frame discarding period.

[0157] Specifically, all uncoded frames are discarded according to the frame discard period, and each uncoded frame that is not discarded is encoded in turn according to the target bit rate. If the uncoded frame is a special frame, the uncoded frame is not discarded, and the encoding bit rate parameters of the uncoded frame are adjusted without exceeding the current bit rate budget value to improve the clarity of the special frame.

[0158] It should be noted that after encoding all uncoded frames at the current moment, the average encoding bitrate of all encoded uncoded frames is calculated. This average is then subtracted from the current bitrate budget to determine the current bitrate budget, facilitating the calculation of the next bitrate budget. If the transmitted rate of coded frames is lower than the encoding rate, encoding video based on the frame drop period can reduce the number of uncoded frames to be encoded, allowing coded frames to be drained as quickly as possible to prevent congestion.

[0159] It is worth mentioning that the bit rate budget value is calculated based on the target bit rate, and the actual bit rate target of the target video is taken into account, so that the bit rate budget value is practical. The subsequent video encoding steps are performed according to the practical bit rate budget value, which can ensure the accuracy of video encoding. At the same time, using the bit rate budget value for video encoding can reserve a spare budget while meeting the target bit rate, which is convenient for special processing of special unencoded frames, improving the quality and stability of video encoding, and introducing a frame discarding period for video encoding, so that the number of unencoded frames encoded at the current moment is reduced, the output speed of encoding is reduced, and the situation of output congestion caused by too fast encoding is avoided, thereby reducing delay.

[0160] The video encoding method of the present application is exemplarily described below with reference to a specific example.

[0161] A video is encoded using the video encoding method of the present application.

[0162] In terms of coding quality, the quantization parameter QP curve in the encoding process is as follows Figure 3 As shown in the figure, the horizontal axis represents time, the vertical axis represents the QP value, the dotted line with diamonds represents the maximum coding QP change curve, the solid line with diamonds represents the average coding QP change curve, and the solid line with triangles represents the minimum coding QP change curve.

[0163] In terms of delay, the sending delay curve is as follows Figure 4 As shown in the figure, the horizontal axis represents time, the vertical axis represents the transmission delay, the unit is milliseconds (ms), the solid line with triangles is the transmission delay change curve; the coding rate change curve is as shown in Figure 5 As shown in the figure, the horizontal axis represents time, the vertical axis represents bit rate, and the unit is kilobits per second (kbps). The curve with triangles represents the change curve of bit rate water level, the curve with diamonds represents the change curve of actual bit rate, and the dotted line with diamonds represents the change curve of coding parameters.

[0164] Figure 3 In the video, between 17:22:35 and 17:22:40, the encoding QP is limited to 43 to ensure the minimum clarity of the target video after encoding. Figure 4 and Figure 5 In the process, the encoding bit rate drops rapidly in a short time, and a large transmission delay occurs at the sending end. The video encoding method of the present application can quickly reduce the transmission delay to below 30ms in a short time.

[0165] The bitrate budget changes as follows Figure 6 As shown in the figure, the horizontal axis represents time, the vertical axis represents the bit rate budget, the solid line with triangles represents the change curve of the real-time bit rate budget, the solid line with diamonds represents the change curve of the minimum bit rate budget, and the encoder input skip rate (i.e., the frame drop period mentioned above) is shown as Figure 7 As shown in the figure, the horizontal axis represents time, the vertical axis represents frame rate, and the unit is frames per second. The solid line with triangles represents the frame rate change curve, and the solid line with dots represents the frame skipping rate.

[0166] It can be seen that the video encoding method of the present application can improve the accuracy of video encoding while ensuring the quality of video encoding, while reducing the transmission delay of the sending end.

[0167] The video encoding device provided in this application is exemplarily described below.

[0168] like Figure 8 As shown, an embodiment of the present application provides a video encoding device, and the video encoding device 800 includes:

[0169] A first acquisition module 801 acquires a target bit rate of a target video, the number of coded frames and the bit rate budget at the N-1 moments before the Nth moment, a plurality of uncoded frames at the Nth moment, and an encoding status at the N-1th moment. The Nth moment is the current moment, the target bit rate is a preset encoding bit rate of the target video, the bit rate budget is a maximum encoding bit rate, the bit rate budget is greater than or equal to the target bit rate, and the encoding status is used to describe the status of the bit rate budget of the target video.

[0170] A first calculation module 802 calculates a current bit rate budget value at a current moment according to a target bit rate and a bit rate budget value at the N-1th moment;

[0171] A second calculation module 803 calculates a current rate budget trend value at the current moment and a historical rate budget trend value at the N-1th moment based on the number of coded frames and the rate budget value at the previous N-1 moments, the current rate budget value, and the number of uncoded frames;

[0172] The second acquisition module 804 acquires a continuous downward trend coefficient and a continuous upward trend coefficient of the rate budget value at the current moment based on the current rate budget trend value and the historical rate budget trend values. The continuous downward trend coefficient is used to describe the decrease in the rate budget value between the current moment and the N-1th moment, and the continuous upward trend coefficient is used to describe the increase in the rate budget value between the current moment and the N-1th moment.

[0173] The frame discarding period obtaining module 805 obtains the frame discarding period at the current moment based on the encoding state of the target video at the N-1th moment, the continuous decreasing trend coefficient, the continuous increasing trend coefficient, and the current bit rate budget value. The frame discarding period is used to describe the interval for discarding unencoded frames.

[0174] The encoding module 806 encodes all unencoded frames at the current moment in sequence according to the current bit rate budget value and the frame dropping period.

[0175] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of this application. Their specific functions and technical effects can be found in the method embodiment section and will not be repeated here.

[0176] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.

[0177] like Figure 9 As shown, an embodiment of the present application provides a terminal device, and the terminal device D10 of this embodiment includes: at least one processor D100 ( Figure 9 Only one processor is shown in the figure), a memory D101, and a computer program D102 stored in the memory D101 and executable on the at least one processor D100, wherein the processor D100 implements the steps of any of the above method embodiments when executing the computer program D102.

[0178] Specifically, when the processor D100 executes the computer program D102, it obtains the target bit rate of the target video, the number of coded frames and the bit rate budget value at the N-1 moments before the Nth moment, multiple uncoded frames at the Nth moment, and the coding state at the N-1th moment, and then calculates the current bit rate budget value at the current moment based on the target bit rate and the bit rate budget value at the N-1th moment, and then calculates the current bit rate budget trend value at the current moment and the historical bit rate budget trend value at the N-1th moment based on the number of coded frames and the bit rate budget value at the N-1 moments before the current moment, the current bit rate budget value, and the number of uncoded frames, and then obtains the continuous downward trend coefficient and the continuous upward trend coefficient of the bit rate budget value at the current moment based on the current bit rate budget trend value and the historical bit rate budget trend value, and then obtains the frame dropping period at the current moment based on the coding state, continuous downward trend coefficient, continuous upward trend coefficient, and current bit rate budget value of the target video at the N-1th moment, and finally encodes all uncoded frames at the current moment in sequence according to the current bit rate budget value and the frame dropping period. Among them, the bit rate budget value is calculated based on the target bit rate, and the actual bit rate target of the target video is taken into consideration, so that the bit rate budget value is practical. The subsequent video encoding steps are performed according to the practical bit rate budget value, which can ensure the accuracy of video encoding. At the same time, using the bit rate budget value for video encoding can reserve a spare budget while meeting the target bit rate, which is convenient for special processing of special unencoded frames, improving the quality and stability of video encoding, and introducing a frame discarding period for video encoding, so that the number of unencoded frames encoded at the current moment is reduced, the output speed of encoding is reduced, and the situation of output congestion caused by too fast encoding is avoided, thereby reducing delay.

[0179] The processor D100 may be a central processing unit (CPU), or may be another general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. A general-purpose processor may be a microprocessor or any conventional processor.

[0180] In some embodiments, the memory D101 may be an internal storage unit of the terminal device D10, such as a hard disk or memory of the terminal device D10. In other embodiments, the memory D101 may also be an external storage device of the terminal device D10, such as a plug-in hard disk, a smart memory card (SMC, SmartMedia Card), a secure digital (SD, Secure Digital) card, a flash card, etc. equipped on the terminal device D10. Furthermore, the memory D101 may also include both an internal storage unit of the terminal device D10 and an external storage device. The memory D101 is used to store an operating system, an application program, a boot loader (BootLoader), data, and other programs, such as the program code of the computer program. The memory D101 may also be used to temporarily store data that has been output or is to be output.

[0181] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the above-mentioned various method embodiments can be implemented.

[0182] An embodiment of the present application provides a computer program product. When the computer program product is run on a terminal device, the terminal device can implement the steps in the above-mentioned method embodiments when executing the computer program product.

[0183] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and when the computer program is executed by the processor, it can implement the steps of the above-mentioned various method embodiments. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device that can carry the computer program code to the video encoding method device / terminal device, recording medium, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.

[0184] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant description of other embodiments.

[0185] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0186] The above is a preferred embodiment of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles described in the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. A video encoding method, characterized in that: include: Obtaining a target bit rate of a target video, a number of encoded frames and a bit rate budget value at the N-1 moments before the Nth moment, multiple unencoded frames at the Nth moment, and an encoding state at the N-1th moment; the Nth moment is the current moment, the target bit rate is a preset encoding bit rate of the target video, the bit rate budget value is a maximum encoding bit rate, the bit rate budget value is greater than or equal to the target bit rate, and the encoding state is used to describe the state of the bit rate budget value of the target video; Calculate the current bit rate budget value at the current moment according to the target bit rate and the bit rate budget value at the N-1th moment; Calculate a current rate budget trend value at the current moment and a historical rate budget trend value at the N-1th moment based on the number of coded frames and the rate budget value at the previous N-1 moments, the current rate budget value, and the number of uncoded frames; Obtaining, based on the current rate budget trend value and the historical rate budget trend value, a continuous downward trend coefficient and a continuous upward trend coefficient of the rate budget value at the current moment; the continuous downward trend coefficient is used to describe a decrease in the rate budget value between the current moment and the N-1th moment, and the continuous upward trend coefficient is used to describe an increase in the rate budget value between the current moment and the N-1th moment; Obtaining a frame discarding period at a current moment based on the encoding state of the target video at the N-1th moment, the continuous decreasing trend coefficient, the continuous increasing trend coefficient, and the current bit rate budget value; the frame discarding period is used to describe an interval for discarding unencoded frames; Encoding all unencoded frames at a current moment in sequence according to the current bit rate budget value and the frame dropping period; The calculating of the current bit rate budget value at the current moment according to the target bit rate and the bit rate budget value at the N-1th moment includes: By formula: B N =B N-1 +(T N -T N-1 )×R×RF Calculate the current bitrate budget value B at the current moment N ; Among them, B N-1 Indicates the bit rate budget value at the N-1th moment, T N Indicates the system time corresponding to the current moment, T N-1 represents the system time corresponding to the N-1th moment, R represents the target bit rate, and RF represents the bit rate control strength coefficient.

2. The video encoding method according to claim 1, wherein: The calculating, based on the number of coded frames and the rate budget value at the previous N-1 moments, the current rate budget value, and the number of uncoded frames, the current rate budget value and the number of uncoded frames, includes: Calculate a bit rate budget average value based on the bit rate budget values ​​at the previous N-1 moments and the current bit rate budget value; Calculating an average number of coded frames based on the number of coded frames and the number of uncoded frames at the first N-1 moments; Calculate a current rate budget trend value at a current moment based on the rate budget average, the average number of coded frames, the number of coded frames and the rate budget value at the previous N-1 moments, the current rate budget value, and the number of uncoded frames; The historical rate budget trend value at the N-1th moment is calculated according to the rate budget average value, the average number of coded frames, the number of coded frames at the previous N-1 moments, and the rate budget value.

3. The video encoding method according to claim 2, wherein: The calculating the bit rate budget average value based on the bit rate budget values ​​at the previous N-1 moments and the current bit rate budget value includes: By formula: Calculate the bitrate budget average value B avg ; Among them, B t Indicates the code rate budget value at the tth moment. When t=N, B N Represents the current bitrate budget value, and N represents the current moment; The calculating the average number of coded frames based on the number of coded frames and the number of uncoded frames at the first N-1 moments includes: By formula: Calculate the average number of coded frames C avg ; Among them, C t Indicates the number of coded frames at the t-th moment. When t=N, C N Indicates the number of uncoded frames.

4. The video encoding method according to claim 2, wherein: The calculating, based on the bit rate budget average value, the average number of coded frames, the number of coded frames and the bit rate budget value at the previous N-1 moments, the current bit rate budget value, and the number of uncoded frames, a current bit rate budget trend value at the current moment includes: By formula: Calculate the current bitrate budget trend value Q at the current moment N ; The calculating the historical rate budget trend value at the N-1th moment according to the rate budget average value, the average number of coded frames, the number of coded frames at the previous N-1 moments, and the rate budget value includes: By formula: Calculate the historical bitrate budget trend value Q at the N-1th moment N-1 .

5. The video encoding method according to claim 1, wherein: The acquiring, based on the current bit rate budget trend value and the historical bit rate budget trend value, a continuous decreasing trend coefficient and a continuous increasing trend coefficient of the bit rate budget value at the current moment, includes: If the historical bitrate budget trend value is less than -Q th , and the current bitrate budget trend value is less than -Q th , then the continuous downward trend coefficient at the current moment is set to the continuous downward trend coefficient at the N-1th moment plus 1, and the continuous upward trend coefficient at the current moment is set to 0; where Q th Indicates the bitrate budget trend threshold; If the historical bitrate budget trend value is greater than Q th , and the current bitrate budget trend value is greater than Q th , then the continuous rising trend coefficient at the current moment is set to the continuous rising trend coefficient at the N-1th moment plus 1, and the continuous falling trend coefficient at the current moment is set to 0; If the historical bitrate budget trend value is less than -Q th , and the current bitrate budget trend value is greater than Q th , then the continuous downward trend coefficient and the continuous upward trend coefficient at the current moment are both set to 0; If the historical bitrate budget trend value is greater than Q th , and the current bitrate budget trend value is less than -Q th , then the continuous downward trend coefficient and the continuous upward trend coefficient at the current moment are both set to 0.

6. The video encoding method according to claim 1, wherein: The coding state is one of a budget sufficient state, a budget decreasing state, a budget increasing state, and a budget deficit state; The obtaining of a frame dropping period at a current moment based on the encoding state of the target video at the N-1th moment, the continuous decreasing trend coefficient, the continuous increasing trend coefficient, and the current bit rate budget value includes: When the encoding state of the target video at the N-1th moment is the sufficient budget state, if the continuous decreasing trend coefficient at the current moment is greater than or equal to the decreasing coefficient threshold, the encoding state of the target video at the current moment is the decreasing budget state, the frame dropping period is set to the frame dropping period upper limit value, and the continuous decreasing trend coefficient is set to 0; If the continuous downward trend coefficient at the current moment is less than the downward coefficient threshold, the encoding state of the target video at the current moment is a sufficient budget state, and the frame discarding period is the frame discarding period at the N-1th moment.

7. The video encoding method according to claim 6, wherein: The step of obtaining a frame dropping period at a current moment based on the encoding state of the target video at the N-1th moment, the continuous decreasing trend coefficient, the continuous increasing trend coefficient, and the current bit rate budget value further includes: When the encoding state of the target video at the N-1th moment is the budget reduction state, if the bitrate budget value at the current moment is greater than the bitrate budget lower limit, the encoding state of the target video at the current moment is the budget reduction state, and the frame dropping period is set to the frame dropping period upper limit minus one; If the continuous rising trend coefficient at the current moment is greater than or equal to the rising coefficient threshold, the encoding state of the target video at the current moment is a budget rising state, the continuous rising trend coefficient is set to 0, and it is determined whether the frame dropping period at the N-1th moment is less than the frame dropping period upper limit value. If so, the frame dropping period is set to the frame dropping period at the N-1th moment plus 1; otherwise, the frame dropping period is set to the frame dropping period upper limit value; If the bitrate budget value at the current moment is less than or equal to the bitrate budget lower limit value, the encoding state of the target video at the current moment is the budget deficit state, and it is determined whether the frame discarding period at the N-1th moment is greater than the frame discarding period lower limit value. If so, the frame discarding period is set to the frame discarding period at the N-1th moment minus 1; otherwise, the frame discarding period is set to the frame discarding period lower limit value.

8. The video encoding method according to claim 6, wherein: The step of obtaining a frame dropping period at a current moment based on the encoding state of the target video at the N-1th moment, the continuous decreasing trend coefficient, the continuous increasing trend coefficient, and the current bit rate budget value further includes: When the encoding state of the target video at the N-1th moment is the budget increasing state, if the bit rate budget value at the current moment is less than the bit rate budget upper limit value, the encoding state of the target video at the current moment is the budget increasing state, and it is determined whether the frame dropping period at the N-1th moment is less than the frame dropping period upper limit value; if so, the frame dropping period is set to the frame dropping period at the N-1th moment plus 1; otherwise, the frame dropping period is set to the frame dropping period upper limit value; If the bitrate budget value at the current moment is greater than or equal to the bitrate budget upper limit value, the encoding state of the target video at the current moment is the budget sufficient state, and the frame discarding period is 0; If the continuous downward trend coefficient at the current moment is greater than or equal to the downward coefficient threshold, the encoding state of the target video at the current moment is the budget reduction state, the continuous downward trend coefficient is set to 0, and the frame discarding period is the frame discarding period of the N-1th moment.

9. The video encoding method according to claim 6, wherein: The step of obtaining a frame dropping period at a current moment based on the encoding state of the target video at the N-1th moment, the continuous decreasing trend coefficient, the continuous increasing trend coefficient, and the current bit rate budget value further includes: When the encoding state of the target video at the N-1th moment is a budget deficit state, if the continuous rising trend coefficient at the current moment is less than the rising coefficient threshold, the encoding state of the target video at the current moment is the budget deficit state, and it is determined whether the frame dropping period at the N-1th moment is greater than the frame dropping period lower limit value; if so, the frame dropping period is set to the frame dropping period at the N-1th moment minus 1; otherwise, the frame dropping period is set to the frame dropping period lower limit value; If the continuous rising trend coefficient at the current moment is greater than or equal to the rising coefficient threshold, the encoding state of the target video at the current moment is the budget rising state, and it is determined whether the frame discarding period at the N-1th moment is less than the upper limit value of the frame discarding period. If so, the frame discarding period is set to the frame discarding period at the N-1th moment plus 1; otherwise, the frame discarding period is set to the upper limit value of the frame discarding period.

Citation Information

Patent Citations

  • Video coding method and device

    CN108495142A

  • Frame extracting method, device, apparatus and computer-readable storage medium

    CN109168013A