CN115499654A - Video coding method and device, electronic equipment and readable storage medium - Google Patents

Video coding method and device, electronic equipment and readable storage medium Download PDF

Info

Publication number
CN115499654A
CN115499654A CN202210911012.4A CN202210911012A CN115499654A CN 115499654 A CN115499654 A CN 115499654A CN 202210911012 A CN202210911012 A CN 202210911012A CN 115499654 A CN115499654 A CN 115499654A
Authority
CN
China
Prior art keywords
bit number
frame
target
video frame
quantization parameter
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
CN202210911012.4A
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.)
Tianyi Cloud Technology Co Ltd
Original Assignee
Tianyi Cloud 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 Tianyi Cloud Technology Co Ltd filed Critical Tianyi Cloud Technology Co Ltd
Priority to CN202210911012.4A priority Critical patent/CN115499654A/en
Publication of CN115499654A publication Critical patent/CN115499654A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/102Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or selection affected or controlled by the adaptive coding
    • H04N19/124Quantisation
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/102Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or selection affected or controlled by the adaptive coding
    • H04N19/103Selection of coding mode or of prediction mode
    • H04N19/107Selection of coding mode or of prediction mode between spatial and temporal predictive coding, e.g. picture refresh
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/169Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding
    • H04N19/184Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being bits, e.g. of the compressed video stream
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/50Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using predictive coding
    • H04N19/587Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using predictive coding involving temporal sub-sampling or interpolation, e.g. decimation or subsequent interpolation of pictures in a video sequence
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/50Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using predictive coding
    • H04N19/59Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using predictive coding involving spatial sub-sampling or interpolation, e.g. alteration of picture size or resolution

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

The invention relates to the technical field of streaming media video coding and code rate control, and discloses a video coding method, a video coding device, electronic equipment and a readable storage medium. Wherein, the method comprises the following steps: acquiring a target bit number and an actual bit number corresponding to a current video frame; controlling the actual bit number to track to the target bit number within the target time based on the error between the actual bit number and the target bit number; determining a quantization parameter corresponding to the current video frame based on a preset model and a target bit number; and coding the quantization parameter by adopting a preset coding method to obtain video coding information. By implementing the invention, the bit number consumption of the video frame is not required to be adjusted by adopting a buffer area, the real-time response of the coding is improved, the coding delay is reduced, the controllable adjustment of the code rate control time is realized, the influence of the code rate error changing in real time on the video coding is eliminated, the jitter delay is avoided to the greatest extent, the coding efficiency is improved, and the watching experience of a user is ensured.

Description

Video encoding method, video encoding device, electronic equipment and readable storage medium
Technical Field
The invention relates to the technical field of streaming media video coding and code rate control, in particular to a video coding method, a video coding device, electronic equipment and a readable storage medium.
Background
In the transmission of streaming media in video application, a video needs to be compressed first, and the code rate of the video is controlled in real time according to the current network throughput and the size condition of a buffer area, so that the smooth playing of the video is ensured. Therefore, the code rate control plays a crucial role in video compression, and the reasonable code rate control strategy can remarkably improve the watching experience of users.
The rate control procedure can be divided into two parts: allocating consumed bit numbers for the coding units; the relationship between the number of consumed bits of a coding unit and an image distortion rate is determined by calculating a Quantization Parameter (QP) of the coding unit, and then the coding unit is encoded by the model. The current video coding method adopts a buffer to ensure the smoothness of the code rate control process in the code rate control process, and linearly adjusts the bit number consumption of a coding unit according to the state of the buffer, such as MPEG-2, MPEG-4, H.261/H.263, H.264/AVC, H.264/SVC, HEVC/H.265, and the like. These coding methods can only reduce the control error, but cannot practically eliminate it.
However, the error magnitude of the target code rate and the actual code rate in the actual control process is changed in real time, and meanwhile, the interference influence of the current network throughput, the delay condition, the buffer size and the like exists, which all can cause the uncontrollable code rate control time, cause jitter delay with different amplitudes, and seriously affect the watching experience of the user.
Disclosure of Invention
In view of this, embodiments of the present invention provide a video encoding method, an apparatus, an electronic device, and a readable storage medium, so as to solve the problem that the rate control time is not controllable due to the existing video encoding method.
According to a first aspect, an embodiment of the present invention provides a video encoding method, including: acquiring a target bit number and an actual bit number corresponding to a current video frame; controlling the actual bit number to track to the target bit number within a target time based on an error between the actual bit number and the target bit number; determining a quantization parameter corresponding to the current video frame based on a preset model and the target bit number; and coding the quantization parameter by adopting a preset coding method to obtain video coding information.
According to the video coding method provided by the embodiment of the invention, the actual bit number of the current video frame is controlled to track to the target bit number within the target time through the error between the actual bit number and the target bit number, the corresponding quantization parameter is determined by combining the target bit number and the preset model, the quantization parameter is coded, and the coding aiming at the current video frame is realized. Therefore, the bit number consumption of the video frame is not required to be adjusted by adopting a buffer area, the real-time response of the coding is improved, and the coding delay is reduced. Meanwhile, the target time of tracking to the target bit number is controlled by combining the error between the actual bit number and the target bit number, so that the adjustment of the video code rate control time is realized, the influence of the real-time change code rate error on video coding is eliminated, the jitter delay is avoided to the greatest extent, the coding efficiency is improved, and the watching experience of a user is ensured.
With reference to the first aspect, in a first implementation manner of the first aspect, the obtaining a target bit number corresponding to a current video frame includes: acquiring the bit number of an image group corresponding to a video coding unit, wherein the image group comprises a full-frame compressed frame, a forward predicted frame and a bidirectional predicted frame; and determining the target bit number of the current video frame based on the bit number and the weight of the different types of coded frames in the image group.
With reference to the first implementation manner of the first aspect, in a second implementation manner of the first aspect, the obtaining the number of bits of the group of pictures corresponding to the video coding unit includes: acquiring a frame rate, a picture quantity and a target bit rate corresponding to the image group; determining a ratio of the target bit rate to the frame rate; and determining the bit number corresponding to the image group based on the ratio and the number of the pictures.
The video coding method provided by the embodiment of the invention determines the target bit number of the current video frame by combining the bit number of the image group and the proportion of different types of coded frames, thereby being convenient for distributing the accurate target bit number for the current video frame.
With reference to the first aspect, in a third implementation manner of the first aspect, the controlling the actual bit number to track to the target bit number within a target time based on an error between the actual bit number and the target bit number includes: acquiring the current network throughput, the time delay variation of adjacent video frames and preset adjustment parameters, wherein the preset adjustment parameters are used for controlling the time for converging the actual bit number to the target bit number; constructing a self-adaptive relation among the current network throughput, the time delay variation of the adjacent video frame and the target time based on the preset adjustment parameters; and controlling the actual bit number to track to the target time of the target bit number based on the self-adaptive relation.
According to the video coding method provided by the embodiment of the invention, by constructing the self-adaptive relationship between the target time and the current network throughput and the time delay variation, on the basis of realizing the preset adjustment of the code rate control time, the influence of factors such as higher throughput or larger time delay variation on the code rate control can be effectively inhibited, the controllability of the code rate is improved, the code rate control process is smoother, and the fluency of video watching is improved.
With reference to the third embodiment of the first aspect, in a fourth embodiment of the first aspect, the method further includes: acquiring the average code rate of the coded historical video frame; and correcting the target bit number based on the average code rate.
According to the video coding method provided by the embodiment of the invention, the target bit number of the current video frame is corrected through the average code rate of the coded historical video frame, so that the target bit number of the current video frame is ensured to be in a reasonable interval, and the video picture quality is prevented from being influenced by too large coding difference of the previous frame and the next frame.
With reference to the first aspect, in a fifth implementation manner of the first aspect, the determining a quantization parameter corresponding to the current video frame based on a preset model and the target bit number includes: judging whether the current video frame is an interframe coded video frame; and when the current video frame is the video frame coded in the frame, calculating an intra-frame quantization parameter according to the preset model.
With reference to the fifth implementation manner of the first aspect, in a sixth implementation manner of the first aspect, the quantizing parameter further includes an inter-frame quantizing parameter, and the determining, based on a preset model and the target bit number, the quantizing parameter corresponding to the current video frame further includes: when the current video frame is the inter-frame coded video frame, acquiring a peak noise ratio corresponding to the coded historical video frame and a compensation value of the intra-frame quantization parameter; determining the inter-frame quantization parameter based on the compensated value of the intra-frame quantization parameter.
According to the video coding method provided by the embodiment of the invention, the interframe quantization parameter and the intraframe quantization parameter are determined, and the interframe quantization parameter and the intraframe quantization parameter are coded by adopting the preset coding method, so that the coding of the current video frame is realized, and the video watching experience of a user is ensured.
According to a second aspect, an embodiment of the present invention provides a video encoding apparatus, including: the acquisition module is used for acquiring a target bit number, an actual bit number and a pixel number corresponding to a current video frame; the control module is used for controlling the actual bit number to track to the target bit number within the target time based on the error between the actual bit number and the target bit number; the determining module is used for determining a quantization parameter corresponding to the current video frame based on a preset model and the target bit number; and the coding module is used for coding the quantization parameter by adopting a preset coding method to obtain video coding information.
According to a third aspect, an embodiment of the present invention provides an electronic device, including: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory having stored therein computer instructions, and the processor executing the computer instructions to perform the video encoding method according to the first aspect or any of the embodiments of the first aspect.
According to a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, where computer instructions are stored, and the computer instructions are configured to cause a computer to execute the video encoding method according to the first aspect or any implementation manner of the first aspect.
It should be noted that, for corresponding beneficial effects of the video encoding apparatus, the electronic device and the computer-readable storage medium provided in the embodiment of the present invention, please refer to the description of corresponding contents in the video encoding method, which is not described herein again.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
Fig. 1 is a flowchart of a video encoding method according to an embodiment of the present invention;
fig. 2 is another flowchart of a video encoding method according to an embodiment of the present invention;
fig. 3 is still another flowchart of a video encoding method according to an embodiment of the present invention;
FIG. 4 is a block diagram of a video stream according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of a fixed-time sliding-mode controller according to an embodiment of the present invention;
fig. 6 is a block diagram of a structure of a video encoding apparatus according to an embodiment of the present invention;
fig. 7 is a schematic diagram of a hardware structure of an electronic device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In accordance with an embodiment of the present invention, there is provided an embodiment of video encoding, it should be noted that the steps illustrated in the flowchart of the figure may be performed in a computer system such as a set of computer executable instructions, and that while a logical order is illustrated in the flowchart, in some cases the steps illustrated or described may be performed in an order different than here.
In this embodiment, a video encoding method is provided, which can be used in electronic devices, such as mobile phones, tablet computers, and the like, fig. 1 is a flowchart of a video encoding method according to an embodiment of the present invention, as shown in fig. 1, the flowchart includes the following steps:
s11, acquiring a target bit number and an actual bit number corresponding to the current video frame.
The current video frame is a video frame to be encoded in a video encoding unit, the video encoding unit may be a Group of pictures (GOP), and the current video frame is one of the video frames to be encoded in the GOP.
The target number of bits represents the number of bits consumed to encode the current video frame. The electronic device can use an H0213 rate control algorithm in HEVC/H.265 coding to obtain the frame rate, the target bit rate and the picture quantity of the video frames in the current GOP, then obtain the corresponding target bit number in each GOP according to the frame rate, and allocate the corresponding target bit number for each video frame in the GOP.
The actual bit number is the bit number corresponding to the actually detected current video frame. The electronic equipment can monitor the video coding unit in real time, collect the number of bits actually distributed to the coding unit, and determine the actual number of bits distributed to each video frame in the coding unit.
And S12, controlling the actual bit number to track to the target bit number in the target time based on the error between the actual bit number and the target bit number.
And comparing the actual bit number with the target bit number, and determining the error between the actual bit number and the target bit number if the actual bit number is inconsistent with the target bit number. The target time is the time required for the actual bit number to converge to the target bit number, and the target time is the code rate control time.
Specifically, the electronic device may construct an adaptive relationship of the error and the target time based on a Fixed-time Sliding Model Controller (FSMC), so that the actual number of bits of the current video frame converges to a given target number of bits within a limited target time. For any actual number of bits, the actual number of bits can be controlled to converge to the target number of bits within the target time regardless of the error value of the current video frame. The target time is controllable and is determined by preset adjustment parameters in the adaptive relationship. The preset adjustment parameter is used for controlling the time when the actual bit number converges to the target bit number.
Specifically, as shown in fig. 5, the fixed-time sliding mode controller may be composed of two parts, i.e., a fixed-time sliding mode surface s and a sliding mode approach rate ∈:
Figure BDA0003773953450000061
Figure BDA0003773953450000062
wherein a, b, h, lambda, p, q, m and n are preset adjusting parameters, a is 0, b is 0, h is 0,0< lambda <1, p is q, m is n, p, q, m and n are positive odd numbers. The specific value of the preset adjustment parameter is not limited herein, and those skilled in the art can determine the value according to the environment and hardware factors in practical applications.
The fixed time sliding mode controller can control the fixed convergence of the fixed time sliding mode controller
Figure BDA0003773953450000063
Since the code rate required to be consumed for each video frame is fixed, the code rate unit is bit/second, thereby determining the convergence frame number j max Then, the target bit number converged currently by the current video frame is determined. Then, the convergence time, that is, the target time when the actual bit number is tracked to the target bit number, can be calculated according to the target bit number and the code rate.
And S13, determining a quantization parameter corresponding to the current video frame based on the preset model and the target bit number.
The quantization parameter is used to reflect the spatial detail compression of the video frame. The smaller the value of the quantization parameter is, the finer the quantization is, the higher the image quality is, and the longer the generated code stream is. The pre-set model is a model for calculating quantization parameters, such as a unified R-Q model at the pixel level.
The quantization parameters include an intra quantization parameter and an inter quantization parameter. The intra-frame quantization parameter is a quantization parameter corresponding to the current video frame, and the inter-frame quantization parameter is a quantization parameter between adjacent video frames.
Taking a unified R-Q model with a preset model as a pixel level as an example, after the current video frame is determined to be converged to a target bit number, the target bit number is input to the unified R-Q model, and then intra-frame quantization parameters can be obtained. And performing tuning compensation on the average intra-frame quantization parameter of the coded video frame according to the peak noise ratio of the coded video frame, so as to determine the inter-frame quantization parameter corresponding to the current video frame.
And S14, coding the quantization parameter by adopting a preset coding method to obtain video coding information.
The preset encoding method is a preset method for frame encoding. The preset encoding method may be h.261/h.263, h.264/AVC, h.264/SVC, HEVC/h.265, and the like, and is not specifically limited herein, and a person skilled in the art may select the encoding method according to actual requirements.
Taking HEVC/h.265 as an example, according to the intra-frame quantization parameter and the inter-frame quantization parameter of the current video frame obtained by calculation, an encoder in the HEVC/h.265 encoding method is used to perform encoding processing on the current video frame, so as to obtain video encoding information corresponding to the current video frame.
After the current video frame is coded, updating the bit number distribution weight of the video frame to be coded in the GOP, the error between the target bit number and the actual bit number, and the quantization parameter. And continuing to perform coding processing of the next frame or the next GOP according to the updated data until the coding processing of each video frame is completed, obtaining video coding information corresponding to each video frame, and generating a video stream based on the video coding information.
In the video encoding method provided in this embodiment, the actual bit number of the current video frame is controlled to track to the target bit number within the target time through the error between the actual bit number and the target bit number, and the corresponding quantization parameter is determined by combining the target bit number and the preset model, so as to perform encoding processing on the quantization parameter, thereby implementing encoding for the current video frame. Therefore, the bit number consumption of the video frame is not required to be adjusted by adopting a buffer area, the real-time response of the coding is improved, and the coding delay is reduced. Meanwhile, the target time of tracking to the target bit number is controlled by combining the error between the actual bit number and the target bit number, so that the adjustment of the video code rate control time is realized, the influence of the real-time change code rate error on video coding is eliminated, the jitter delay is avoided to the greatest extent, the coding efficiency is improved, and the watching experience of a user is ensured.
In this embodiment, a video encoding method is provided, which can be used in electronic devices, such as mobile phones, tablet computers, and the like, fig. 2 is a flowchart of the video encoding method according to an embodiment of the present invention, and as shown in fig. 2, the flowchart includes the following steps:
and S21, acquiring a target bit number and an actual bit number corresponding to the current video frame.
Specifically, the step S21 may include:
and S211, acquiring the actual bit number corresponding to the current video frame.
For a detailed description, refer to the corresponding related description of the above embodiments, which is not repeated herein.
S212, acquiring the bit number of the image group corresponding to the video coding unit. Wherein the group of pictures includes full frame compressed frames, forward predicted frames, and bi-directional predicted frames.
A plurality of GOPs are connected to form a video stream, and one GOP is generally composed of 1 full-frame compressed frame (I-frame), several bi-directional predicted frames (B-frames), and forward predicted frames (P-frames), as shown in the structure diagram of the video stream in fig. 4.
As an optional implementation manner, the step S212 may include:
(1) And acquiring the frame rate, the number of pictures and the target bit rate corresponding to the image group.
And acquiring the frame rate, the target bit rate and the number of pictures corresponding to the current GOP by using a code rate control method. For example, a rate control algorithm of H0213 in HEVC/h.265 coding is adopted to obtain a frame rate corresponding to a current GOP, a target bit rate, and the number of pictures included in the GOP.
(2) A ratio of the target bit rate to the frame rate is determined.
If the target bit rate of the obtained current image group is T rate Frame rate of F rate Then the ratio T of the target bit rate to the frame rate can be determined rate /F rate
(3) And determining the bit number corresponding to the image group based on the ratio and the number of pictures.
The expression for determining the bit number corresponding to the current image group according to the ratio and the number of pictures is as follows:
Figure BDA0003773953450000081
wherein, T GOP Denotes the number of bits allocated to the current GOP, F rate Indicating the frame rate of the current GOP, N GOP Indicates the number of pictures in the current GOP, T rate Representing the target bit rate of the current GOP.
Taking the video stream shown in fig. 4 as an example, the bit number corresponding to each GOP in the video stream can be obtained according to the above method.
S213, based on the bit number and the weight of the different types of coding frames in the image group, the target bit number of the current video frame is determined.
After the bit number of the current GOP is obtained, the bit number is distributed to the I frame, the B frame and the P frame contained in the current GOP according to the weight of the I frame, the B frame and the P frame contained in the current GOP in the GOP, and the target bit number corresponding to each video frame in the current GOP is obtained. Specifically, the expression for determining the target number of bits for each video frame is as follows:
Figure BDA0003773953450000091
wherein, T i,j Indicates the target number of bits for the jth frame in the ith GOP,
Figure BDA0003773953450000092
x in (B) represents the type of current video frame, which may be I, B or P,
Figure BDA0003773953450000093
respectively corresponding to the number of pictures of I frame, P frame and B frame,
Figure BDA0003773953450000094
i frame, P frame, B frame weights, respectively.
As an alternative, the weight of the P frame is used
Figure BDA0003773953450000095
For reference, the
Figure BDA0003773953450000096
Weight defaulted to 1,I frame
Figure BDA0003773953450000097
And weight of B frame
Figure BDA0003773953450000098
Can be determined by the following expression:
Figure BDA0003773953450000099
wherein, the first and the second end of the pipe are connected with each other,
Figure BDA00037739534500000910
average peak to noise ratios for coded I frames, P frames, and B frames respectively,
Figure BDA00037739534500000911
the average number of bits for I, P, and B frames.
Figure BDA00037739534500000912
And
Figure BDA00037739534500000913
all can be obtained by a rate control method (such as an H0213 rate control method in HEVC/h.265 coding).
And S22, controlling the actual bit number to track to the target bit number in the target time based on the error between the actual bit number and the target bit number.
Specifically, the step S22 may include:
s221, the current network throughput and the time delay variation of the adjacent video frame are obtained.
The current network throughput is the maximum rate at which video frames can be accepted without video frame loss. The delay variation is the delay difference of receiving adjacent video frames.
The electronic device may monitor the rate at which it receives video frames over a period, and determine a maximum rate, which is the current network throughput. And meanwhile, recording the receiving time of each video frame, determining the time delay difference between adjacent video frames, and determining the time delay difference as the time delay variation.
S222, constructing a self-adaptive relation among the current network throughput, the time delay variation of the adjacent video frames and the target time.
Based on the current network throughput, the delay variation of the adjacent video frames and the target time, a self-adaptive relationship is constructed by using a fixed time sliding mode surface, as shown in fig. 5. The expression of the adaptive relationship obtained by the fixed time sliding mode surface construction is as follows:
Figure BDA0003773953450000101
wherein, t c Representing a target time; w represents the current network throughput; Δ t s Representing the amount of delay variation. a. b is a preset adjustment parameter, and a>0,b>0。
And S223, controlling the target time of tracking the actual bit number to the target bit number based on the adaptive relation.
And when the network throughput is higher or the time delay variation is larger, adjusting the preset adjustment parameters according to the self-adaptive relation so as to realize the control of the target time. Meanwhile, the fixed-time sliding mode controller described in conjunction with the above embodiments can control the video frames to be fixed and converged to the frame number j max And the number of frames j max The code rate control method is determined by preset adjustment parameters, so that the influence of interference factors such as higher network throughput or larger delay variation on code rate control can be effectively inhibited on the basis of adjustable code rate control time, and the stability of code rate control is improved.
As an optional implementation, as shown in fig. 2, after step S22, the method may further include:
and S23, acquiring the average code rate of the coded historical video frame.
The encoded historical video frames are video frames in the GOP that have been encoded. Since the video frames which are not coded do not have the coding information, the video frames which are not coded and the coded video frames can be distinguished by detecting whether the video frames have the corresponding coding information or not. Average code rate passing target bit rate T rate And frame rate F rate Is determined, i.e. the average code rate is T rate /F rate
And S24, correcting the target bit number based on the average code rate.
The target bit number allocated to the current video frame is corrected, as shown in fig. 5, so that the target bit number does not exceed 2 times of the average bitrate corresponding to the encoded historical video frame and is not lower than 1/4 of the average bitrate of the encoded historical video frame, thereby preventing the viewing experience from being affected due to a large encoding difference between adjacent video frames.
The specific correction method is as follows:
T i,j =max{T rate /(4·F rate ),min{T i,j ,(2·T rate )/F rate }}
wherein, F rate Representing frame rate, T rate Representing the target bit rate.
And S25, determining a quantization parameter corresponding to the current video frame based on the preset model and the target bit number.
For detailed description, reference is made to the corresponding related description of the above embodiments, and details are not repeated herein.
And S26, coding the quantization parameter by adopting a preset coding method to obtain video coding information.
For a detailed description, refer to the corresponding related description of the above embodiments, which is not repeated herein.
The video coding method provided in this embodiment determines the target bit number of the current video frame by combining the bit number of the group of pictures and the proportion of different types of coded frames, so as to allocate an accurate target bit number to the current video frame. By constructing the self-adaptive relationship between the target time and the current network throughput and the time delay variation, on the basis of realizing the preset adjustment of the code rate control time, the influence of factors such as higher throughput or larger time delay variation on the code rate control can be effectively inhibited, the controllability of the code rate is improved, the code rate control process is smoother, and the fluency of video watching is improved. And correcting the target bit number of the current video frame through the average code rate of the coded historical video frame so as to ensure that the target bit number of the current video frame is in a reasonable interval and avoid the influence on the video picture quality caused by too large coding difference of the previous frame and the next frame.
In this embodiment, a video encoding method is provided, which can be used in electronic devices, such as mobile phones, tablet computers, and the like, fig. 3 is a flowchart of the video encoding method according to an embodiment of the present invention, as shown in fig. 3, the flowchart includes the following steps:
and S31, acquiring a target bit number and an actual bit number corresponding to the current video frame.
For a detailed description, refer to the corresponding related description of the above embodiments, which is not repeated herein.
And S32, controlling the actual bit number to track to the target bit number in the target time based on the error between the actual bit number and the target bit number.
For a detailed description, refer to the corresponding related description of the above embodiments, which is not repeated herein.
And S33, determining a quantization parameter corresponding to the current video frame based on the preset model and the target bit number.
Specifically, the quantization parameter includes an intra quantization parameter and an inter quantization parameter, and accordingly, the step S33 may include:
s331, determining whether the current video frame is an inter-frame encoded video frame.
The video frames coded between frames are the video frames which need to be coded by combining the adjacent video frames before and after. The electronic device detects an association between the current video frame and other video frames to determine whether the current video frame is an inter-coded video frame. If the current video frame is an intra-frame coded video frame, step S332 is executed, otherwise step S333 is executed.
And S332, calculating the intra-frame quantization parameter according to a preset model.
The preset model is a unified R-Q model at the pixel level. If the current video frame is the video frame coded in the frame, the coding of the current video frame is the coding of the current frame, and the coding information of other video frames does not need to be considered. Determining intra-frame quantization parameters using a unified R-Q model at the pixel level
Figure BDA0003773953450000111
The specific expression is as follows:
Figure BDA0003773953450000121
wherein N is i,j Representing the number of pixels of the current video frame; MAD i,j Representing the predicted mean absolute difference, l, of the current video frame i,j And h i,j And calculating the obtained R-Q model parameters after updating for each video frame.
S333, obtaining the peak noise ratio corresponding to the coded historical video frame and the compensation value of the intra-frame quantization parameter.
If the current video frame is an inter-coded video frame, determining a peak-to-noise ratio corresponding to the coded historical video frame by using a rate control method (e.g., a rate control method of HEVC/h.265).
Initial value Δ QP of compensation value Δ QP of intra-frame quantization parameter 0 1, as each video frame is encoded, the compensation value Δ QP of the intra-frame quantization parameter is updated, in the following manner:
ΔQP=ΔQP 0 +(PSNR i,j-1 -PSNR ave )/θ
wherein Δ QP represents a compensation value of an intra quantization parameter; PSNR i,j-1 Representing the peak to noise ratio of the previous video frame; PSNR ave Average peak to noise ratio for the encoded historical video frames; theta is a tuning parameter, the range of theta is 0-1, and tuning can be performed according to actual requirements.
S334, the inter-frame quantization parameter is determined based on the compensation value of the intra-frame quantization parameter.
The interframe quantization parameter is determined as follows:
Figure BDA0003773953450000122
wherein the content of the first and second substances,
Figure BDA0003773953450000123
representing an interframe quantization parameter corresponding to the current video frame;
Figure BDA0003773953450000124
representing an inter-frame quantization parameter average of the encoded historical video frames; Δ QP denotes a compensation value of an intra quantization parameter.
And S34, coding the quantization parameter by adopting a preset coding method to obtain video coding information.
For a detailed description, refer to the corresponding related description of the above embodiments, which is not repeated herein.
According to the video coding method provided by the embodiment, the interframe quantization parameter and the intraframe quantization parameter are determined, and the interframe quantization parameter and the intraframe quantization parameter are coded by adopting the preset coding method, so that the coding of the current video frame is realized, and the video watching experience of a user is ensured.
In this embodiment, a video encoding apparatus is further provided, which is used to implement the foregoing embodiments and preferred embodiments, and the description of which is already given is omitted. As used below, the term "module" may be a combination of software and/or hardware that implements a predetermined function. Although the means described in the embodiments below are preferably implemented in software, implementations in hardware or a combination of software and hardware are also possible and contemplated.
The present embodiment provides a video encoding apparatus, as shown in fig. 6, including:
the obtaining module 41 is configured to obtain a target bit number and an actual bit number corresponding to a current video frame.
And the control module 42 is configured to control the actual bit number to track to the target bit number within the target time based on an error between the actual bit number and the target bit number.
And a determining module 43, configured to determine a quantization parameter corresponding to the current video frame based on the preset model and the target bit number.
And the encoding module 44 is configured to perform encoding processing on the quantization parameter by using a preset encoding method to obtain video encoding information.
Optionally, the obtaining module 41 may include:
and the first obtaining submodule is used for obtaining the actual bit number corresponding to the current video frame.
And the second acquisition submodule is used for acquiring the bit number of the image group corresponding to the video coding unit. Wherein the group of pictures includes full frame compressed frames, forward predicted frames, and bi-directional predicted frames.
And the first determining submodule is used for determining the target bit number of the current video frame based on the bit number and the weight of the different types of coded frames in the image group.
Specifically, the second obtaining module is configured to obtain a frame rate, a number of pictures, and a target bit rate corresponding to the image group; determining a ratio of a target bit rate to a frame rate; and determining the bit number corresponding to the image group based on the ratio and the number of pictures.
Optionally, the control module 42 may include:
and the third acquisition submodule is used for acquiring the current network throughput and the time delay variation of the adjacent video frame.
And the construction submodule is used for constructing the self-adaptive relationship between the current network throughput, the time delay variation of the adjacent video frame and the target time.
And the tracking submodule is used for controlling the target time of tracking the actual bit number to the target bit number based on the self-adaptive relation.
Optionally, the video encoding apparatus may further include:
and the code rate obtaining module is used for obtaining the average code rate of the coded historical video frame.
And the correcting module is used for correcting the target bit number based on the average code rate.
Optionally, the quantization parameter includes an intra quantization parameter and an inter quantization parameter, and accordingly, the determining module 43 may include:
and the judging submodule is used for judging whether the current video frame is an interframe coded video frame.
And the first calculation submodule is used for calculating the intra-frame quantization parameter according to a preset model if the current video frame is an intra-frame coded video frame.
And the second determining submodule is used for acquiring a peak noise ratio corresponding to the coded historical video frame and a compensation value of an intra-frame quantization parameter if the current video frame is an inter-frame coded video frame.
And the third determining sub-module is used for determining the inter-frame quantization parameter based on the compensation value of the intra-frame quantization parameter.
The video coding apparatus in this embodiment is presented in the form of functional units, where a unit refers to an ASIC circuit, a processor and memory executing one or more software or fixed programs, and/or other devices that may provide the above-described functionality.
Further functional descriptions of the modules are the same as those of the corresponding embodiments, and are not repeated herein.
The video encoding device provided in this embodiment controls the actual bit number of the current video frame to track to the target bit number within the target time through the error between the actual bit number and the target bit number, determines the corresponding quantization parameter by combining the target bit number and the preset model, and performs encoding processing on the quantization parameter, thereby implementing encoding for the current video frame. Therefore, the bit number consumption of the video frame is not required to be adjusted by adopting a buffer area, the real-time response of the coding is improved, and the coding delay is reduced. Meanwhile, the target time of tracking to the target bit number is controlled by combining the error between the actual bit number and the target bit number, so that the adjustment of the video code rate control time is realized, the influence of the real-time change code rate error on video coding is eliminated, the jitter delay is avoided to the greatest extent, the coding efficiency is improved, and the watching experience of a user is ensured.
An embodiment of the present invention further provides an electronic device, which has the video encoding apparatus shown in fig. 6.
Referring to fig. 7, fig. 7 is a schematic structural diagram of an electronic device according to an alternative embodiment of the present invention, and as shown in fig. 7, the electronic device may include: at least one processor 501, such as a Central Processing Unit (CPU), at least one communication interface 503, memory 504, and at least one communication bus 502. Wherein a communication bus 502 is used to enable the connection communication between these components. The communication interface 503 may include a Display (Display) and a Keyboard (Keyboard), and the optional communication interface 503 may also include a standard wired interface and a standard wireless interface. The Memory 504 may be a high-speed volatile Random Access Memory (RAM) or a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. The memory 504 may alternatively be at least one memory device located remotely from the processor 501. Wherein the processor 501 may be in connection with the apparatus described in fig. 6, an application program is stored in the memory 504, and the processor 501 calls the program code stored in the memory 504 for performing any of the method steps described above.
The communication bus 502 may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus 502 may be divided into an address bus, a data bus, a control bus, and the like. For ease of illustration, only one thick line is shown in FIG. 7, but that does not indicate only one bus or one type of bus.
The memory 504 may include a volatile memory (volatile memory), such as a random-access memory (RAM); the memory may also include a non-volatile memory (non-volatile memory), such as a flash memory (flash memory), a Hard Disk Drive (HDD) or a solid-state drive (SSD); the memory 504 may also comprise a combination of the above-described types of memory.
The processor 501 may be a Central Processing Unit (CPU), a Network Processor (NP), or a combination of a CPU and an NP.
The processor 501 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a Programmable Logic Device (PLD), or a combination thereof. The PLD may be a Complex Programmable Logic Device (CPLD), a field-programmable gate array (FPGA), a General Array Logic (GAL), or any combination thereof.
Optionally, the memory 504 is also used to store program instructions. The processor 501 may call program instructions to implement the video encoding method as shown in the embodiments of fig. 1 to 3 of the present application.
Embodiments of the present invention further provide a non-transitory computer storage medium, where the computer storage medium stores computer-executable instructions, and the computer-executable instructions may execute the video encoding method in any of the above method embodiments. The storage medium may be a magnetic Disk, an optical Disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a Flash Memory (Flash Memory), a Hard Disk (Hard Disk Drive, HDD), a Solid-State Drive (SSD), or the like; the storage medium may also comprise a combination of memories of the kind described above.
Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the invention, and such modifications and variations fall within the scope defined by the appended claims.

Claims (10)

1. A video encoding method, comprising:
acquiring a target bit number and an actual bit number corresponding to a current video frame;
controlling the actual bit number to track to the target bit number in the target time based on the error between the actual bit number and the target bit number;
determining a quantization parameter corresponding to the current video frame based on a preset model and the target bit number;
and coding the quantization parameter by adopting a preset coding method to obtain video coding information.
2. The method of claim 1, wherein obtaining the target number of bits corresponding to the current video frame comprises:
acquiring the bit number of a group of pictures corresponding to a video coding unit, wherein the group of pictures comprises a full-frame compressed frame, a forward predicted frame and a bidirectional predicted frame;
and determining the target bit number of the current video frame based on the bit number and the weight of the coding frames of different types in the image group.
3. The method according to claim 2, wherein said obtaining the number of bits of the group of pictures corresponding to the video coding unit comprises:
acquiring a frame rate, a picture quantity and a target bit rate corresponding to the image group;
determining a ratio of the target bit rate to the frame rate;
and determining the bit number corresponding to the image group based on the ratio and the number of the pictures.
4. The method of claim 1, wherein the controlling the actual number of bits to track to the target number of bits within a target time based on an error between the actual number of bits and the target number of bits comprises:
acquiring the current network throughput and a preset adjustment parameter of the time delay variation of an adjacent video frame;
constructing a self-adaptive relation between the current network throughput, the time delay variation of the adjacent video frames and the target time;
and controlling the actual bit number to track to the target time of the target bit number based on the self-adaptive relation.
5. The method of claim 4, further comprising:
acquiring the average code rate of the coded historical video frame;
and correcting the target bit number based on the average code rate.
6. The method according to claim 1, wherein the quantization parameter comprises an intra-frame quantization parameter, and the determining the quantization parameter corresponding to the current video frame based on the preset model and the target bit number comprises:
judging whether the current video frame is an interframe coded video frame;
and when the current video frame is the video frame coded in the frame, calculating an intra-frame quantization parameter according to the preset model.
7. The method according to claim 6, wherein the quantization parameters further include an inter-frame quantization parameter, and the determining the quantization parameter corresponding to the current video frame based on the preset model and the target bit number further includes:
when the current video frame is the inter-frame coded video frame, acquiring a peak noise ratio corresponding to the coded historical video frame and a compensation value of the intra-frame quantization parameter;
determining the inter-frame quantization parameter based on the compensated value of the intra-frame quantization parameter.
8. A video encoding apparatus, comprising:
the acquisition module is used for acquiring a target bit number and an actual bit number corresponding to a current video frame;
the control module is used for controlling the actual bit number to track to the target bit number within the target time based on the error between the actual bit number and the target bit number;
the determining module is used for determining a quantization parameter corresponding to the current video frame based on a preset model and the target bit number;
and the coding module is used for coding the quantization parameter by adopting a preset coding method to obtain video coding information.
9. An electronic device, comprising:
a memory and a processor, the memory and the processor being communicatively coupled to each other, the memory having stored therein computer instructions, the processor performing the video encoding method of any of claims 1-7 by executing the computer instructions.
10. A computer-readable storage medium having stored thereon computer instructions for causing a computer to perform the video encoding method of any one of claims 1-7.
CN202210911012.4A 2022-07-29 2022-07-29 Video coding method and device, electronic equipment and readable storage medium Pending CN115499654A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210911012.4A CN115499654A (en) 2022-07-29 2022-07-29 Video coding method and device, electronic equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210911012.4A CN115499654A (en) 2022-07-29 2022-07-29 Video coding method and device, electronic equipment and readable storage medium

Publications (1)

Publication Number Publication Date
CN115499654A true CN115499654A (en) 2022-12-20

Family

ID=84467116

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210911012.4A Pending CN115499654A (en) 2022-07-29 2022-07-29 Video coding method and device, electronic equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN115499654A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117278538A (en) * 2023-11-22 2023-12-22 荣耀终端有限公司 Method for adjusting parameters of encoder and electronic equipment

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117278538A (en) * 2023-11-22 2023-12-22 荣耀终端有限公司 Method for adjusting parameters of encoder and electronic equipment
CN117278538B (en) * 2023-11-22 2024-04-16 荣耀终端有限公司 Method for adjusting parameters of encoder and electronic equipment

Similar Documents

Publication Publication Date Title
JP5676705B2 (en) Improved video rate control for video coding standards
WO2021244341A1 (en) Picture coding method and apparatus, electronic device and computer readable storage medium
CN109862359B (en) Code rate control method and device based on layered B frame and electronic equipment
KR101518358B1 (en) A buffer-based rate control exploiting frame complexity buffer level and position of intra frames in video coding
US20060056508A1 (en) Video coding rate control
CN109729437B (en) Streaming media self-adaptive transmission method, terminal and system
EP1745653A2 (en) Encoder with adaptive rate control for h.264
US8811472B2 (en) Bitrate control device for controlling bitrate of video data
CN107509120A (en) A kind of streaming media self-adapting transmission method based on buffer underflow probability Estimation
JP3907875B2 (en) Coding rate control device and information coding device
CN115499654A (en) Video coding method and device, electronic equipment and readable storage medium
WO2009149564A1 (en) Method and device for controlling bit-rate for video encoding, video encoding system using same and computer product therefor
WO2022228375A1 (en) Video coding method and apparatus, and electronic device
KR20120096863A (en) Rate control for hierarchical coding structure in high efficiency video coding(hevc)
CN101527846B (en) H.264 variable bit rate control method based on Matthew effect
US6661926B1 (en) Picture compression process, especially of the MPEG2 type
Tsai Rate control for low-delay video using a dynamic rate table
JP5006763B2 (en) Image encoding apparatus, control method therefor, and computer program
CN111541898A (en) Method, device, server and storage medium for determining coding mode
JP4936557B2 (en) Encoder
Chen et al. Framework and Challenges: H. 265/HEVC Rate Control in Real-time Transmission over 5G Mobile Networks
US9237347B2 (en) Systems and methods for video compression for low bit rate and low latency video communications
CN115118975A (en) Code rate control method and device for video coding
Jamali et al. A Parametric Rate-Distortion Model for Video Transcoding
Park PSNR-based initial QP determination for low bit rate video coding

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