Video encoding method, device, electronic device and readable storage medium

By controlling the actual number of bits of the video frame to track the target number of bits in the video encoding method, and determining the quantization parameters in combination with the preset model, the problem of uncontrollable bit rate control time in the prior art is solved, and the controllability and user experience of bit rate control are achieved.

CN115499654BActive Publication Date: 2025-04-22CHINA TELECOM CLOUD TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210911012.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-29
Publication Date
2025-04-22
Estimated Expiration
2042-07-29

AI Technical Summary

Technical Problem

The existing video encoding methods cause uncontrollable code rate control time during the code rate control process, resulting in jitter delay, and seriously affecting the user's viewing experience.

Method used

By obtaining the error between the target number of bits and the actual number of bits of the current video frame, the actual number of bits is controlled to track to the target number of bits within the target time, and the quantization parameters are determined in combination with the preset model, and the preset encoding method is used for encoding processing.

Benefits of technology

The controllability of the bit rate control time is realized, the impact of real-time changing bit rate error on video encoding is eliminated, the jitter delay is avoided to the greatest extent, the encoding efficiency is improved, and the user's viewing experience is ensured.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115499654B_ABST
    Figure CN115499654B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of streaming media video encoding and bit rate control, and discloses a video encoding method, device, electronic device and readable storage medium. The method includes: obtaining the target bit number and the actual bit number corresponding to the current video frame; based on the error between the actual bit number and the target bit number, controlling the actual bit number to track to the target bit number within the target time; based on the preset model and the target bit number, determining the quantization parameter corresponding to the current video frame; using the preset encoding method to encode the quantization parameter to obtain video encoding information. By implementing the present invention, there is no need to use a buffer to adjust the bit number consumption of the video frame, which improves the real-time response of the encoding, reduces the encoding delay, realizes the controllable adjustment of the bit rate control time, eliminates the influence of the real-time changing bit rate error on the video encoding, avoids the jitter delay to the greatest extent, improves the encoding efficiency, and ensures the user's viewing experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of streaming media video encoding and bit rate control, and in particular to a video encoding method, device, electronic equipment and readable storage medium. Background Art

[0002] The transmission of streaming media in video applications requires the video to be compressed first, and the video bit rate is controlled in real time according to the current network throughput and buffer size to ensure smooth video playback. Therefore, bit rate control plays a vital role in video compression, and a reasonable bit rate control strategy can significantly improve the user's viewing experience.

[0003] The rate control process can be divided into two parts: allocating the number of bits consumed for the coding unit; determining the relationship between the number of bits consumed by the coding unit and the image distortion rate by calculating the quantization parameter (QP) of the coding unit, and then encoding the coding unit through the model. The current video coding method uses a buffer to ensure the smoothness of the rate control process during the rate control process, and linearly adjusts the bit consumption of the 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 and HEVC / H.265. These coding methods can only reduce the control error, but cannot actually eliminate this error.

[0004] However, the error between the target bit rate and the actual bit rate in the actual control process changes in real time. There are also interferences such as the current network throughput, latency, and buffer size. These will lead to uncontrollable bit rate control time, resulting in jitter delays of varying magnitudes, which seriously affects the user's viewing experience. Summary of the invention

[0005] In view of this, embodiments of the present invention provide a video encoding method, apparatus, electronic device, and readable storage medium to solve the problem that the bit rate control time is uncontrollable due to the existing video encoding method.

[0006] According to the first aspect, an embodiment of the present invention provides a video encoding method, including: obtaining a target bit number and an actual bit number corresponding to a current video frame; based on an error between the actual bit number and the target bit number, controlling the actual bit number to track to the target bit number within a target time; based on a preset model and the target bit number, determining a quantization parameter corresponding to the current video frame; and encoding the quantization parameter using a preset encoding method to obtain video encoding information.

[0007] The video encoding method provided by the embodiment of the present invention controls the actual number of bits of the current video frame to track to the target number of bits within the target time through the error between the actual number of bits and the target number of bits, determines the corresponding quantization parameter in combination with the target number of bits and the preset model, and performs encoding processing on the quantization parameter to achieve encoding for the current video frame. As a result, there is no need to use a buffer to adjust the bit consumption of the video frame, which improves the real-time response of the encoding and reduces the encoding delay. At the same time, the error between the actual number of bits and the target number of bits is combined to control the target time to track to the target number of bits, thereby achieving the adjustment of the video bit rate control time, eliminating the impact of the real-time changing bit rate error on the video encoding, avoiding jitter delay to the greatest extent, improving the encoding efficiency, and ensuring the user's viewing experience.

[0008] In combination with the first aspect, in a first implementation of the first aspect, obtaining a target number of bits corresponding to a current video frame includes: obtaining the number of bits of an image group corresponding to a video encoding unit, the image group including a full-frame compressed frame, a forward prediction frame, and a bidirectional prediction frame; determining the target number of bits of the current video frame based on the number of bits and the weights of different types of encoded frames in the image group.

[0009] In combination with the first implementation of the first aspect, in the second implementation of the first aspect, obtaining the number of bits of the image group corresponding to the video encoding unit includes: obtaining the frame rate, the number of pictures and the target bit rate corresponding to the image group; determining the ratio of the target bit rate to the frame rate; and determining the number of bits corresponding to the image group based on the ratio and the number of pictures.

[0010] The video encoding method provided by the embodiment of the present invention determines the target bit number of the current video frame in combination with the bit number of the image group and the proportion of different types of encoded frames, so as to allocate an accurate target bit number for the current video frame.

[0011] In combination with the first aspect, in a third implementation of the first aspect, the actual bit number is controlled 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, including: obtaining the current network throughput, the delay change of adjacent video frames and preset adjustment parameters, the preset adjustment parameters are used to control the time for the actual bit number to converge to the target bit number; constructing an adaptive relationship between the current network throughput, the delay change of adjacent video frames 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 adaptive relationship.

[0012] The video encoding method provided by the embodiment of the present invention can effectively suppress the influence of factors such as high throughput or large delay variation on the bit rate control by constructing an adaptive relationship between the target time and the current network throughput and the delay variation, while realizing the preset adjustment of the bit rate control time, thereby improving the controllability of the bit rate, making the bit rate control process smoother and improving the fluency of video viewing.

[0013] In combination with the third implementation of the first aspect, in the fourth implementation of the first aspect, the method further includes: obtaining an average bit rate of encoded historical video frames; and correcting the target number of bits based on the average bit rate.

[0014] The video encoding method provided by the embodiment of the present invention corrects the target bit number of the current video frame by the average bit rate of the encoded historical video frames to ensure that the target bit number of the current video frame is within a reasonable range, thereby avoiding that the encoding difference between the previous and next frames is too large to affect the video picture quality.

[0015] In combination with the first aspect, in the fifth implementation of the first aspect, the quantization parameter includes an intra-frame quantization parameter, and determining the quantization parameter corresponding to the current video frame based on the preset model and the target number of bits includes: determining whether the current video frame is an inter-frame coded video frame; when the current video frame is the intra-frame coded video frame, calculating the intra-frame quantization parameter according to the preset model.

[0016] In combination with the fifth implementation of the first aspect, in the sixth implementation of the first aspect, the quantization parameter also includes an inter-frame quantization parameter, and determining the quantization parameter corresponding to the current video frame based on the preset model and the target number of bits also includes: when the current video frame is the inter-frame encoded video frame, obtaining the peak noise ratio corresponding to the encoded historical video frame and the compensation value of the intra-frame quantization parameter; determining the inter-frame quantization parameter based on the compensation value of the intra-frame quantization parameter.

[0017] The video encoding method provided by the embodiment of the present invention realizes encoding of the current video frame by determining the inter-frame quantization parameter and the intra-frame quantization parameter, and encoding the inter-frame quantization parameter and the intra-frame quantization parameter using a preset encoding method, thereby ensuring the user's video viewing experience.

[0018] According to the second aspect, an embodiment of the present invention provides a video encoding device, including: an acquisition module, used to obtain a target bit number, an actual bit number and a pixel number corresponding to a current video frame; a control module, used to control 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; a determination module, used to determine a quantization parameter corresponding to the current video frame based on a preset model and the target bit number; and an encoding module, used to encode the quantization parameter using a preset encoding method to obtain video encoding information.

[0019] According to the third aspect, an embodiment of the present invention provides an electronic device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the video encoding method described in the first aspect or any embodiment of the first aspect by executing the computer instructions.

[0020] According to a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the video encoding method described in the first aspect or any implementation of the first aspect.

[0021] It should be noted that, for the corresponding beneficial effects of the video encoding device, electronic device, and computer-readable storage medium provided by the embodiments of the present invention, please refer to the description of the corresponding contents in the video encoding method, which will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0023] Figure 1 is a flowchart of a video encoding method according to an embodiment of the present invention;

[0024] Figure 2 is another flow chart of a video encoding method according to an embodiment of the present invention;

[0025] Figure 3 is another flow chart of a video encoding method according to an embodiment of the present invention;

[0026] Figure 4 is a structural diagram of a video stream according to an embodiment of the present invention;

[0027] Figure 5 is a schematic diagram of a fixed-time sliding mode controller according to an embodiment of the present invention;

[0028] Figure 6 is a structural block diagram of a video encoding device according to an embodiment of the present invention;

[0029] Figure 7 It is a schematic diagram of the hardware structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0030] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0031] According to an embodiment of the present invention, an embodiment of video encoding is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0032] In this embodiment, a video encoding method is provided, which can be used in electronic devices such as mobile phones, tablet computers, computers, etc. Figure 1 is a flowchart of a video encoding method according to an embodiment of the present invention. Figure 1 As shown, the process includes the following steps:

[0033] S11, obtaining a target bit number and an actual bit number corresponding to the current video frame.

[0034] 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 (Group of picture, GOP), and the current video frame is a video frame to be encoded in the GOP.

[0035] The target number of bits indicates the number of bits consumed to encode the current video frame. The electronic device can use the H0213 rate control algorithm in HEVC / H.265 encoding to obtain the frame rate, target bit rate and number of pictures of the video frame in the current GOP, and then obtain the corresponding target number of bits in each GOP, and allocate the corresponding target number of bits to each video frame in the GOP.

[0036] The actual number of bits is the number of bits corresponding to the current video frame actually detected. The electronic device can monitor the video encoding unit in real time, collect the number of bits actually allocated to the encoding unit, and determine the actual number of bits allocated to each video frame in the encoding unit.

[0037] S12, based on the error between the actual number of bits and the target number of bits, controlling the actual number of bits to track to the target number of bits within a target time.

[0038] The actual number of bits is compared with the target number of bits. If the actual number of bits is inconsistent with the target number of bits, the error between the actual number of bits and the target number of bits is determined. The target time is the time required for the actual number of bits to converge to the target number of bits, and the target time is the rate control time.

[0039] Specifically, the electronic device can construct an adaptive relationship between the error and the target time based on a fixed-time sliding mode 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, no matter what the error value of the current video frame is, its actual number of bits can be controlled to converge to the target number of bits within the target time. The target time is controllable and is determined by a preset adjustment parameter in the adaptive relationship. Among them, the preset adjustment parameter is used to control the time for the actual number of bits to converge to the target number of bits.

[0040] Specifically, Figure 5 As shown in Figure 2, the fixed-time sliding mode controller can be composed of two parts: the fixed-time sliding mode surface s and the sliding mode approach rate ε:

[0041]

[0042]

[0043] Wherein, a, b, h, λ, p, q, m and n are preset adjustment parameters, a>0, b>0, h>0, 0<λ<1, p>q, m>n, and p, q, m, n are all positive odd numbers. The specific values ​​of the preset adjustment parameters are not limited here, and those skilled in the art can determine them according to the environment and hardware factors in actual applications.

[0044] The fixed-time sliding mode controller can control its fixed convergence to Since the bit rate required for each video frame is fixed and the bit rate unit is bit / second, the convergence frame number j is determined. max After that, the target bit number of the current video frame is also determined. Then, the convergence time can be calculated according to the target bit number and the bit rate, that is, the target time for the actual bit number to track to the target bit number.

[0045] S13, determining a quantization parameter corresponding to the current video frame based on a preset model and a target bit number.

[0046] The quantization parameter is used to reflect the compression of spatial details of the video frame. The smaller the value of the quantization parameter, the finer the quantization, the higher the image quality, and the longer the generated bitstream. The preset model is a model used to calculate the quantization parameter, such as a unified RQ model at the pixel level.

[0047] The quantization parameters include intra-frame quantization parameters and inter-frame quantization parameters. The intra-frame quantization parameter is the quantization parameter corresponding to the current video frame, and the inter-frame quantization parameter is the quantization parameter between adjacent video frames.

[0048] Taking the pixel-level unified RQ model as an example, after determining that the current video frame converges to the target bit number, the target bit number is input into the unified RQ model to obtain the intra-frame quantization parameter. According to the peak noise ratio of the encoded video frame, the average intra-frame quantization parameter of the encoded video frame is tuned and compensated to determine the inter-frame quantization parameter corresponding to the current video frame.

[0049] S14, using a preset encoding method to encode the quantization parameter to obtain video encoding information.

[0050] The preset encoding method is a pre-set method for frame encoding. The preset encoding method may be H.261 / H.263, H.264 / AVC, H.264 / SVC, and HEVC / H.265, etc., which are not specifically limited here, and those skilled in the art may select the encoding method according to actual needs.

[0051] Taking HEVC / H.265 as an example, according to the calculated intra-frame quantization parameter and inter-frame quantization parameter of the current video frame, the encoder in the HEVC / H.265 encoding method is used to encode the current video frame to obtain video encoding information corresponding to the current video frame.

[0052] After the encoding of the current video frame is completed, the bit number allocation weight, the error between the target bit number and the actual bit number, and the quantization parameter of the video frame to be encoded in the GOP are updated. The encoding process of the next frame or the next GOP is continued according to the updated data until the encoding process of each video frame is completed, the video encoding information corresponding to each video frame is obtained, and a video stream is generated based on the video encoding information.

[0053] The video encoding method provided in this embodiment controls the actual number of bits of the current video frame to track to the target number of bits within the target time through the error between the actual number of bits and the target number of bits, determines the corresponding quantization parameter in combination with the target number of bits and the preset model, and performs encoding processing on the quantization parameter to achieve encoding for the current video frame. As a result, there is no need to use a buffer to adjust the bit consumption of the video frame, which improves the real-time response of the encoding and reduces the encoding delay. At the same time, the error between the actual number of bits and the target number of bits is combined to control the target time to track to the target number of bits, thereby achieving the adjustment of the video bit rate control time, eliminating the impact of the real-time changing bit rate error on the video encoding, avoiding jitter delay to the greatest extent, improving the encoding efficiency, and ensuring the user's viewing experience.

[0054] In this embodiment, a video encoding method is provided, which can be used in electronic devices such as mobile phones, tablet computers, computers, etc. Figure 2 is a flowchart of a video encoding method according to an embodiment of the present invention. Figure 2 As shown, the process includes the following steps:

[0055] S21, obtaining a target number of bits and an actual number of bits corresponding to the current video frame.

[0056] Specifically, the above step S21 may include:

[0057] S211, obtaining the actual number of bits corresponding to the current video frame.

[0058] For detailed description, please refer to the relevant description corresponding to the above embodiments, which will not be repeated here.

[0059] S212, obtaining the bit number of the picture group corresponding to the video encoding unit, wherein the picture group includes a full-frame compression frame, a forward prediction frame, and a bidirectional prediction frame.

[0060] Multiple GOPs are connected to form a video stream. A GOP is usually composed of a full-frame compressed frame (intra picture, I frame), several bi-directional interpolated prediction frames (bi-directional interpolated prediction frames, B frames) and forward prediction frames (predictive-frame, P frame), such as Figure 4 The video stream structure diagram is shown.

[0061] As an optional implementation, the above step S212 may include:

[0062] (1) Obtain the frame rate, number of pictures, and target bit rate corresponding to the image group.

[0063] The frame rate, target bit rate and number of pictures corresponding to the current GOP are collected using the rate control method. For example, the H0213 rate control algorithm in HEVC / H.265 encoding is used to obtain the frame rate, target bit rate and number of pictures corresponding to the current GOP.

[0064] (2) Determine the ratio of the target bit rate to the frame rate.

[0065] If the target bit rate of the current image group is T rate , the frame rate is F rate , the ratio of the target bit rate to the frame rate T can be determined rate / F rate .

[0066] (3) Based on the ratio and the number of pictures, determine the number of bits corresponding to the image group.

[0067] The expression for determining the number of bits corresponding to the current image group based on the ratio and the number of pictures is as follows:

[0068]

[0069] Among them, T GOP Indicates the number of bits allocated to the current GOP, F rate Indicates the frame rate of the current GOP, N GOP Indicates the number of pictures in the current GOP, T rate Indicates the target bit rate of the current GOP.

[0070] by Figure 4 Taking the video stream shown in FIG. 1 as an example, the number of bits corresponding to each GOP in the video stream can be obtained according to the above method.

[0071] S213, determining a target number of bits for the current video frame based on the number of bits and the weights of different types of coded frames in the group of pictures.

[0072] After the number of bits of the current GOP is obtained, the number of bits is allocated to the I frames, B frames and P frames contained in the current GOP according to the weights of the I frames, B frames and P frames contained in the current GOP, and the target number of bits corresponding to each video frame in the current GOP is obtained. Specifically, the expression for determining the target number of bits of each video frame is as follows:

[0073]

[0074] Among them, T i,j represents the target number of bits for the jth frame in the i-th GOP, The X in the video indicates the type of the current video frame, which can be I, B or P. The number of pictures corresponding to I frames, P frames, and B frames respectively. They are the weights of I-frame, P-frame and B-frame respectively.

[0075] As an optional implementation, the weight of the P frame For reference, the The default value is 1, the weight of I frame and the weight of B frame It can be determined by the following expression:

[0076]

[0077] in, are the average peak-to-noise ratios of the encoded I-frames, P-frames, and B-frames, respectively. It is the average number of bits of I frame, P frame and B frame. and Both can be obtained through rate control methods (such as the H0213 rate control method in HEVC / H.265 encoding).

[0078] S22, based on the error between the actual number of bits and the target number of bits, controlling the actual number of bits to track to the target number of bits within a target time.

[0079] Specifically, the above step S22 may include:

[0080] S221, obtaining the current network throughput and the delay variation of adjacent video frames.

[0081] The current network throughput is the maximum rate of video frames that can be received without video frame loss. The delay variation is the delay difference between receiving adjacent video frames.

[0082] The electronic device can monitor the rate at which it receives video frames within a certain period, and determine the maximum rate, which is the current network throughput. At the same time, the reception time of each video frame is recorded, the delay difference between adjacent video frames is determined, and the delay difference is determined as the delay variation.

[0083] S222, constructing an adaptive relationship between the current network throughput, the delay variation of adjacent video frames and the target time.

[0084] Based on the current network throughput, the delay variation of adjacent video frames and the target time, a fixed-time sliding surface is used to construct their adaptive relationship, such as Figure 5 As shown. The expression of the adaptive relationship obtained by constructing the fixed time sliding surface is:

[0085]

[0086] Among them, t crepresents the target time; w represents the current network throughput; Δt s Indicates the delay variation. a and b are preset adjustment parameters, and a>0, b>0.

[0087] S223, controlling the actual number of bits to track to a target time of a target number of bits based on the adaptive relationship.

[0088] When the network throughput is high or the delay variation is large, the preset adjustment parameters are adjusted according to the adaptive relationship to achieve control of the target time. At the same time, the fixed time sliding mode controller described in the above embodiment can control the video frame to converge to the fixed frame number j. max , and the frame number j max It is determined by the preset adjustment parameters. Therefore, on the basis of the adjustable bit rate control time, it can effectively suppress the influence of interference factors such as high network throughput or large delay variation on bit rate control, thereby improving the stability of bit rate control.

[0089] As an optional implementation, Figure 2 As shown, after step S22, the method may further include:

[0090] S23, obtaining the average bit rate of the encoded historical video frames.

[0091] The encoded historical video frames are the video frames that have been encoded in the GOP. Since the unencoded video frames do not have any encoding information, the unencoded video frames and the encoded video frames can be distinguished by detecting whether the video frames have corresponding encoding information. The average bit rate is calculated by the target bit rate T rate With frame rate F rate The ratio is determined by the average bit rate, that is, T rate / F rate .

[0092] S24, correcting the target number of bits based on the average bit rate.

[0093] Correct the target number of bits allocated to the current video frame, such as Figure 5 As shown, it shall not exceed twice the average bit rate corresponding to the encoded historical video frames, and shall not be lower than 1 / 4 of the average bit rate of the encoded historical video frames, so as to prevent large differences in encoding of adjacent video frames and affect the viewing experience.

[0094] The specific correction methods are as follows:

[0095] T i,j =max{T rate / (4·F rate ),min{T i,j ,(2·T rate ) / F rate}}

[0096] Among them, F rate Indicates the frame rate, T rate Indicates the target bit rate.

[0097] S25, determining a quantization parameter corresponding to the current video frame based on a preset model and a target bit number.

[0098] For detailed description, please refer to the relevant description corresponding to the above embodiments, which will not be repeated here.

[0099] S26, using a preset encoding method to encode the quantization parameter to obtain video encoding information.

[0100] For detailed description, please refer to the relevant description corresponding to the above embodiments, which will not be repeated here.

[0101] The video encoding method provided in this embodiment determines the target number of bits of the current video frame in combination with the number of bits of the image group and the proportion of different types of encoded frames, so as to allocate an accurate target number of bits to the current video frame. By constructing an adaptive relationship between the target time and the current network throughput and the delay variation, on the basis of realizing the preset adjustment of the bit rate control time, it can effectively suppress the influence of factors such as high throughput or large delay variation on the bit rate control, improve the controllability of the bit rate, make the bit rate control process smoother, and improve the fluency of video viewing. The target number of bits of the current video frame is corrected by the average bit rate of the encoded historical video frames to ensure that the target number of bits of the current video frame is in a reasonable range, so as to avoid the encoding difference between the previous and next frames being too large to affect the video picture quality.

[0102] In this embodiment, a video encoding method is provided, which can be used in electronic devices such as mobile phones, tablet computers, computers, etc. Figure 3 is a flowchart of a video encoding method according to an embodiment of the present invention. Figure 3 As shown, the process includes the following steps:

[0103] S31, obtaining a target number of bits and an actual number of bits corresponding to the current video frame.

[0104] For detailed description, please refer to the relevant description corresponding to the above embodiments, which will not be repeated here.

[0105] S32, based on the error between the actual number of bits and the target number of bits, controlling the actual number of bits to track to the target number of bits within a target time.

[0106] For detailed description, please refer to the relevant description corresponding to the above embodiments, which will not be repeated here.

[0107] S33, determining a quantization parameter corresponding to the current video frame based on a preset model and a target bit number.

[0108] Specifically, the quantization parameter includes an intra-frame quantization parameter and an inter-frame quantization parameter. Accordingly, the above step S33 may include:

[0109] S331, determining whether the current video frame is an inter-frame coded video frame.

[0110] The inter-frame coded video frame is a video frame that needs to be coded in combination with the adjacent video frames. The electronic device detects the correlation between the current video frame and other video frames to determine whether the current video frame is an inter-frame coded video frame. If the current video frame is an intra-frame coded video frame, step S332 is executed, otherwise step S333 is executed.

[0111] S332: Calculate intra-frame quantization parameters according to a preset model.

[0112] The preset model is a pixel-level unified RQ model. If the current video frame is an intra-frame coded video frame, it means that the encoding of the current video frame is the encoding of this frame, and there is no need to consider the encoding information of other video frames. Use the pixel-level unified RQ model to determine the intra-frame quantization parameter The specific expression is as follows:

[0113]

[0114] Among them, N i,j Indicates the number of pixels in the current video frame; MAD i,j represents the predicted mean absolute difference of the current video frame, l i,j With h i,j The calculated RQ model parameters are updated for each video frame.

[0115] S333, obtaining a peak noise ratio corresponding to the encoded historical video frame and a compensation value of an intra-frame quantization parameter.

[0116] If the current video frame is an inter-frame coded video frame, the peak noise ratio corresponding to the coded historical video frame is determined by a rate control method (such as the rate control method of HEVC / H.265).

[0117] The initial value ΔQP0 of the compensation value ΔQP of the intra-frame quantization parameter is 1. As each video frame is encoded, the compensation value ΔQP of the intra-frame quantization parameter is updated accordingly. The updating method is:

[0118] ΔQP=ΔQP0+(PSNR i,j-1 -PSNR ave ) / θ

[0119] Among them, ΔQP represents the compensation value of the intra-frame quantization parameter; PSNR i,j-1 Indicates the peak noise ratio of the previous video frame; PSNRave is the average peak noise ratio of the encoded historical video frames; θ is a tuning parameter, which ranges from 0 to 1 and can be adjusted according to actual needs.

[0120] S334, determining an inter-frame quantization parameter based on the compensation value of the intra-frame quantization parameter.

[0121] The inter-frame quantization parameter is determined as follows:

[0122]

[0123] in, Indicates the inter-frame quantization parameter corresponding to the current video frame; It represents the average value of the inter-frame quantization parameter of the encoded historical video frames; ΔQP represents the compensation value of the intra-frame quantization parameter.

[0124] S34, using a preset encoding method to encode the quantization parameter to obtain video encoding information.

[0125] For detailed description, please refer to the relevant description corresponding to the above embodiments, which will not be repeated here.

[0126] The video encoding method provided in this embodiment realizes encoding of the current video frame by determining the inter-frame quantization parameter and the intra-frame quantization parameter, and encoding the inter-frame quantization parameter and the intra-frame quantization parameter using a preset encoding method, thereby ensuring the user's video viewing experience.

[0127] In this embodiment, a video encoding device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.

[0128] This embodiment provides a video encoding device, such as Figure 6 As shown, including:

[0129] The acquisition module 41 is used to acquire the target bit number and the actual bit number corresponding to the current video frame.

[0130] The control module 42 is used to control the actual number of bits to track to the target number of bits within a target time based on the error between the actual number of bits and the target number of bits.

[0131] The determination module 43 is used to determine the quantization parameter corresponding to the current video frame based on a preset model and a target bit number.

[0132] The encoding module 44 is used to encode the quantization parameter using a preset encoding method to obtain video encoding information.

[0133] Optionally, the acquisition module 41 may include:

[0134] The first acquisition submodule is used to obtain the actual number of bits corresponding to the current video frame.

[0135] The second acquisition submodule is used to acquire the bit number of the picture group corresponding to the video encoding unit, wherein the picture group includes a full-frame compression frame, a forward prediction frame, and a bidirectional prediction frame.

[0136] The first determination submodule is used to determine the target number of bits of the current video frame based on the number of bits and the weights of different types of coded frames in the group of pictures.

[0137] Specifically, the second acquisition module is used to obtain the frame rate, number of pictures and target bit rate corresponding to the image group; determine the ratio of the target bit rate to the frame rate; and determine the number of bits corresponding to the image group based on the ratio and the number of pictures.

[0138] Optionally, the control module 42 may include:

[0139] The third acquisition submodule is used to obtain the current network throughput and the delay variation of adjacent video frames.

[0140] The construction submodule is used to construct an adaptive relationship between the current network throughput, the delay variation of adjacent video frames and the target time.

[0141] The tracking submodule is used to control the actual number of bits to track to the target time of the target number of bits based on the adaptive relationship.

[0142] Optionally, the video encoding device may further include:

[0143] The bit rate acquisition module is used to obtain the average bit rate of the encoded historical video frames.

[0144] The correction module is used to correct the target bit number based on the average bit rate.

[0145] Optionally, the quantization parameter includes an intra-frame quantization parameter and an inter-frame quantization parameter. Accordingly, the determination module 43 may include:

[0146] The judgment submodule is used to judge whether the current video frame is an inter-frame coded video frame.

[0147] The first calculation submodule is used to calculate the intra-frame quantization parameter according to a preset model if the current video frame is an intra-frame coded video frame.

[0148] The second determination submodule is used to obtain the peak noise ratio corresponding to the encoded historical video frame and the compensation value of the intra-frame quantization parameter if the current video frame is an inter-frame encoded video frame.

[0149] The third determination submodule is used to determine the inter-frame quantization parameter based on the compensation value of the intra-frame quantization parameter.

[0150] The video encoding device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC circuit, a processor and a memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.

[0151] The further functional description of each of the above modules is the same as that of the above corresponding embodiments and will not be repeated here.

[0152] The video encoding device provided in this embodiment controls the actual number of bits of the current video frame to track to the target number of bits within the target time through the error between the actual number of bits and the target number of bits, determines the corresponding quantization parameter in combination with the target number of bits and the preset model, and performs encoding processing on the quantization parameter to achieve encoding for the current video frame. As a result, there is no need to use a buffer to adjust the bit consumption of the video frame, which improves the real-time response of the encoding and reduces the encoding delay. At the same time, the error between the actual number of bits and the target number of bits is combined to control the target time to track to the target number of bits, thereby achieving the adjustment of the video bit rate control time, eliminating the impact of the real-time changing bit rate error on the video encoding, avoiding jitter delay to the greatest extent, improving the encoding efficiency, and ensuring the user's viewing experience.

[0153] The embodiment of the present invention also provides an electronic device having the above Figure 6 The video encoding device is shown.

[0154] See also Figure 7 , Figure 7 is a schematic diagram of the structure of an electronic device provided by an optional embodiment of the present invention, such as Figure 7As shown, the electronic device may include: at least one processor 501, such as a central processing unit (CPU), at least one communication interface 503, a memory 504, and at least one communication bus 502. The communication bus 502 is used to realize the connection and communication between these components. The communication interface 503 may include a display screen (Display) and a keyboard (Keyboard), and the optional communication interface 503 may also include a standard wired interface and a wireless interface. The memory 504 may be a high-speed volatile random access memory (Random Access Memory, RAM) or a non-volatile memory (non-volatile memory), such as at least one disk storage. The memory 504 may optionally be at least one storage device located away from the aforementioned processor 501. The processor 501 may be combined with Figure 6 In the described device, the memory 504 stores an application program, and the processor 501 calls the program code stored in the memory 504 to execute any of the above method steps.

[0155] The communication bus 502 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The communication bus 502 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 7 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0156] Among them, 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 include a combination of the above types of memory.

[0157] The processor 501 may be a central processing unit (CPU), a network processor (NP), or a combination of a CPU and a NP.

[0158] 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 generic array logic (GAL) or any combination thereof.

[0159] Optionally, the memory 504 is also used to store program instructions. The processor 501 can call the program instructions to implement the present application Figures 1 to 3 The video encoding method shown in the embodiment.

[0160] The embodiment of the present invention further provides a non-transitory computer storage medium, wherein the computer storage medium stores computer executable instructions, and the computer executable instructions can execute the video encoding method in any of the above method embodiments. The storage medium may be a disk, an optical disk, a read-only memory (ROM), a random access memory (RAM), a flash memory, a hard disk (HDD), or a solid-state drive (SSD); the storage medium may also include a combination of the above types of memories.

[0161] 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 present invention, and such modifications and variations are all within the scope defined by the appended claims.

Claims

1. A video encoding method, characterized in that: include: Get the target bit number and actual bit number corresponding to the current video frame; Based on the error between the actual number of bits and the target number of bits, controlling the actual number of bits to track to the target number of bits within a target time, including: obtaining preset adjustment parameters of the current network throughput and the delay variation of adjacent video frames; constructing an adaptive relationship between the current network throughput, the delay variation of adjacent video frames and the target time; and controlling the actual number of bits to track to the target time of the target number of bits based on the adaptive relationship; Determine a quantization parameter corresponding to the current video frame based on a preset model and the target number of bits; Using a preset encoding method to encode the quantization parameter to obtain video encoding information; Wherein, obtaining the target number of bits corresponding to the current video frame includes: obtaining the number of bits of a group of pictures corresponding to a video coding unit, the group of pictures including a full-frame compression frame, a forward prediction frame, and a bidirectional prediction frame; determining the target number of bits of the current video frame based on the number of bits and the weights of different types of coded frames in the group of pictures; Obtaining the actual number of bits corresponding to the current video frame includes: obtaining the frame rate, number of pictures and target bit rate corresponding to the image group; determining the ratio of the target bit rate to the frame rate; and determining the number of bits corresponding to the image group based on the ratio and the number of pictures.

2. The method according to claim 1, characterized in that Also includes: Get the average bit rate of the encoded historical video frames; The target number of bits is corrected based on the average bit rate.

3. The method according to claim 1, characterized in that The quantization parameter includes an intra-frame quantization parameter, and determining the quantization parameter corresponding to the current video frame based on the preset model and the target number of bits includes: Determine whether the current video frame is an inter-frame coded video frame; When the current video frame is the intra-frame coded video frame, the intra-frame quantization parameter is calculated according to the preset model.

4. The method according to claim 3, characterized in that The quantization parameter also includes 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 also includes: When the current video frame is the inter-frame coded video frame, obtaining a peak noise ratio corresponding to an encoded historical video frame and a compensation value of the intra-frame quantization parameter; The inter-frame quantization parameter is determined based on the compensation value of the intra-frame quantization parameter.

5. A video encoding device, characterized in that: include: An acquisition module is used to obtain the target bit number and the actual bit number corresponding to the current video frame; A control module, configured to control 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; A determination module, configured to determine a quantization parameter corresponding to the current video frame based on a preset model and the target number of bits; An encoding module, used for encoding the quantization parameter using a preset encoding method to obtain video encoding information; The acquisition module includes: A first acquisition submodule is used to acquire a frame rate, a number of pictures and a target bit rate corresponding to an image group; determine a ratio of the target bit rate to the frame rate; and determine a number of bits corresponding to the image group based on the ratio and the number of pictures; A second acquisition submodule is used to acquire the number of bits of a group of images corresponding to a video encoding unit, wherein the group of images includes a full-frame compression frame, a forward prediction frame, and a bidirectional prediction frame; A first determination submodule, configured to determine a target number of bits of the current video frame based on the number of bits and weights of different types of coded frames in the group of pictures; Wherein, the control module comprises: The third acquisition submodule is used to obtain preset adjustment parameters of the current network throughput and the delay variation of adjacent video frames; A construction submodule, used to construct an adaptive relationship between the current network throughput, the delay variation of adjacent video frames and the target time; A tracking submodule is used to control the actual number of bits to track to a target time of the target number of bits based on the adaptive relationship.

6. An electronic device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the video encoding method according to any one of claims 1 to 4 by executing the computer instructions.

7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the video encoding method according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • A control method and device for image code rate

    CN101127909A