Video encoding method and apparatus

By adaptively adjusting quantization parameters and modifying the video encoding method based on various data, the problem of poor encoding results caused by improper user configuration is solved, resulting in better video encoding effects and user experience.

CN119420922BActive Publication Date: 2025-10-28AXERA TECH (BEIJING) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411514932.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-28
Publication Date
2025-10-28
Estimated Expiration
2044-10-28

AI Technical Summary

Technical Problem

In existing video coding technologies, improperly configured quantization parameters can lead to poor coding results such as mosaic and breathing effects.

Method used

By adaptively adjusting the quantization parameters, the parameters are automatically adjusted based on content complexity, motion amplitude, the ratio of keyframes to forward predictive coded frames, and peak signal-to-noise ratio to adapt to different video content and scenarios.

Benefits of technology

It improves video encoding quality, avoids problems such as mosaic and breathing effects, enhances user experience, and balances bitrate and image quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119420922B_ABST
    Figure CN119420922B_ABST
Patent Text Reader

Abstract

This application provides a video encoding method and apparatus applicable to intelligent video processing devices. These devices may include security equipment, such as IPCs (Internet Protocol Cameras), in-vehicle video processing devices, or image processing devices. The video encoding method includes: acquiring image frames from a target video; encoding the first frame according to its quantization parameters when the image frame is the first frame; adjusting the quantization parameters of the previous frame based on content complexity, motion amplitude, the ratio of decoded keyframes to forward predictive coded frames, and peak signal-to-noise ratio when the image frame is a target frame following the first frame, to obtain the quantization parameters of the target frame; and encoding the target frame according to its quantization parameters. This application implements adaptive adjustment of the quantization parameters.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of video coding technology, and in particular to a video coding method and apparatus. Background Technology

[0002] Video encoding is a technique that reduces the size of video files through compression. Encoded videos are smaller in size, making them easier to store and transmit. For example, videos shot by cameras are usually quite large; video encoding can effectively compress their size.

[0003] When encoding video, a higher bitrate results in higher image quality, but also a larger file size. To balance image quality and file size, the compression rate can be adjusted using QP (Quantizer Parameter), thereby controlling the bitrate.

[0004] Relying on VBR (Variable Bit Rate) technology, in related technologies, users can input a QP (Quick Point) setting range in the configuration interface of the video processing smart device. The video processing smart device automatically adjusts the QP within the set range according to the complexity of the video. However, if the user-inputted QP setting range is inappropriate, it will affect the video encoding effect. For example, if the QP setting range is in a high range, it will cause the video to be over-compressed during encoding, resulting in a mosaic effect during playback and affecting the user's viewing experience. Summary of the Invention

[0005] This application provides a video encoding method and apparatus to solve the problem of poor video encoding quality.

[0006] In a first aspect, this application provides a video encoding method, including:

[0007] Acquire image frames from a target video, wherein the target video comprises multiple consecutive image frames;

[0008] When the image frame is the first frame, the quantization parameters of the first frame are determined according to the resolution and bit rate of the target video, and the first frame is encoded according to the quantization parameters of the first frame.

[0009] When the image frame is a target frame after the first frame, the content complexity of the previous frame after encoding is calculated, and the quantization parameters of the previous frame are adjusted according to the comparison result of the content complexity and the first set range to obtain the first quantization parameter.

[0010] Calculate the motion amplitude between the target frame and the previous frame of the target frame, and adjust the first quantization parameter according to the comparison result of the motion amplitude and the second set range to obtain the second quantization parameter;

[0011] Calculate the ratio of the decoded keyframes to the forward predictive coded frames, and adjust the second quantization parameter based on the comparison result of the ratio with the third set range to obtain the third quantization parameter;

[0012] Calculate the peak signal-to-noise ratio (PSNR) of the previous frame of the target frame, and adjust the third quantization parameter based on the fact that the PSNR is less than a threshold to obtain the fourth quantization parameter;

[0013] The target frame is encoded according to the fourth quantization parameter.

[0014] In some embodiments, the quantization parameters include the minimum quantization step size of the current frame, the maximum quantization step size of the current frame, the minimum quantization step size of the key frame, and the maximum quantization step size of the key frame.

[0015] In some embodiments, adjusting the quantization parameters of the previous frame based on the comparison result of the content complexity and a first predetermined range includes:

[0016] If the complexity of the content is greater than the maximum value of the first set range, reduce the maximum quantization step size of the key frame and the maximum quantization step size of the current frame;

[0017] If the complexity of the content is less than the minimum value of the set range corresponding to the first set range, increase the minimum quantization step size of the key frame and the minimum quantization step size of the current frame.

[0018] In some embodiments, adjusting the first quantization parameter based on the comparison result between the motion amplitude and the second preset range includes:

[0019] If the motion amplitude is greater than the maximum value of the second preset range, reduce the maximum quantization step size of the key frame and the maximum quantization step size of the current frame;

[0020] If the motion amplitude is less than the minimum value of the second set range, increase the maximum quantization step size of the key frame and the minimum quantization step size of the current frame.

[0021] In some embodiments, adjusting the second quantization parameter based on the comparison result between the ratio and a third predetermined range includes:

[0022] If the ratio is greater than the maximum value of the third set range, increase the maximum quantization step size of the key frame and the minimum quantization step size of the key frame;

[0023] If the ratio is less than the minimum value of the third set range, the maximum quantization step size and the minimum quantization step size of the keyframe are reduced.

[0024] In some embodiments, adjusting the third quantization parameter based on the peak signal-to-noise ratio being less than a threshold includes:

[0025] If the peak signal-to-noise ratio is less than the threshold, increase the minimum quantization step size of the current frame, the maximum quantization step size of the current frame, the minimum quantization step size of the key frame, and the maximum quantization step size of the key frame.

[0026] In some embodiments, in the quantization parameters of the first frame, the minimum quantization step size of the current frame is the same as the minimum quantization step size of the key frame, and the maximum quantization step size of the current frame is the same as the maximum quantization step size of the key frame.

[0027] Secondly, this application provides a video encoding apparatus, comprising:

[0028] The input module is used to acquire image frames from a target video, wherein the target video includes multiple consecutive image frames;

[0029] The first frame encoding module, connected to the input module, is used to determine the quantization parameters of the first frame according to the resolution and bit rate of the target video when the image frame is the first frame, and to encode the first frame according to the quantization parameters of the first frame.

[0030] The target frame encoding module, connected to the input module, includes:

[0031] The content complexity analysis unit is used to calculate the content complexity of the previous frame of the target frame after encoding when the image frame is the target frame after the first frame, and adjust the quantization parameters of the previous frame according to the comparison result of the content complexity and the first set range to obtain the first quantization parameters.

[0032] The motion amplitude analysis unit, connected to the content complexity unit, is used to calculate the motion amplitude between the target frame and the previous frame of the target frame, and adjust the first quantization parameter according to the comparison result of the motion amplitude and the second set range to obtain the second quantization parameter;

[0033] A ratio analysis unit, connected to the motion amplitude analysis unit, is used to calculate the ratio of the decoded keyframes to the forward predictive coded frames. Based on the comparison result of the ratio with the third set range, the second quantization parameter is adjusted to obtain the third quantization parameter.

[0034] A peak signal-to-noise ratio (PSNR) unit, connected to the ratio analysis unit, is used to calculate the PSNR of the previous frame of the target frame, and adjust the third quantization parameter based on the PSNR being less than a threshold to obtain a fourth quantization parameter.

[0035] The encoding unit is used to encode the target frame according to the fourth quantization parameter.

[0036] In some embodiments, the quantization parameters include the minimum quantization step size of the current frame, the maximum quantization step size of the current frame, the minimum quantization step size of the key frame, and the maximum quantization step size of the key frame.

[0037] In some embodiments, in the quantization parameters of the first frame, the minimum quantization step size of the current frame is the same as the minimum quantization step size of the key frame, and the maximum quantization step size of the current frame is the same as the maximum quantization step size of the key frame.

[0038] As can be seen from the above technical content, the embodiments of this application provide a video encoding method and apparatus. After encoding the first frame, the embodiments of this application initiate an adaptive adjustment process for the quantization parameters. When encoding target frames after the first frame, the quantization parameters are automatically adjusted based on multiple data points, including content complexity, motion amplitude, the ratio of keyframes to forward predictive coded frames, and peak signal-to-noise ratio. This allows the quantization parameters to automatically adapt to various scenarios and different video content, offering high flexibility while balancing video encoding bitrate and image quality, achieving better video encoding results. Users do not need to configure multiple quantization parameters, reducing the complexity of user configuration and effectively avoiding encoding effects such as mosaic, breathing, and code block effects caused by inappropriate user-configured quantization parameters, thus improving the user experience. Attached Figure Description

[0039] To more clearly illustrate the technical solution of this application, the drawings used in the embodiments will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0040] Figure 1 A flowchart illustrating the video encoding method provided in this application embodiment;

[0041] Figure 2 This is a schematic diagram of the structure of the video encoding device provided in the embodiments of this application. Detailed Implementation

[0042] The embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described below do not represent all embodiments consistent with this application. They are merely examples of systems and methods consistent with some aspects of this application as detailed in the claims.

[0043] This application provides a video encoding method and apparatus applicable to intelligent video processing devices, including security devices such as IPCs (Internet Protocol Cameras), in-vehicle video processing devices, or image processing devices. By adaptively adjusting quantization parameters based on various parameters such as content complexity and motion amplitude, the quantization parameters can be adapted to video encoding in various scenarios, balancing bitrate and image quality. This eliminates the need for users to manually adjust quantization parameters according to the scenario, improving video encoding efficiency and quality.

[0044] See Figure 1 This is a flowchart illustrating a video encoding method provided in an embodiment of this application. Figure 1 As shown, the video encoding method may include the following steps:

[0045] Step S100: Obtain image frames from the target video, wherein the target video includes multiple consecutive image frames.

[0046] In some embodiments, the target video is the original video captured by a security device, and the target video includes multiple consecutive image frames.

[0047] After encoding these consecutive image frames, security equipment can obtain various types of image frames, such as I (intra-picture) frames, B (predictive-frame) frames, and P (bi-directional interpolated prediction frame) frames. These different types of image frames are combined to form the encoded video.

[0048] An I-frame, also known as a keyframe, contains complete data of the current frame and can be decoded independently; that is, only the data of the current frame is needed for decoding. Because I-frames contain complete data of the current frame, their compression ratio is usually relatively low.

[0049] A P-frame contains the difference data between this frame and a previous keyframe (or P-frame). During decoding, the previously buffered image is overlaid with the differences defined in this frame to generate the current frame's image. Because a P-frame only contains the difference data from the previous frame and not the same data as the previous frame, the compression ratio of a P-frame is usually greater than that of an I-frame.

[0050] B-frames contain the difference data between the current frame and the frames before and after it. During decoding, not only the buffered previous frames but also the frames after the current frame are needed. The final image is obtained by superimposing the data from the current frame and the frames before and after it. Because B-frames only contain the difference data between the current frame and the previous frames, and the difference data between the current frame and the frames after it, but do not contain the same data as the previous frames or the frames after it, the compression ratio of B-frames is usually greater than that of P-frames.

[0051] Step S200: When the image frame is the first frame, determine the quantization parameters of the first frame according to the resolution and bit rate of the target video, and encode the first frame according to the quantization parameters of the first frame.

[0052] During the encoding process, the quantization parameter is an important parameter affecting the compression ratio and image quality. The smaller the quantization parameter, the lower the compression ratio and the higher the image quality, but the larger the size of the encoded image frame will be; the larger the quantization parameter, the higher the compression ratio, the lower the image quality, and the smaller the size of the encoded image frame will be.

[0053] In some embodiments, the user can pre-configure the quantization parameters of the security device, that is, configure an adjustment range for the quantization parameters. When encoding the target video, the security device can adaptively adjust the quantization parameters within this adjustment range. To facilitate user configuration and ensure adjustment space, the adjustment range can be a relatively large interval. For example, the adjustment range can be (1, 51), in bits.

[0054] In some embodiments, the quantization parameters may include the quantization parameters of the I-frame and the quantization parameters of the current frame, wherein the quantization parameters of the I-frame include MaxIQp (maximum quantization step size of the I-frame) and MinIQp (minimum quantization step size of the I-frame), and the quantization parameters of the current frame include MaxQp (maximum quantization step size) and MinQp (minimum quantization step size).

[0055] MaxIQp and MinIQp are used to limit the quantization step size of I-frames, which falls between MinIQp and MaxIQp. A smaller quantization step size results in a sharper I-frame, while a larger quantization step size results in a blurrier I-frame. Since I-frames serve as reference frames for P-frames and B-frames, their image quality directly affects the decoding quality of subsequent frames.

[0056] MaxQp and MinQp are used to limit the quantization step size of the current frame, which is between MinQp and MaxQp. The smaller the quantization step size of the current frame, the clearer the encoded image; the larger the quantization step size of the current frame, the blurrier the encoded image.

[0057] In some embodiments, the user can configure these four quantization parameters as follows:

[0058] MaxQp: 1

[0059] MinQp: 51

[0060] MaxIQp: 1

[0061] MinIQp: 51

[0062] After the user configuration is completed, the quantization step size of both the I-frame and the current frame is in the range of (1, 51). Since (1, 51) is usually the maximum range of quantization parameters, configuring the quantization step size in this range allows the security device to have sufficient adjustment space when adjusting the quantization parameters, and can adapt to various scenarios, such as indoor scenarios, outdoor scenarios, static scenarios, and moving scenarios.

[0063] In some embodiments, for the first frame of the target video, bpp (Bits Per Pixel) can be calculated based on the resolution and bit rate of the target video. The quantization parameters of the first frame are configured based on the bpp. After configuring the quantization parameters of the first frame, the first frame can be encoded based on the quantization parameters of the first frame to obtain the encoded image frame.

[0064] Step S300: When the image frame is the target frame after the first frame, calculate the content complexity of the previous frame after encoding, and adjust the quantization parameters of the previous frame according to the comparison result of the content complexity and the first set range to obtain the first quantization parameters.

[0065] In some embodiments, after encoding the first frame, encoding of subsequent image frames of the target video begins. During the encoding of these subsequent image frames, the quantization parameters can be dynamically adjusted based on the already encoded image frames to balance image quality and file size in real time. For ease of distinction from the first frame, image frames located after the first frame in the target video can be referred to as target frames.

[0066] In some embodiments, when determining the quantization parameters of the target frame, the quantization parameters of the previous frame can be adjusted according to the content complexity of the previous frame. To facilitate differentiation from the quantization parameters of the previous frame, the quantization parameters processed in this step are referred to as the first quantization parameters.

[0067] Higher content complexity indicates a more complex scene, making it more difficult for users to analyze the content. Lower bitrates in subsequent image frames result in poor image quality, hindering content analysis; higher bitrates ensure image quality, but excessively high bitrates lead to larger encoded video files. Therefore, adjusting quantization parameters to a wider bitrate range is necessary to balance image quality and video size.

[0068] Lower content complexity indicates a simpler scene, making it easier for users to analyze the content. A higher bitrate in subsequent image frames leads to a larger encoded video file size; conversely, a lower bitrate, while still allowing for analysis due to the simplicity of the scene, results in poor image quality and a negative user experience if the bitrate is too low. Therefore, adjusting the quantization parameters is necessary to narrow the bitrate range, balancing the size of the encoded video with its image quality.

[0069] In some embodiments, the content complexity can be compared with a first set range to obtain a comparison result. Based on the comparison result, it can be determined whether the quantization parameter needs to be adjusted and how to adjust the quantization parameter. The adjustment step size can be configured according to actual needs.

[0070] For example, if the content complexity exceeds the maximum value of a first preset range, the maximum quantization step size of the keyframe and the maximum quantization step size of the current frame are reduced. The first preset range can be 10 to 14, in bits per second. When the content complexity is high, such as greater than 14, reducing the maximum quantization step size of the I-frame and the current frame limits both to a lower range, ensuring image quality. The first quantization parameter is obtained after the quantization parameters are adjusted as described above.

[0071] If the content complexity is less than the minimum value of the set range corresponding to the first set range, increase the minimum quantization step size of the keyframe and the minimum quantization step size of the current frame. When the content complexity is low, such as less than 10, by increasing the minimum quantization step size of the I-frame and the minimum quantization step size of the current frame, the quantization step size of both the current frame and the I-frame can be limited to a higher range, thereby reducing the size of the encoded image frame. The first quantization parameter is obtained after the quantization parameters are adjusted as described above.

[0072] If the complexity of the content is within the first set range, the quantization parameters will not be adjusted in this step, and the quantization parameters of the previous frame can be directly determined as the first quantization parameters.

[0073] Step S400: Calculate the motion amplitude between the target frame and the previous frame of the target frame, and adjust the first quantization parameter according to the comparison result of the motion amplitude and the second set range to obtain the second quantization parameter.

[0074] In some embodiments, motion amplitude refers to the degree of displacement or change between two adjacent image frames. A larger motion amplitude indicates a greater change between two adjacent frames. In this case, increasing the bitrate can improve image quality, which is beneficial for analyzing the image content. Conversely, a smaller motion amplitude indicates a smaller change between two adjacent frames. In this case, decreasing the bitrate can improve the compression ratio, which is beneficial for reducing video size.

[0075] In some embodiments, the motion amplitude can be compared with a second preset range to obtain a comparison result, and based on the comparison result, it can be determined whether the quantization parameter needs to be adjusted and how to adjust the quantization parameter.

[0076] For example, if the motion amplitude is greater than the maximum value of the second preset range, the maximum quantization step size of the keyframe and the maximum quantization step size of the current frame are reduced, wherein the second preset range can be 120-200 pixels. When the motion amplitude is large, such as greater than 200 pixels, by reducing the maximum quantization step size of the I-frame and the maximum quantization step size of the current frame, the quantization step size of both the I-frame and the current frame can be limited to a lower range, ensuring image quality. The second quantization parameter is obtained after the first quantization parameter is adjusted as described above.

[0077] If the motion amplitude is less than the minimum value of the set range corresponding to the second set range, increase the maximum quantization step size of the keyframe and the minimum quantization step size of the current frame. When the motion amplitude is small, such as less than 120 pixels, by increasing the maximum quantization step size of the I-frame and the minimum quantization step size of the current frame, the quantization step size of both the I-frame and the current frame can be limited to a higher range, thereby reducing the size of the encoded image frame. The second quantization parameter is obtained after the quantization parameters are adjusted as described above.

[0078] If the amplitude of the motion is within the second set range, then the quantization parameter does not need to be adjusted in this step, and the first quantization parameter can be directly determined as the second quantization parameter.

[0079] Step S500: Calculate the ratio of the decoded keyframes to the forward predictive coded frames. Based on the comparison result of the ratio and the third set range, adjust the second quantization parameter to obtain the third quantization parameter.

[0080] In some embodiments, the ratio of keyframes to forward predictive coded frames, i.e., the IP ratio, is the ratio of the data volume of an I-frame to the data volume of a P-frame. The larger this ratio is, the greater the difference in data volume between I-frames and P-frames, meaning a greater difference in image quality between I-frames and P-frames; the smaller the ratio is, the closer it is to 1, the smaller the difference in data volume between I-frames and P-frames, meaning a smaller difference in image quality between I-frames and P-frames.

[0081] A significant difference in data size between I-frames and P-frames can lead to a noticeable breathing effect. The breathing effect refers to a periodic change in image quality. Because I-frames and P-frames have different encoding modes and image quality, the breathing effect is prone to occur during the switching between I-frames and P-frames.

[0082] Before decoding the target frame, the ratio of the decoded keyframes to the forward predictive coded frames can be calculated. The decoded keyframes can refer to the keyframes in the GOP (Group of Pictures) containing the target frame, and the forward predictive coded frames can refer to the P-frames in the GOP containing the target frame.

[0083] In this step, the respiratory effect is optimized by automatically adjusting the IP ratio.

[0084] In some embodiments, the IP ratio can be compared with a third set range to obtain a comparison result. Based on the comparison result, it can be determined whether the quantization parameter needs to be adjusted and how to adjust the quantization parameter.

[0085] For example, if the IP ratio is greater than the maximum value of the third preset range, the maximum and minimum quantization step sizes of the keyframes are increased, where the third preset range can be 60 to 120. When the IP ratio is large, such as greater than 120, the breathing effect is more obvious. To reduce the breathing effect, the maximum and minimum quantization step sizes of the I-frames can be increased, limiting the quantization step size of both the I-frame and the current frame to a higher range, thereby reducing the bitrate of the I-frames and decreasing the data volume difference between the I-frames and P-frames, thus mitigating the breathing effect. The third quantization parameter is obtained after the second quantization parameter is adjusted as described above.

[0086] If the IP ratio is less than the minimum value of the set range corresponding to the third set range, the maximum and minimum quantization step sizes of the keyframes are reduced. When the IP ratio is small, such as less than 60, the breathing effect is weak. By reducing the maximum and minimum quantization step sizes of the keyframes, the quantization step size of both the I-frame and the current frame can be limited to a higher range, thereby increasing the bit rate of the I-frame and improving image quality. The third quantization parameter is obtained after the second quantization parameter is adjusted as described above.

[0087] If the IP ratio is within the third set range, then the quantization parameter does not need to be adjusted in this step, and the second quantization parameter can be directly determined as the third quantization parameter.

[0088] Step S600: Calculate the peak signal-to-noise ratio of the previous frame of the target frame, and adjust the third quantization parameter according to the fact that the peak signal-to-noise ratio is less than the threshold to obtain the fourth quantization parameter.

[0089] In some embodiments, PSNR (Peak signal-to-noise ratio) indicates the similarity between image frames before and after encoding. A larger PSNR indicates higher similarity, and a smaller PSNR indicates lower similarity. When the similarity is low, a mosaic effect will occur.

[0090] In some embodiments, the PSNR can be compared with a threshold to obtain a comparison result. Based on the comparison result, it can be determined whether the quantization parameter needs to be adjusted and how to adjust the quantization parameter.

[0091] For example, the threshold could be 25 dB. When the PSNR is low, such as less than 25 dB, by increasing the maximum quantization step size of the I-frame, the minimum quantization step size of the I-frame, the maximum quantization step size of the current frame, and the minimum quantization step size of the current frame, the quantization step size of both the I-frame and the current frame can be limited to a higher range, thereby improving the PSNR. The fourth quantization parameter is obtained after the third quantization parameter is adjusted as described above.

[0092] If the PSNR is greater than or equal to the threshold, the quantization parameter is not adjusted in this step, and the third quantization parameter can be directly determined as the fourth quantization parameter.

[0093] The above steps S300-S600 illustrate a method for adjusting quantization parameters. The adjustment step size of the quantization parameters in these steps can be configured to be the same or different, depending on actual needs.

[0094] Step S700: Encode the target frame according to the fourth quantization parameter.

[0095] In some embodiments, after obtaining the fourth quantization parameter, the target frame can be encoded according to the fourth quantization parameter.

[0096] In some embodiments, after encoding a target frame, the content complexity of the target frame can be calculated to adjust the quantization parameters when encoding the next target frame.

[0097] In some embodiments, the first set range, the second set range, the third set range, and the threshold in the above steps can be set according to actual needs, and the embodiments of this application do not impose specific limitations.

[0098] As can be seen from the above embodiments, the video encoding method provided in this application initiates an adaptive adjustment process of quantization parameters after the encoding of the first frame. When encoding target frames after the first frame, the quantization parameters are automatically adjusted based on multiple data such as content complexity, motion amplitude, IP ratio, and PSNR. This allows the quantization parameters to automatically adapt to various scenarios and different video content, providing high flexibility and balancing video encoding bitrate and image quality to achieve better video encoding results. Users do not need to configure multiple quantization parameters, reducing the complexity of user configuration and effectively avoiding encoding effects such as mosaic effect, breathing effect, and code block effect caused by inappropriate user-configured quantization parameters, thus improving the user experience.

[0099] This application also provides a video encoding device, see [link to relevant documentation]. Figure 2 The video encoding device may include an input module, a first frame encoding module, and a target frame encoding module.

[0100] The input module is used to acquire image frames from a target video, wherein the target video includes multiple consecutive image frames;

[0101] The first frame encoding module, connected to the input module, is used to determine the quantization parameters of the first frame according to the resolution and bit rate of the target video when the image frame is the first frame, and to encode the first frame according to the quantization parameters of the first frame.

[0102] The target frame encoding module, connected to the input module, includes:

[0103] The content complexity analysis unit is used to calculate the content complexity of the previous frame of the target frame after encoding when the image frame is the target frame after the first frame, and adjust the quantization parameters of the previous frame according to the comparison result of the content complexity and the first set range to obtain the first quantization parameters.

[0104] The motion amplitude analysis unit, connected to the content complexity unit, is used to calculate the motion amplitude between the target frame and the previous frame of the target frame, and adjust the first quantization parameter according to the comparison result of the motion amplitude and the second set range to obtain the second quantization parameter;

[0105] A ratio analysis unit, connected to the motion amplitude analysis unit, is used to calculate the ratio of the decoded keyframes to the forward predictive coded frames. Based on the comparison result of the ratio with the third set range, the second quantization parameter is adjusted to obtain the third quantization parameter.

[0106] A peak signal-to-noise ratio (PSNR) unit, connected to the ratio analysis unit, is used to calculate the PSNR of the previous frame of the target frame, and adjust the third quantization parameter based on the PSNR being less than a threshold to obtain a fourth quantization parameter.

[0107] The encoding unit is used to encode the target frame according to the fourth quantization parameter.

[0108] In some embodiments, the working process and technical effects of each module of the video encoding device can be referred to the process description in the video encoding method, and will not be repeated here.

[0109] Similar parts between the embodiments provided in this application can be referred to mutually. The specific implementation methods provided above are only a few examples under the overall concept of this application and do not constitute a limitation on the protection scope of this application. For those skilled in the art, any other implementation methods extended from the solution of this application without creative effort shall fall within the protection scope of this application.

Claims

1. A video encoding method, characterized in that, include: Acquire image frames from a target video, wherein the target video comprises multiple consecutive image frames; When the image frame is the first frame, the quantization parameters of the first frame are determined according to the resolution and bit rate of the target video, and the first frame is encoded according to the quantization parameters of the first frame. When the image frame is a target frame after the first frame, the content complexity of the previous frame after encoding is calculated, and the quantization parameters of the previous frame are adjusted according to the comparison result of the content complexity and the first set range to obtain the first quantization parameter. Calculate the motion amplitude between the target frame and the previous frame of the target frame, and adjust the first quantization parameter according to the comparison result of the motion amplitude and the second set range to obtain the second quantization parameter; Calculate the ratio of the decoded keyframes to the forward predictive coded frames, and adjust the second quantization parameter based on the comparison result of the ratio with the third set range to obtain the third quantization parameter; Calculate the peak signal-to-noise ratio (PSNR) of the previous frame of the target frame, and adjust the third quantization parameter based on the fact that the PSNR is less than a threshold to obtain the fourth quantization parameter; The target frame is encoded according to the fourth quantization parameter.

2. The video encoding method according to claim 1, characterized in that, The quantization parameters include the minimum quantization step size of the current frame, the maximum quantization step size of the current frame, the minimum quantization step size of the key frame, and the maximum quantization step size of the key frame.

3. The video encoding method according to claim 2, characterized in that, The step of adjusting the quantization parameters of the previous frame based on the comparison result between the content complexity and the first preset range includes: If the complexity of the content is greater than the maximum value of the first set range, reduce the maximum quantization step size of the key frame and the maximum quantization step size of the current frame; If the complexity of the content is less than the minimum value of the set range corresponding to the first set range, increase the minimum quantization step size of the key frame and the minimum quantization step size of the current frame.

4. The video encoding method according to claim 2, characterized in that, The step of adjusting the first quantization parameter based on the comparison result between the motion amplitude and the second preset range includes: If the motion amplitude is greater than the maximum value of the second preset range, reduce the maximum quantization step size of the key frame and the maximum quantization step size of the current frame; If the motion amplitude is less than the minimum value of the second set range, increase the maximum quantization step size of the key frame and the minimum quantization step size of the current frame.

5. The video encoding method according to claim 2, characterized in that, The step of adjusting the second quantization parameter based on the comparison result between the ratio and the third preset range includes: If the ratio is greater than the maximum value of the third set range, increase the maximum quantization step size of the key frame and the minimum quantization step size of the key frame; If the ratio is less than the minimum value of the third set range, the maximum quantization step size and the minimum quantization step size of the keyframe are reduced.

6. The video encoding method according to claim 2, characterized in that, The step of adjusting the third quantization parameter based on the peak signal-to-noise ratio being less than a threshold includes: If the peak signal-to-noise ratio is less than the threshold, increase the minimum quantization step size of the current frame, the maximum quantization step size of the current frame, the minimum quantization step size of the key frame, and the maximum quantization step size of the key frame.

7. The video encoding method according to claim 2, characterized in that, In the quantization parameters of the first frame, the minimum quantization step size of the current frame is the same as the minimum quantization step size of the key frame, and the maximum quantization step size of the current frame is the same as the maximum quantization step size of the key frame.

8. A video encoding device, characterized in that, include: The input module is used to acquire image frames from a target video, wherein the target video includes multiple consecutive image frames; The first frame encoding module, connected to the input module, is used to determine the quantization parameters of the first frame according to the resolution and bit rate of the target video when the image frame is the first frame, and to encode the first frame according to the quantization parameters of the first frame. The target frame encoding module, connected to the input module, includes: The content complexity analysis unit is used to calculate the content complexity of the previous frame of the target frame after encoding when the image frame is the target frame after the first frame, and adjust the quantization parameters of the previous frame according to the comparison result of the content complexity and the first set range to obtain the first quantization parameters. The motion amplitude analysis unit, connected to the content complexity unit, is used to calculate the motion amplitude between the target frame and the previous frame of the target frame, and adjust the first quantization parameter according to the comparison result of the motion amplitude and the second set range to obtain the second quantization parameter; A ratio analysis unit, connected to the motion amplitude analysis unit, is used to calculate the ratio of the decoded keyframes to the forward predictive coded frames. Based on the comparison result of the ratio with the third set range, the second quantization parameter is adjusted to obtain the third quantization parameter. A peak signal-to-noise ratio (PSNR) unit, connected to the ratio analysis unit, is used to calculate the PSNR of the previous frame of the target frame, and adjust the third quantization parameter based on the PSNR being less than a threshold to obtain a fourth quantization parameter. The encoding unit is used to encode the target frame according to the fourth quantization parameter.

9. The video encoding apparatus according to claim 8, characterized in that, The quantization parameters include the minimum quantization step size of the current frame, the maximum quantization step size of the current frame, the minimum quantization step size of the key frame, and the maximum quantization step size of the key frame.

10. The video encoding apparatus according to claim 9, characterized in that, In the quantization parameters of the first frame, the minimum quantization step size of the current frame is the same as the minimum quantization step size of the key frame, and the maximum quantization step size of the current frame is the same as the maximum quantization step size of the key frame.

Citation Information

Patent Citations

  • Video constant quality control method in the mode of pyramid type bidirectional estimation

    CN101110957A

  • Video coding frame layer code stream size control method and system and medium

    CN113422958A