CN117956159A - Video code rate control method, video code rate control device and computer storage medium - Google Patents

Video code rate control method, video code rate control device and computer storage medium Download PDF

Info

Publication number
CN117956159A
CN117956159A CN202311860196.7A CN202311860196A CN117956159A CN 117956159 A CN117956159 A CN 117956159A CN 202311860196 A CN202311860196 A CN 202311860196A CN 117956159 A CN117956159 A CN 117956159A
Authority
CN
China
Prior art keywords
code rate
current
frame
short period
period
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311860196.7A
Other languages
Chinese (zh)
Inventor
李鸿辉
李曾
江东
林聚财
殷俊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Dahua Technology Co Ltd
Original Assignee
Zhejiang Dahua Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhejiang Dahua Technology Co Ltd filed Critical Zhejiang Dahua Technology Co Ltd
Priority to CN202311860196.7A priority Critical patent/CN117956159A/en
Publication of CN117956159A publication Critical patent/CN117956159A/en
Pending legal-status Critical Current

Links

Landscapes

  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

The application provides a video code rate control method, a video code rate control device and a computer storage medium, wherein the video code rate control method comprises the following steps: acquiring the encoded average code rate in the current long period; under the condition that the encoded average code rate in the current long period is larger than the target code rate of the current long period, determining a first adjusting amplitude according to the encoded average code rate of the current long period and the target code rate of the current long period; acquiring a current short period quantization parameter according to the coded short period basic quantization parameter; adjusting the current short period quantization parameter according to the first adjustment amplitude to obtain a current short period basic quantization parameter; and coding according to the current short period basic quantization parameter, and outputting a compressed code stream. In this way, the characteristics between the frame and the short period and between the short period and the short period are sufficiently considered.

Description

Video code rate control method, video code rate control device and computer storage medium
Technical Field
The present application relates to the field of video coding technologies, and in particular, to a video rate control method, a video rate control device, and a computer storage medium.
Background
The standards of video coding and decoding include H.264/AVC, H.265/HEVC, H.266/VVC, VP8, VP9, AV1, AVS and the like, and the main purpose of the video coding and decoding is to compress the collected video signals into data with different standard formats, so that the video coding and decoding are convenient to transmit or store. In order to apply video coding techniques to actual scenes, rate control techniques play a vital role in video encoders, since it is possible to adjust the target rate of the encoder output with limited communication bandwidth or memory space, thereby avoiding the occurrence of too large or too small of an encoded video frame.
In the prior art, only the code rate is allocated, the size of the actual code rate and the target code rate is simply considered for adjustment, and the characteristics between frames and short periods and between short periods are not fully considered.
Disclosure of Invention
In order to solve the technical problems, the application provides a video code rate control method, a video code rate control device and a computer storage medium.
In order to solve the technical problems, the application provides a video code rate control method, which comprises the following steps: acquiring the encoded average code rate in the current long period; under the condition that the encoded average code rate in the current long period is larger than the target code rate of the current long period, determining a first adjusting amplitude according to the encoded average code rate of the current long period and the target code rate of the current long period; acquiring a current short period quantization parameter according to the coded short period basic quantization parameter; adjusting the current short period quantization parameter according to the first adjustment amplitude to obtain a current short period basic quantization parameter; and coding according to the current short period basic quantization parameter, and outputting a compressed code stream.
Before the average code rate of the codes in the current long period is obtained, the video code rate control method further comprises the following steps: responding to the current long period as a non-first long period in the whole coding process, and acquiring the actual average code rate of the previous long period according to the actual coding total bits of the previous long period and the long period coding time; acquiring a code rate difference value by utilizing the actual average code rate of the previous long period and the target code rate of the previous long period; and confirming the current long-period target code rate according to the code rate difference value and the previous long-period target code rate.
After the average code rate of the codes in the current long period is obtained, the video code rate control method further comprises the following steps: acquiring the actual average code rate of the previous short period under the condition that the encoded average code rate in the current long period is smaller than or equal to the target code rate of the current long period; and under the condition that the actual average code rate of the previous short period is larger than the maximum floating code rate of the first short period or smaller than the maximum floating code rate of the second short period, the second adjusting amplitude is utilized to adjust the basic quantization parameter of the previous short period, and the basic quantization parameter of the current short period is obtained.
After the obtaining of the actual average code rate of the previous short period, the video code rate control method further comprises the following steps: under the condition that the actual average code rate of the previous short period is smaller than or equal to the maximum floating code rate of the first short period and larger than or equal to the maximum floating code rate of the second short period, acquiring an overflow proportion according to the actual code rate of the previous short period and the target code rate of the current long period; acquiring the motion condition of the previous short period according to the motion condition of each frame of the previous short period; determining a current short-period motion scene based on the overflow proportion and the previous short-period motion condition; and adjusting the basic quantization parameter of the previous short period according to the current short period motion scene to obtain the basic quantization parameter of the current short period.
The short-period motion scene comprises a large motion scene, a small motion scene and a common motion scene; subtracting a third adjusting amplitude from the previous short period basic quantization parameter under a large motion scene to obtain the current short period basic quantization parameter; in a small motion scene, adding a fourth adjusting amplitude to the previous short period basic quantization parameter to obtain the current short period basic quantization parameter; in a common motion scene, the previous short period basic quantization parameter is the same as the current short period basic quantization parameter.
The video code rate control method further comprises the following steps: acquiring the previous short-period motion condition; responding to the fact that the previous short-period motion condition belongs to a static scene, and acquiring a previous I frame quantization parameter; subtracting a fifth adjusting amplitude from the previous I frame quantization parameter to obtain a current I frame quantization parameter; and coding according to the current I frame quantization parameter, and outputting a compressed code stream.
After the previous short-period motion condition is acquired, the video code rate control method further comprises the following steps: responding to the fact that the previous short-period motion condition belongs to a motion scene, and acquiring a current I frame motion condition; acquiring an adjusting parameter based on the current I frame motion condition; and acquiring the current I frame quantization parameter based on the adjustment parameter and the previous I frame quantization parameter.
The video code rate control method further comprises the following steps: acquiring the maximum bit of each frame based on a preset short period maximum code rate, short period coding time and short period coding frame number; based on the current short period coded bits, the coded I frame bits and the current short period coded frame number, obtaining short period coded P frame average bits; based on the maximum bit of each frame, the short period coding frame number and the coded I frame bit, obtaining a short period P frame maximum average bit; under the condition that the average bit of the short-period coded P frame is smaller than the maximum average bit of the short-period P frame, determining a P frame basic quantization parameter of the current frame according to the P frame motion condition of the previous frame and the P frame motion condition of the current frame; acquiring the P frame quantization quality of the current frame based on the P frame motion condition of the current frame; determining the current frame P frame quantization parameter according to the current frame P frame basic quantization parameter and the current frame P frame quantization quality; and coding according to the quantization parameter of the current P frame, and outputting a compressed code stream.
After the maximum average bit of the short period P frame is obtained, the video code rate control method further includes: under the condition that the average bit of the short-period coded P frame is larger than or equal to the maximum average bit of the short-period P frame, acquiring a P frame quantization parameter of a previous frame; and determining the P frame basic quantization parameter of the current frame based on the P frame quantization parameter of the previous frame and a sixth adjustment amplitude.
The video code rate control method further comprises the following steps: responding to the fact that the current short period is not the first short period in the long period and the current descending frequency is larger than 0, and acquiring the current long period residual code rate according to the coded total bits, the coded time, the preset long period target code rate and the long period coding time in the current long period; acquiring a weight coefficient based on the current descending times; adding the current long period residual code rate and the previous short period target code rate according to the weight coefficient to obtain the current short period target code rate; the encoding is carried out according to the current short period basic quantization parameter, and a compressed code stream is output, which comprises the following steps: and coding according to the current short period basic quantization parameter and the current short period target code rate, and outputting a compressed code stream.
In order to solve the technical problems, the application provides a video rate control device, which comprises a memory and a processor coupled with the memory; the memory is used for storing program data, and the processor is used for executing the program data to realize the video code rate control method.
In order to solve the above technical problems, the present application provides a computer storage medium for storing program data, which when executed by a computer, is configured to implement the above video rate control method.
Compared with the prior art, the application has the beneficial effects that: the video code rate control device obtains the encoded average code rate in the current long period; under the condition that the encoded average code rate in the current long period is larger than the target code rate of the current long period, determining a first adjusting amplitude according to the encoded average code rate of the current long period and the target code rate of the current long period; acquiring a current short period quantization parameter according to the coded short period basic quantization parameter; adjusting the current short period quantization parameter according to the first adjustment amplitude to obtain a current short period basic quantization parameter; and coding according to the current short period basic quantization parameter, and outputting a compressed code stream. By the mode, characteristics between the frames and the short period and between the short period and the short period are fully considered, the current short period quantization parameter can be adjusted more accurately, and video transmission errors can be avoided to a certain extent.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for the description of the embodiments will be briefly described below, and it is apparent that the drawings in the following description are only some embodiments of the present application, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Wherein:
Fig. 1 is a flowchart of a first embodiment of a video rate control method according to the present application;
fig. 2 is a flow chart of a second embodiment of a video rate control method provided by the present application;
fig. 3 is a flowchart illustrating a third embodiment of a video rate control method according to the present application;
fig. 4 is a flowchart of a fourth embodiment of a video rate control method according to the present application;
Fig. 5 is a flowchart illustrating a fifth embodiment of a video rate control method according to the present application;
fig. 6 is a flowchart illustrating a sixth embodiment of a video rate control method according to the present application;
Fig. 7 is a flowchart of a seventh embodiment of a video rate control method according to the present application;
Fig. 8 is a schematic structural diagram of an embodiment of a video rate control device according to the present application;
fig. 9 is a schematic structural diagram of an embodiment of a computer storage medium provided by the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are only some, but not all embodiments of the application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
The terms "first," "second," "third," "fourth" and the like in the description and in the claims and in the above drawings, if any, are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the application described herein may be implemented, for example, in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Referring to fig. 1 specifically, fig. 1 is a flowchart illustrating a video rate control method according to a first embodiment of the present application.
The video code rate control method is applied to a video code rate control device, wherein the video code rate control device can be a server, a local terminal or a system formed by mutually matching the server and the local terminal. Accordingly, each part, for example, each unit, sub-unit, module, and sub-module, included in the video rate control device may be all disposed in the server, may be all disposed in the local terminal, or may be disposed in the server and the local terminal, respectively.
Further, the server may be hardware or software. When the server is hardware, the server may be implemented as a distributed server cluster formed by a plurality of servers, or may be implemented as a single server. When the server is software, it may be implemented as a plurality of software or software modules, for example, software or software modules for providing a distributed server, or may be implemented as a single software or software module, which is not specifically limited herein.
As shown in fig. 1, the specific steps are as follows:
step S11: and obtaining the encoded average code rate in the current long period.
In the embodiment of the application, the long period includes a plurality of short periods, the current short period is any one of the plurality of short periods, the short period includes a start time and an end time, the end time of the current short period is the same as the start time of the next adjacent short period, the short period includes a plurality of video frames, and the current video frame is any one of the plurality of video frames.
Specifically, the video code rate control device obtains the encoded average code rate in the current long period.
The video code rate control device is used for controlling the total coded bits in the current long periodCalculating the encoded average code rate/> in the current long period by using the encoded time TCurrenLongThe calculation formula is as follows:
In an embodiment of the present application, before obtaining the encoded average code rate in the current long period, the video code rate control device confirms the target code rate in the current long period, referring specifically to fig. 2, fig. 2 is a flowchart illustrating a second embodiment of the video code rate control method provided by the present application.
As shown in fig. 2, the specific steps are as follows:
Step S21: and responding to the current long period as a non-first long period in the whole coding process, and acquiring the actual average code rate of the previous long period according to the actual coding total bits of the previous long period and the long period coding time.
When the current long period is the first long period of the whole coding process, the current long period target code rateEqual to the long period target code rate/>, set by the user
When the current long period is not the first long period in the whole coding process, the video code rate control device actually codes the total bits according to the previous long periodThe long period coding time T Long is used for obtaining the actual average code rate of the previous long period, and the calculation mode is as follows:
step S22: and obtaining a code rate difference value by using the actual average code rate of the previous long period and the target code rate of the previous long period.
Target code rate of previous long periodThe video code rate control device obtains a code rate difference value to calculate the actual average code rate of the previous long period by utilizing the actual average code rate of the previous long period and the target code rate of the previous long periodAnd the difference value diff of the code rate is calculated as follows:
Step S23: and confirming the current long-period target code rate according to the code rate difference value and the previous long-period target code rate.
The video code rate control device calculates the current long period target code rate according to the code rate difference value and the previous long period target code rateThe calculation formula is as follows:
Wherein, E (x) is from% Diff) to/>E (x) may be linear or non-linear.
Step S12: and under the condition that the encoded average code rate in the current long period is larger than the target code rate in the current long period, determining the first adjusting amplitude according to the encoded average code rate in the current long period and the target code rate in the current long period.
If the average code rate of the codes in the current long period is larger than the target code rate of the current long period, namelyThen the number of times of descent Nb ShortDown is increased by 1, and the ratio M of the average coded code rate in the current long period to the target code rate in the current long period is calculated, wherein the calculation formula is as follows:
according to the first adjustment amplitude ChangeQP calculated after M, the calculation formula is:
ChangeQP=γ1(M)
wherein, gamma 1 (x) is a mapping function from M to ChangeQP, and can be a linear relation or a nonlinear relation.
Step S13: and acquiring the current short period quantization parameter according to the encoded short period basic quantization parameter.
The video code rate control device is used for controlling the target code rate according to the long period set by the userThe pixel depth BPP of the current sequence is calculated by the image width W, the image height H and the frame rate fps, and the calculation formula is as follows:
the video code rate control device initializes the basis of the short period according to the pixel depth BPP And (3) withThe calculation formula is as follows:
Wherein g (x) is from BPP to F (x) is the mapping function from BPP to/>G (x) and f (x) may be linear or nonlinear. Video rate control device based on the basis/>, of each short period encodedAnd/>Determining quantization parameter/>, of current short periodAnd/>The calculation formula is as follows:
wherein gamma 2 (x) is a slave To/>The mapping function of (2) may be linear or nonlinear.
Step S14: and adjusting the current short period quantization parameter according to the first adjusting amplitude to obtain the current short period basic quantization parameter.
The video code rate control device quantizes parameters according to the current short periodDetermining a current short period base quantization parameter for the current short period with the first adjustment amplitude ChangeQPThe calculation formula is as follows:
Wherein, gamma 3 (x) is the slave (/ >) ChangeQP) to/>Which may be linear or non-linear.
Step S15: and coding according to the current short period basic quantization parameter, and outputting a compressed code stream.
It should be noted that, after adjusting the target code rate of the current long period, the video code rate control device of the present application adjusts the basic quantization parameter of the current short period. The manner of adjusting the current short period base quantization parameter includes, but is not limited to, three embodiments, respectively: judging the adjustment mode of the current short period basic quantization parameter according to the coded short period condition, specifically please refer to step S11-step S15; judging the adjustment mode of the basic quantization parameter of the current short period according to the code rate condition of the previous short period, specifically please refer to step S31-step S32; judging the current short period basic quantization parameter adjusting mode according to the code rate and the motion condition of the previous short period, and referring to step S41-step S43.
Specifically, an embodiment of the present application determines a manner of adjusting a current short period basic quantization parameter according to a code rate condition of a previous short period, referring to fig. 3, fig. 3 is a flow chart of a third embodiment of the video code rate control method provided by the present application.
As shown in fig. 3, the specific steps are as follows:
Step S31: and under the condition that the encoded average code rate in the current long period is smaller than or equal to the target code rate in the current long period, acquiring the actual average code rate in the previous short period.
Specifically, the video rate control device encodes the total bits according to the current long periodAverage code rate/>, coded over a current long period, with coded time T CurrenLong The calculation formula is as follows:
If it is The number of drops Nb ShortDown is cleared. The video code rate control device is used for controlling the coded total bit/>, according to the previous short periodThe actual average code rate/>, of the previous short period is calculated with the coded time T short of the previous short periodThe calculation formula is as follows:
Step S32: and under the condition that the actual average code rate of the previous short period is larger than the maximum floating code rate of the first short period or smaller than the maximum floating code rate of the second short period, the second adjusting amplitude is utilized to adjust the basic quantization parameter of the previous short period, so that the basic quantization parameter of the current short period is obtained.
The video code rate control device adjusts according to the short period maximum code rate R ShortMax set by the user, ifThe current short period base quantization parameter is adjusted.
Wherein ω1 min and ω1 max are second adjustment amplitudes, ω1 min is greater than or equal to 0 and ω1 max≥0,T0 are floating thresholds, and 1 is greater than or equal to T 0≥0,RShortMax*T0 is the first short period maximum floating code rate.
If it isThe video code rate control device adjusts the current short period basic quantization parameter according to the following specific formula:
The present application further proposes an embodiment for determining a current short period basic quantization parameter adjustment mode according to a code rate and a motion condition of a previous short period, and referring to fig. 4 specifically, fig. 4 is a flow chart of a fourth embodiment of the video code rate control method provided by the present application.
As shown in fig. 4, the specific steps are as follows:
step S41: and under the condition that the actual average code rate of the previous short period is smaller than or equal to the maximum floating code rate of the first short period and larger than or equal to the maximum floating code rate of the second short period, acquiring the overflow proportion according to the actual code rate of the previous short period and the target code rate of the current long period.
In particular, ifThe video code rate control device calculates the actual coding code rate/>, of the previous short periodTarget code rate/>, with current long periodThe overflow ratio P of (2) is as follows:
step S42: and acquiring the motion condition of the previous short period according to the motion condition of each frame of the previous short period.
The video code rate control device determines each frame according to the motion condition of each frame in the previous short period The larger the value is, the more intense the motion is, the video code rate control device calculates the motion condition Quality BeforeShort of the previous short period, and the calculation formula is as follows:
Wherein, To be from/>The mapping function to Quality Beforeshort may be linear or non-linear.
Step S43: and determining the current short-period motion scene based on the overflow proportion and the previous short-period motion condition.
The short-period motion scene comprises a large motion scene, a small motion scene and a common motion scene.
Specifically, if Quality BeforeShort>T2 and P > T 3, it indicates that the current scene is a large motion. If Quality BeforeShort<T4 and P < T 5, the current scene is indicated to be a small motion, and otherwise, the current motion scene is indicated to be a common motion scene.
Step S44: and adjusting the basic quantization parameter of the previous short period according to the current short period motion scene to obtain the basic quantization parameter of the current short period.
And under the large motion scene, subtracting the third adjusting amplitude from the previous short period basic quantization parameter to obtain the current short period basic quantization parameter. And in a small motion scene, adding the fourth adjusting amplitude to the previous short period basic quantization parameter to obtain the current short period basic quantization parameter. In a common motion scene, the previous short period basic quantization parameter is the same as the current short period basic quantization parameter.
Specifically, if Quality BeforeShort>T2 and P > T 3 indicate that the current motion scene is a large motion scene, the calculation formula of the current short period basic quantization parameter is:
Wherein pi 2 min and pi 2 max are the third adjusting amplitude, pi 2 min is more than or equal to 0 and pi 2 max≥0,T2 are the large motion threshold, T 2≥0,T3 is the overflow threshold, and T 3 is more than or equal to 0.
If Quality BeforeShort<T4 and P < T 5 indicate that the current motion scene is a small motion scene, then:
Wherein ω2 min and ω2 max are the fourth adjustment amplitude, ω2 min is more than or equal to 0 and ω2 max≥0,T4 are the small movement threshold, T 4≥0,T5 is the overflow threshold, and T 5 is more than or equal to 0.
In other cases, the current motion scene is represented as a common motion scene, and then:
According to the short period adjusting method, different adjusting modes under different conditions are fully considered, the basic quantization parameters of the short period can be adjusted more accurately, and the situation of error transmission can be avoided to a certain extent.
Further, the present application proposes a specific embodiment for calculating the current short period basic quantization parameter, which is specifically as follows:
the video code rate control device initializes the basis of the short period according to the pixel depth BPP And (3) withThe calculation formula of (c) may be, but is not limited to, the following:
The video rate control device may, but is not limited to, the following form according to the calculation formula for calculating the adjustment amplitude ChangeQP in excess of the target rate ratio M:
video rate control device based on the basis of each coded short period And/>Determining the/>, of the current short periodAnd/>The calculation formula may be, but is not limited to, the following:
wherein Shortnum is the number of coded short periods, m i is the weight value of the coded i-th short period, the weight values can be all 1, or can be determined according to the distance between the frame and the current short period, the longer the distance is, the smaller the value is, and otherwise, the larger the value is.
The video code rate control device controls the motion condition of each frame according to the previous short periodCalculating the motion Quality BeforeShort for the previous short period, the calculation formula may be, but is not limited to, the following:
Wherein, frameNum short is the number of short period frames, τ i is the weight value of the i-th frame of the previous short period, the weight values can be all 1, or can be determined according to the distance between the frame and the current short period, the longer the distance is, the smaller the value is, and otherwise, the larger the value is.
When the weight values are all 1, andAt this time, the threshold T 0、T1、T2、T3、T4、T5 may be set to
T2=8、/>T4=3、/>
The adjustment amplitude values ω1 min、ω1max、ω2min、ω2max and pi 1 min、π1max、π2min、π2max may be set to ω min=ω1max=π1min=π1max =4
ω2min=ω2max=π2min=π2max=2
Based on the actual coding condition of the coding process, the target code rate adjustment of the long period and the short period is carried out, and the maximum quantization parameter and the minimum quantization parameter adjustment of the short period and the frame level are carried out according to the motion condition of the image, so that the relation between the video quality and the target code rate can be well balanced, and the code stream with the clearest maximum efficiency and the best effect can be obtained in a storage space with a certain capacity. The method is simple and independent, and can be compatible with different chip platforms.
Further, an embodiment of the present application is provided for adjusting the quantization parameter of the I frame, and referring to fig. 5, fig. 5 is a flowchart of a fifth embodiment of the video rate control method provided by the present application.
As shown in fig. 5, the specific steps are as follows:
step S51: the previous short-period motion situation is acquired.
The video rate control device obtains the motion Quality BeforeShort of the previous short period.
In an embodiment of the present application, when the previous short-period motion condition is acquired to belong to a short period of a motion scene, the video rate control device responds to the fact that the previous short-period motion condition belongs to the motion scene, and acquires the current I-frame motion condition; acquiring an adjusting parameter based on the current I frame motion condition; and acquiring the current I frame quantization parameter based on the adjustment parameter and the previous I frame quantization parameter.
The video code rate control device calculates delta Iqp according to the I frame motion condition Quality Iframe, and the calculation formula is as follows:
ΔIqp=ρ(QualityIframe)
Where ρ (x) is a mapping function from Quality Iframe to Δiqp, which may be linear or non-linear.
Video code rate control device based on previous I frameAnd/>Nb ShortDown, ΔIqp calculates/>, of the current I frameAnd/>The calculation formula is as follows:
Wherein, For the slave (/ >)Δiqp, nb ShortDown) to/>Mapping function of/>For the slave (/ >)Δiqp, nb ShortDown) to/>Is used as a mapping function of the (c),And/>Either linear or nonlinear.
Step S52: and acquiring a previous I frame quantization parameter in response to the previous short-period motion condition belonging to the static scene.
For still scenes, breathing effects are likely to occur, so that the I-frame quality needs to be improved. When the video code rate control device is used for a motion scene, the maximum quantization parameter and the minimum quantization parameter of the I frame need to be controlled.
When Quality BeforeShort<T6 is reached, the bit rate is considered to be surplus and is a long-term static scene, and the video bit rate control device acquires the quantization parameter of the previous I frame.
Step S53: subtracting the fifth adjusting amplitude from the previous I frame quantization parameter to obtain the current I frame quantization parameter.
When Quality BeforeShort<T6, the code rate is considered to be surplus and a long-term static scene, so that the video Quality is ensured by improving the I frame Quality, and then:
Wherein, And/>For the maximum quantization parameter and the minimum quantization parameter of the current I frame,/>And/>Is the maximum quantization parameter and the minimum quantization parameter of the previous I frame. /(I)And/>For the fifth adjustment amplitude,/> T 6 is a static scene threshold, and T 6 is more than or equal to 0.
Step S54: and encoding according to the current I frame quantization parameter, and outputting a compressed code stream.
Specifically, the video code rate control device encodes according to the current I frame quantization parameter and outputs a compressed code stream. The video code rate control device considers the influence of the I frame on the static scene through an I frame level adjustment and distribution method, improves the quality of the I frame, and enables the transition between the I frame and the P frame to be smoother; considering the motion condition and the short period adjustment condition of the I frame, the short period adjustment direction can be adapted under the condition of ensuring subjective quality.
The application describes an I frame adjusting mode by a specific embodiment, which is as follows:
Adjusting amplitude values The threshold T6 may be set to:
T6=3
After calculating the I-frame motion Quality Iframe, Δiqp is calculated, and the calculation formula may be, but is not limited to, the following form:
video code rate control device based on previous I frame And/>Nb ShortDown, Δiqp in (a) calculates/>, of the current I frameAnd/>The calculation formula may be, but is not limited to, the following:
wherein k 1 can be 2,1, Etc., k 2 can be set as/>Etc.
Further, the present application further provides an embodiment for adjusting the quantization parameter of the P-frame, and specifically please refer to fig. 6, fig. 6 is a flowchart illustrating a sixth embodiment of the video rate control method according to the present application.
As shown in fig. 6, the specific steps are as follows:
step S61: based on the preset short period maximum code rate, the short period coding time and the short period coding frame number, the maximum bit of each frame is obtained.
The video code rate control device calculates a maximum bit per frame Bite framemax and a minimum bit per frame Bite framemin according to a preset short period maximum code rate R ShortMax, a short period coding time T short and a short period coding frame number frameNum short, and a calculation formula is as follows:
Wherein T 7 and T 8 are floating thresholds, and T 7≥0,1≥T8 is more than or equal to 1 and more than or equal to 0.
Step S62: based on the current short period encoded bits, the encoded I frame bits, and the current short period encoded frame number, short period encoded P frame average bits are obtained.
The video code rate control device is used for controlling the coded bits in the current short period according to the coded I frame bits Bite I Coded frame number in current short period/>Calculating the average bit/>, of the encoded P-frames in a short periodMaximum average bit/>, with P-frames in short periodsThe calculation formula is as follows:
Step S63: based on the maximum bits per frame, the short period code frame number and the coded I frame bits, the short period P frame maximum average bits are obtained.
The specific calculation mode is as follows:
wherein T 9 is a floating threshold, and 1 is more than or equal to T 9 is more than or equal to 0.
Step S64: and under the condition that the average bit of the short-period coded P frame is smaller than the maximum average bit of the short-period P frame, determining the P frame basic quantization parameter of the current frame according to the P frame motion condition of the previous frame and the P frame motion condition of the current frame.
The video code rate control device is used for controlling the video code rate according to the motion condition of the previous frameMotion condition of current frameDelta quality is calculated according to the change value of (a), and the calculation formula is as follows:
Δquality=α1(change)
Wherein, alpha 1 (x) is a mapping function from change to deltaquality, and can be a linear relation or a nonlinear relation.
When Nb ShortDown>T10 is satisfied and the previous frame actually codes bitsOr satisfy/>When calculate/>And/>The calculation formula is as follows:
/>
Wherein alpha 2 (x) is from Δquality) to/>Alpha 3 (x) is the sum of @ and @ of mapping functionsΔquality) to/>Is a linear relationship or a nonlinear relationship between α 2 (x) and α 3 (x). T 10 is an overflow threshold, T 10≥0,T11 is a floating threshold, and T 11 is more than or equal to 1 and more than or equal to 0.
When meeting the requirementsAnd/>Or satisfy the followingAnd/>Or satisfy the followingCalculation/>And/>The calculation formula is as follows:
wherein alpha 4 (x) is from Δquality) to/>Alpha 5 (x) is the sum of @ and @ of mapping functionsΔquality) to/>Is a linear relationship or a nonlinear relationship between α 4 (x) and α 5 (x). T 12 and T 14 are motion thresholds, T 12≥0,T14≥0,T13 and T 15 are floating thresholds, and 1 is more than or equal to T 13≥0,1≥T15 is more than or equal to 0.
When the above condition is not satisfied, calculateAnd/>The calculation formula is as follows:
Wherein alpha 6 (x) is from Δquality) to/>Alpha 7 (x) is the sum of @ and @ of mapping functionsΔquality) to/>Is a mapping function of alpha 6 (x) and alpha 7 (x) and can be a linear relation or a nonlinear relation
Step S65: and acquiring the P frame quantization quality of the current frame based on the P frame motion condition of the current frame.
Video code rate control device according to motion condition of frame itselfDetermining the quality of a frame itselfAnd/>The calculation formula is as follows:
Wherein alpha 6 (x) is a slave To/>Alpha 7 (x) is the slaveTo/>Is a linear relationship or a nonlinear relationship between α 6 (x) and α 7 (x). /(I)
Step S66: and determining the P frame quantization parameter of the current frame according to the P frame basic quantization parameter of the current frame and the P frame quantization quality of the current frame.
The video code rate control device is according to Nb ShortDown and Nb ShortDown in the embodiment of the applicationCalculating/>, of the current P frameAnd (3) withThe calculation formula is as follows:
Wherein alpha 8 (x) is from Nb ShortDown) to/>Alpha 9 (x) is the slave (/ >)Nb ShortDown) to/>Is a linear relationship or a nonlinear relationship between α 8 (x) and α 9 (x).
Step S67: and encoding according to the current P frame quantization parameter, and outputting a compressed code stream.
In an embodiment of the present application, the P-frame quantization parameter of the previous frame is obtained when the average bit of the short-period encoded P-frame is greater than or equal to the maximum average bit of the short-period P-frame. And determining the P frame basic quantization parameter of the current frame based on the P frame quantization parameter of the previous frame and the sixth adjustment amplitude.
If it meetsThen according to the/>, of the previous frameAnd/>Calculate frame level/>And/>The calculation formula is as follows:
Wherein, And/>For the sixth adjustment amplitude,/>
By the P frame adjusting method, the coding condition in a short period, the motion condition and the coding condition of the previous frame and the current frame are considered, and different adjusting modes are adopted, so that the subjective quality of human eyes can be ensured under different coding conditions.
The application describes a P frame adjusting mode by a specific embodiment, which is as follows:
Adjusting amplitude values The threshold T 7、T8、T9、T10、T11、T12、T13、T14、T15 may be set as:
T10=0、/>
T12=8、T14=3、/>
the video code rate control device is used for controlling the video code rate according to the motion condition of the previous frame And current frame motion situation/>Delta quality is calculated according to the change value of (a), and the calculation formula is as follows:
wherein m may be 2,1, Etc.
The video code rate control device calculates the current frame according to the overflow condition and the motion conditionAnd/>The method comprises the following steps:
When Nb ShortDown > 0 is satisfied and the actual code bit of the previous frame Or satisfy/>When the video code rate control device calculates/>And/>The calculation formula may be, but is not limited to, the following:
Wherein n 1 can be 3,2,1, etc.
When meeting the requirementsAnd/>Or satisfy the followingAnd/>Or satisfy the followingCalculation/>And/>The calculation formula may be, but is not limited to, the following:
Wherein n 2 can be-3, -2, -1, etc.
When the above conditions are not satisfied, the video rate control device calculatesAnd/>The calculation formula may be, but is not limited to, the following:
video code rate control device according to motion condition of frame itself Determining the quality of a frame itselfAnd/>The calculation formula may be, but is not limited to, the following:
/>
The video code rate control device is according to Nb ShortDown and Nb ShortDown in the embodiment of the application Calculating/>, of the current P frameAnd (3) withThe calculation formula may be, but is not limited to, the following:
Wherein t 1、t2 can be 1,2,3, etc.
Further, the present application provides an embodiment of adjusting the target code rate of the current short period, that is, in the embodiment of the present application, after adjusting the basic quantization parameter of the current short period, the target code rate of the current short period is adjusted. Referring to fig. 7 specifically, fig. 7 is a flowchart illustrating a seventh embodiment of a video rate control method according to the present application.
As shown in fig. 7, the specific steps are as follows:
Step S71: and responding to the fact that the current short period is not the first short period in the long period and the current descending frequency is larger than O, and acquiring the current long period residual code rate according to the coded total bits, the coded time, the preset long period target code rate and the long period coding time in the current long period.
For the first short period of the first long period, the video code rate control device controls the video code rate according to the target code rate of the long period set by the userCalculating the target code rate/>, of the current short periodThe calculation formula is as follows:
the video code rate control device adjusts the target code rate according to the current long period when the video code rate control device is used for the first short period which is not the first long period Calculating the target code rate/>, of the current short periodThe calculation formula is as follows:
If Nb ShortDown > 0, the video code rate control device is based on the coded total bits for the non-first short period in the long period Coded time T CurrenLong, long period target code rate set by userLong period coding time T Long is used for calculating long period residual code rate/>The calculation formula is as follows:
/>
If Nb ShortDown is less than 0, regulating the amplitude delta qp and the target code rate of the previous short period according to the basic quantization parameter Calculating the target code rate/>, of the current short periodThe calculation formula is as follows:
Wherein ε 3 (x) is the sum of the values from (Δqp, ) To/>Which may be linear or non-linear.
Step S72: and acquiring a weight coefficient based on the current descending times.
And determining the weight coefficients mu and theta according to Nb ShortDown, wherein the calculation formula is as follows:
μ=ε1(NbShortDown)
θ=ε2(NbShortDown)
where ε 1 (x) is a mapping function from Nb ShortDown to μ, ε 2 (x) is a mapping function from Nb ShortDown to θ, and ε 1 (x) and ε 2 (x) may be linear or nonlinear.
Step S73: and adding the current long period residual code rate and the previous short period target code rate according to the weight coefficient to obtain the current short period target code rate.
The video code rate control device is used for controlling the residual code rate according to the long periodTarget code rate/>, with the previous short periodCalculating the target code rate/>, of the current short periodThe calculation formula is as follows:
step S74: and coding according to the current short period basic quantization parameter and the current short period target code rate, and outputting a compressed code stream.
Further, the present application proposes a specific embodiment as an illustration, specifically as follows:
the video rate control device determines the weight coefficients μ and θ according to Nb ShortDown, and the calculation formula may be, but is not limited to, the following form:
The video code rate control device adjusts the amplitude delta qp and the target code rate of the previous short period according to the basic quantization parameter Calculating the target code rate/>, of the current short periodThe calculation formula may be, but is not limited to, the following:
/>
It will be appreciated by those skilled in the art that in the above-described method of the specific embodiments, the written order of steps is not meant to imply a strict order of execution but rather should be construed according to the function and possibly inherent logic of the steps.
In order to implement the above-mentioned video rate control method, the present application further provides a video rate control device, refer to fig. 8 specifically, fig. 8 is a schematic structural diagram of an embodiment of the video rate control device provided by the present application.
The video rate control apparatus 400 of the present embodiment includes a processor 41, a memory 42, an input/output device 43, and a bus 44.
The processor 41, the memory 42 and the input/output device 43 are respectively connected to the bus 44, and the memory 42 stores program data, and the processor 41 is configured to execute the program data to implement the video rate control method according to the above embodiment.
In an embodiment of the present application, the processor 41 may also be referred to as a CPU (Central Processing Unit ). The processor 41 may be an integrated circuit chip with signal processing capabilities. Processor 41 may also be a general purpose processor, a digital signal processor (DSP, digital Signal Process), an Application Specific Integrated Circuit (ASIC), a field programmable gate array (FPGA, field Programmable GATE ARRAY) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components. The general purpose processor may be a microprocessor or the processor 41 may be any conventional processor or the like.
The present application further provides a computer storage medium, please continue to refer to fig. 9, fig. 9 is a schematic structural diagram of an embodiment of the computer storage medium provided by the present application, the computer storage medium 600 stores a computer program 61, and the computer program 61 is used to implement the video rate control method of the above embodiment when being executed by a processor.
Embodiments of the present application may be stored in a computer readable storage medium when implemented in the form of software functional units and sold or used as a stand alone product. Based on such understanding, the technical solution of the present application may be embodied in essence or a part contributing to the prior art or all or part of the technical solution in the form of a software product stored in a storage medium, including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor (processor) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a usb disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
The foregoing description is only of embodiments of the present application, and is not intended to limit the scope of the application, and all equivalent structures or equivalent processes using the descriptions and the drawings of the present application or directly or indirectly applied to other related technical fields are included in the scope of the present application.

Claims (12)

1. The video code rate control method is characterized by comprising the following steps of:
acquiring the encoded average code rate in the current long period;
Under the condition that the encoded average code rate in the current long period is larger than the target code rate of the current long period, determining a first adjusting amplitude according to the encoded average code rate of the current long period and the target code rate of the current long period;
acquiring a current short period quantization parameter according to the coded short period basic quantization parameter;
adjusting the current short period quantization parameter according to the first adjustment amplitude to obtain a current short period basic quantization parameter;
and coding according to the current short period basic quantization parameter, and outputting a compressed code stream.
2. The video rate control method of claim 1, wherein,
Before the average code rate of the codes in the current long period is obtained, the video code rate control method further comprises the following steps:
Responding to the current long period as a non-first long period in the whole coding process, and acquiring the actual average code rate of the previous long period according to the actual coding total bits of the previous long period and the long period coding time;
acquiring a code rate difference value by utilizing the actual average code rate of the previous long period and the target code rate of the previous long period;
and confirming the current long-period target code rate according to the code rate difference value and the previous long-period target code rate.
3. The video rate control method according to claim 1 or 2, characterized in that,
After the average code rate of the codes in the current long period is obtained, the video code rate control method further comprises the following steps:
in the case that the encoded average code rate in the current long period is less than or equal to the target code rate of the current long period,
Acquiring the actual average code rate of the previous short period;
And under the condition that the actual average code rate of the previous short period is larger than the maximum floating code rate of the first short period or smaller than the maximum floating code rate of the second short period, the second adjusting amplitude is utilized to adjust the basic quantization parameter of the previous short period, and the basic quantization parameter of the current short period is obtained.
4. The video rate control method according to claim 3, wherein,
After the obtaining of the actual average code rate of the previous short period, the video code rate control method further comprises the following steps:
Under the condition that the actual average code rate of the previous short period is smaller than or equal to the maximum floating code rate of the first short period and larger than or equal to the maximum floating code rate of the second short period, acquiring an overflow proportion according to the actual code rate of the previous short period and the target code rate of the current long period;
acquiring the motion condition of the previous short period according to the motion condition of each frame of the previous short period;
Determining a current short-period motion scene based on the overflow proportion and the previous short-period motion condition;
and adjusting the basic quantization parameter of the previous short period according to the current short period motion scene to obtain the basic quantization parameter of the current short period.
5. The video rate control method of claim 4, wherein,
The short-period motion scene comprises a large motion scene, a small motion scene and a common motion scene; subtracting a third adjusting amplitude from the previous short period basic quantization parameter under a large motion scene to obtain the current short period basic quantization parameter; in a small motion scene, adding a fourth adjusting amplitude to the previous short period basic quantization parameter to obtain the current short period basic quantization parameter; in a common motion scene, the previous short period basic quantization parameter is the same as the current short period basic quantization parameter.
6. The video rate control method of claim 4, wherein,
The video code rate control method further comprises the following steps:
Acquiring the previous short-period motion condition;
responding to the fact that the previous short-period motion condition belongs to a static scene, and acquiring a previous I frame quantization parameter;
Subtracting a fifth adjusting amplitude from the previous I frame quantization parameter to obtain a current I frame quantization parameter;
And coding according to the current I frame quantization parameter, and outputting a compressed code stream.
7. The video rate control method of claim 6, wherein,
After the previous short-period motion condition is acquired, the video code rate control method further comprises the following steps:
Responding to the fact that the previous short-period motion condition belongs to a motion scene, and acquiring a current I frame motion condition;
acquiring an adjusting parameter based on the current I frame motion condition;
And acquiring the current I frame quantization parameter based on the adjustment parameter and the previous I frame quantization parameter.
8. The video rate control method of claim 4, wherein,
The video code rate control method further comprises the following steps:
Acquiring the maximum bit of each frame based on a preset short period maximum code rate, short period coding time and short period coding frame number;
Based on the current short period coded bits, the coded I frame bits and the current short period coded frame number, obtaining short period coded P frame average bits;
based on the maximum bit of each frame, the short period coding frame number and the coded I frame bit, obtaining a short period P frame maximum average bit;
Under the condition that the average bit of the short-period coded P frame is smaller than the maximum average bit of the short-period P frame, determining a P frame basic quantization parameter of the current frame according to the P frame motion condition of the previous frame and the P frame motion condition of the current frame;
acquiring the P frame quantization quality of the current frame based on the P frame motion condition of the current frame;
Determining the current frame P frame quantization parameter according to the current frame P frame basic quantization parameter and the current frame P frame quantization quality;
and coding according to the quantization parameter of the current P frame, and outputting a compressed code stream.
9. The video rate control method of claim 8, wherein,
After the maximum average bit of the short period P frame is obtained, the video code rate control method further comprises the following steps:
under the condition that the average bit of the short-period coded P frame is larger than or equal to the maximum average bit of the short-period P frame, acquiring a P frame quantization parameter of a previous frame;
And determining the P frame basic quantization parameter of the current frame based on the P frame quantization parameter of the previous frame and a sixth adjustment amplitude.
10. The video rate control method of claim 1, wherein,
The video code rate control method further comprises the following steps:
responding to the fact that the current short period is not the first short period in the long period and the current descending frequency is larger than 0, and acquiring the current long period residual code rate according to the coded total bits, the coded time, the preset long period target code rate and the long period coding time in the current long period;
acquiring a weight coefficient based on the current descending times;
Adding the current long period residual code rate and the previous short period target code rate according to the weight coefficient to obtain the current short period target code rate;
The encoding is carried out according to the current short period basic quantization parameter, and a compressed code stream is output, which comprises the following steps:
And coding according to the current short period basic quantization parameter and the current short period target code rate, and outputting a compressed code stream.
11. A video rate control device, comprising a memory and a processor coupled to the memory;
wherein the memory is configured to store program data and the processor is configured to execute the program data to implement the video rate control method according to any one of claims 1 to 10.
12. A computer storage medium for storing program data which, when executed by a computer, is adapted to carry out the video rate control method of any one of claims 1 to 10.
CN202311860196.7A 2023-12-29 2023-12-29 Video code rate control method, video code rate control device and computer storage medium Pending CN117956159A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311860196.7A CN117956159A (en) 2023-12-29 2023-12-29 Video code rate control method, video code rate control device and computer storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311860196.7A CN117956159A (en) 2023-12-29 2023-12-29 Video code rate control method, video code rate control device and computer storage medium

Publications (1)

Publication Number Publication Date
CN117956159A true CN117956159A (en) 2024-04-30

Family

ID=90791305

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311860196.7A Pending CN117956159A (en) 2023-12-29 2023-12-29 Video code rate control method, video code rate control device and computer storage medium

Country Status (1)

Country Link
CN (1) CN117956159A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118214887A (en) * 2024-05-20 2024-06-18 浙江大华技术股份有限公司 Video coding method

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118214887A (en) * 2024-05-20 2024-06-18 浙江大华技术股份有限公司 Video coding method

Similar Documents

Publication Publication Date Title
US20230156237A1 (en) Deblocking filtering control
US9516325B2 (en) Region-of-interest aware video coding
US9225983B2 (en) Rate-distortion-complexity optimization of video encoding guided by video description length
US9282329B2 (en) Methods and devices for data compression using offset-based adaptive reconstruction levels
US7653129B2 (en) Method and apparatus for providing intra coding frame bit budget
AU766868B2 (en) Apparatus, method and computer program product for transcoding a coded moving picture sequence
US20060056508A1 (en) Video coding rate control
CN108574841B (en) Coding method and device based on self-adaptive quantization parameter
WO2009157579A1 (en) Image processing device and image processing method
WO2009157577A1 (en) Image processing device, and image processing method
CN101795415A (en) Method and device for controlling code rate in video coding
JP5900163B2 (en) Image processing apparatus, image processing method, and program
CN117956159A (en) Video code rate control method, video code rate control device and computer storage medium
CN103843338A (en) Adaptive quantization of intra-encoding image blocks
CN108353178B (en) Encoding and decoding method and corresponding devices
US20210400273A1 (en) Adaptive quantizer design for video coding
JP5847199B2 (en) Encoded moving image generation method, image encoding method, and image encoding apparatus
JP3779066B2 (en) Video encoding device
US8711927B2 (en) System and method for video encoding
Kwon et al. A transcoding method for improving the subjective picture quality
US20180048897A1 (en) Method and apparatus for coding a video into a bitstream
JP2019117974A (en) Encoding device, bit rate control method, and computer program
Kwon et al. BITRATE-QUANTIZATION MODEL FOR H. 264 BITSTREAM TRANSCODING

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination