Video coding method and device

By introducing an adaptive quantitative parameter adjustment mechanism in the video encoding method, the quantization parameters are automatically adjusted according to multiple data, the encoding effect problem caused by the user's need to manually configure the quantization parameters is solved, and the code rate and image quality are taken into account, which improves the user's Experience.

CN119420922AActive Publication Date: 2025-02-11AXERA TECH (BEIJING) CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

In the existing video encoding technology, users need to manually configure quantitative parameters. If the configuration is improper, it will affect the video encoding effect, resulting in problems such as mosaic effect and breathing effect, which will affect the user experience.

Method used

By introducing an adaptive quantization parameter adjustment mechanism in the video encoding method, the quantization parameters are automatically adjusted according to multiple data such as content complexity, motion amplitude, the ratio of keyframes to forward predicted coded frames and peak signal-to-noise ratio, to ensure that the quantization parameters are adapted A variety of scenes and video content.

Benefits of technology

It realizes automatic adaptation of quantitative parameters, takes into account the code rate and image quality of video encoding, reduces the complexity of user configuration, avoids the encoding effect problems caused by inappropriate configuration, and improves the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119420922A_ABST
    Figure CN119420922A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a video coding method and device, and is suitable for video processing intelligent equipment, the video processing intelligent equipment can comprise security equipment, such as IPC (Internet Protocol Camera), vehicle-mounted video processing equipment or image processing equipment, and the video coding method comprises the following steps: obtaining an image frame in a target video; when the image frame is the first frame, coding the first frame according to the quantization parameter of the first frame; when the image frame is a target frame after the first frame, adjusting the quantization parameter of the previous frame according to the content complexity, the motion amplitude, the ratio of the decoded key frame to the forward prediction coding frame and the peak signal-to-noise ratio to obtain the quantization parameter of the target frame; and coding the target frame according to the quantization parameter of the target frame. According to the embodiment of the invention, adaptive adjustment of the quantization parameter is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] Video coding is a technology that reduces the size of video by compressing it. The encoded video becomes smaller and easier to store and transmit. For example, the video shot by a camera is usually large in size, and video coding can effectively compress the video size.

[0003] When encoding a video, the higher the bit rate, the higher the image quality of the encoded video will be, but at the same time, the size of the encoded video will also be larger. In order to balance the image quality and the size of the video, the compression rate of the video can be adjusted through QP (Quantizer Parameter), thereby achieving bit rate control.

[0004] Relying on VBR (Variable Bit Rate) technology, in the related technology, the user can input the QP setting range in the configuration interface of the video processing intelligent device, and the video processing intelligent device automatically adjusts the QP within the setting range according to the complexity of the video. However, if the QP setting range input by the user is inappropriate, it will affect the encoding effect of the video. For example, if the QP setting range is in a higher range, it will cause the video to be compressed too high during encoding, resulting in a mosaic effect on the encoded video during playback, affecting the user's viewing experience. Summary of the invention

[0005] The present application provides a video encoding method and device to solve the problem of poor video encoding effect.

[0006] In a first aspect, the present application provides a video encoding method, comprising:

[0007] Acquire an image frame in a target video, wherein the target video includes a plurality of continuous image frames;

[0008] When the image frame is a first frame, determining a quantization parameter of the first frame according to a resolution and a bit rate of the target video, and encoding the first frame according to the quantization parameter of the first frame;

[0009] When the image frame is a target frame after the first frame, calculating the content complexity of a previous frame of the target frame after encoding, and adjusting the quantization parameter of the previous frame according to a comparison result of the content complexity and a first set range to obtain a first quantization parameter;

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

[0011] Calculating a ratio of a decoded key frame to a forward prediction coded frame, and adjusting the second quantization parameter according to a comparison result of the ratio with a third set range to obtain a third quantization parameter;

[0012] Calculating a peak signal-to-noise ratio of a previous frame of the target frame, and adjusting the third quantization parameter according to the peak signal-to-noise ratio being less than a threshold value to obtain a fourth quantization parameter;

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

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

[0015] In some embodiments, adjusting the quantization parameter of the previous frame according to the comparison result between the content complexity and the first set range includes:

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

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

[0018] In some embodiments, adjusting the first quantization parameter according to a comparison result between the motion amplitude and a second set range includes:

[0019] If the motion amplitude is greater than the maximum value of the second set range, reducing 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 smaller than the minimum value of the second set range, the maximum quantization step size of the key frame and the minimum quantization step size of the current frame are increased.

[0021] In some embodiments, adjusting the second quantization parameter according to a comparison result between the ratio and a third setting range includes:

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

[0023] If the ratio is smaller than the minimum value of the third setting range, the maximum quantization step size of the key frame and the minimum quantization step size of the key frame are reduced.

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

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

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

[0027] In a second aspect, the present application provides a video encoding device, including:

[0028] An input module, used to obtain image frames in a target video, wherein the target video includes a plurality of continuous image frames;

[0029] a first frame encoding module connected to the input module, and configured to, when the image frame is a first frame, determine a quantization parameter of the first frame according to the resolution and bit rate of the target video, and encode the first frame according to the quantization parameter of the first frame;

[0030] A target frame encoding module, connected to the input module, comprises:

[0031] a content complexity analysis unit, configured to calculate, when the image frame is a target frame after the first frame, a content complexity of a previous frame of the target frame after encoding, and adjust a quantization parameter of the previous frame according to a comparison result of the content complexity with a first set range to obtain a first quantization parameter;

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

[0033] a ratio analysis unit connected to the motion amplitude analysis unit, and configured to calculate a ratio of a decoded key frame to a forward prediction coding frame, and adjust the second quantization parameter according to a comparison result between the ratio and a third set range to obtain a third quantization parameter;

[0034] a peak signal-to-noise ratio unit, connected to the ratio analysis unit, and configured to calculate a peak signal-to-noise ratio of a previous frame of the target frame, and to adjust the third quantization parameter according to the peak signal-to-noise ratio being less than a threshold value to obtain a fourth quantization parameter;

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

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

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

[0038] It can be seen from the above technical content that the embodiment of the present application provides a video encoding method and device. After completing the encoding of the first frame, the embodiment of the present application starts the adaptive adjustment process of the quantization parameter. When encoding the target frame after the first frame, the quantization parameter is automatically adjusted according to the content complexity, motion amplitude, the ratio of the key frame to the forward prediction coding frame, and the peak signal-to-noise ratio. The quantization parameter can automatically adapt to a variety of scenes and different video contents, with high flexibility, taking into account the bit rate and image quality of video encoding, and achieving a better video encoding effect; the user does not need to configure multiple quantization parameters, which reduces the complexity of the user configuration, effectively avoids the mosaic effect, breathing effect, coding block effect and other coding effects caused by inappropriate quantization parameters configured by the user, and improves the user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the technical solution of the present application, the drawings required for use in the embodiments are briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0040] Figure 1 A schematic diagram of a video encoding method according to an embodiment of the present invention;

[0041] Figure 2 A schematic diagram of the structure of a video encoding device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0042] The following embodiments are described in detail, and examples thereof are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following embodiments do not represent all implementations consistent with the present application. They are only examples of systems and methods consistent with some aspects of the present application as detailed in the claims.

[0043] The embodiment of the present application provides a video encoding method and apparatus, which is applicable to video processing intelligent devices, which may include security equipment, such as IPC (Internet Protocol Camera), vehicle-mounted video processing equipment or image processing equipment. The quantization parameters are adaptively adjusted by various parameters such as content complexity and motion amplitude, so that the quantization parameters can be adapted to video encoding in various scenarios, and the bit rate and image quality of video encoding can be taken into account, so that users do not need to manually adjust the quantization parameters according to the scenario, thereby improving the video encoding efficiency and video encoding effect.

[0044] See also Figure 1 , is a flow chart of a video encoding method provided in an embodiment of the present application. Figure 1 As shown, the video encoding method may include the following steps:

[0045] Step S100: Acquire image frames in a target video, where the target video includes a plurality of continuous image frames.

[0046] In some embodiments, the target video is an original video shot by a security device, and the target video includes a plurality of continuous image frames.

[0047] After encoding these continuous image frames, the security equipment can obtain a variety of different types of image frames, such as I (intra picture, intra-frame coded frame) frame, B (predictive-frame, forward predictive coded frame) frame and P (bi-directional interpolated prediction frame, bidirectional predictive interpolated coded frame) frame. These different types of image frames are combined into the encoded video.

[0048] I-frame is also called key frame. I-frame contains complete data of this frame and has the feature of independent decoding, that is, only the data of this frame is needed for decoding. Since I-frame contains complete data of this frame, the compression rate of I-frame is usually low.

[0049] The P frame contains the difference data between the current frame and the previous key frame (or P frame). When decoding, the difference defined by the current frame needs to be superimposed on the previously cached picture to generate the picture of the current frame. Since the P frame only contains the difference data with the previous frame, and does not contain the same data as the previous frame, the compression rate of the P frame is usually greater than that of the I frame.

[0050] B frames contain the difference data between the current frame and the previous and next frames. When decoding, not only the previous cached picture is needed, but also the picture after the current frame. The final picture is obtained by superimposing the previous and next frames with the current frame data. Since B frames only contain the difference data with the previous frame and the difference data with the next frame, and do not contain the same data as the previous frame or the next frame, the compression rate of B frames is usually greater than that of P frames.

[0051] Step S200: when the image frame is a first frame, determining a quantization parameter of the first frame according to a resolution and a bit rate of the target video, and encoding the first frame according to the quantization parameter of the first frame.

[0052] During the encoding process, the quantization parameter is an important parameter that affects the compression rate and image quality. The smaller the quantization parameter, the lower the compression rate and the higher the image quality, but the larger the size of the encoded image frame; the larger the quantization parameter, the higher the compression rate, the worse the image quality, and the smaller the size of the encoded image frame.

[0053] In some embodiments, the user can pre-configure the quantization parameter of the security device, that is, configure an adjustment range for the quantization parameter. When the security device encodes the target video, the quantization parameter can be adaptively adjusted within the adjustment range. To facilitate user configuration and ensure adjustment space, the adjustment range can be a larger interval range. Exemplarily, the adjustment range can be (1,51), in bits.

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

[0055] MaxIQp and MinIQp are used to limit the quantization step size of I frames. The quantization step size of I frames is between MinIQp and MaxIQp. The smaller the quantization step size of I frames, the clearer the I frames are; the larger the quantization step size of I frames, the blurrier the I frames are. Since I frames are 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. The quantization step size of the current frame is between MinQp and MaxQp. The smaller the quantization step size of the current frame, the clearer it will be after encoding; the larger the quantization step size of the current frame, the blurrier it will be after encoding.

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

[0058] MaxQp: 1

[0059] MinQp: 51

[0060] MaxIQp: 1

[0061] MinIQp: 51

[0062] After the user configuration is completed, the range of the quantization step size of the I frame and the current frame is (1,51). Since (1,51) is usually the maximum range of the quantization parameter, configuring the quantization step size within this range allows the security equipment to have sufficient adjustment space when adjusting the quantization parameter, and can adapt to a variety of scenarios, such as indoor scenes, outdoor scenes, static scenes, motion scenes, etc.

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

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

[0065] In some embodiments, after encoding the first frame, encoding of subsequent image frames of the target video begins. When encoding these subsequent image frames, the quantization parameters can be dynamically adjusted according to the image frames that have been encoded, so as to balance the image quality and volume of the encoding in real time. In order to distinguish from the first frame, the image frame in the target video that is located after the first frame can be called the target frame.

[0066] In some embodiments, when determining the quantization parameter of the target frame, the quantization parameter of the previous frame may be adjusted according to the content complexity of the previous frame. To facilitate the distinction from the quantization parameter of the previous frame, the quantization parameter processed by this step is referred to as the first quantization parameter.

[0067] The higher the content complexity, the more complex the current scene is, and the more difficult it is for users to analyze the content of the picture. If the bit rate of subsequent image frames is low, the image quality will be poor, affecting the analysis of the picture content; if the bit rate of subsequent image frames is high, the image quality can be guaranteed; but if the bit rate is too high, the encoded video volume will be large. Therefore, it is necessary to adjust the bit rate within a larger range by adjusting the quantization parameters to balance the encoded image quality and video volume.

[0068] The lower the content complexity, the simpler the current scene is, and the easier it is for users to analyze the content of the picture. If the bit rate of subsequent image frames is high, the size of the encoded video will be large; if the bit rate of subsequent image frames is low, the scene is relatively simple, which can also ensure the user's analysis of the picture content; but if the bit rate is too low, the image quality of the encoded video will be too poor, affecting the user experience. Therefore, it is necessary to adjust the bit rate to a smaller range by adjusting the quantization parameters to balance the size and image quality of the encoded video.

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

[0070] Exemplarily, if the content complexity is greater than the maximum value of the first setting range, the maximum quantization step of the key frame and the maximum quantization step of the current frame are reduced, wherein the first setting range may be 10 to 14, in units of bit rate. When the content complexity is large, such as greater than 14, by reducing the maximum quantization step of the I frame and the maximum quantization step of the current frame, the quantization step of the I frame and the quantization step of the current frame can be limited to a lower range to ensure image quality. The quantization parameter is adjusted as described above to obtain the first quantization parameter.

[0071] If the content complexity is less than the minimum value of the setting range corresponding to the first setting range, increase the minimum quantization step of the key frame and the minimum quantization step of the current frame. When the content complexity is small, such as less than 10, by increasing the minimum quantization step of the I frame and the minimum quantization step of the current frame, the quantization step of the current frame and the quantization step of the I frame can be limited to a higher range to reduce the volume of the encoded image frame. The first quantization parameter is obtained after the quantization parameter is adjusted as above.

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

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

[0074] In some embodiments, the motion amplitude is the displacement or degree of change between two adjacent image frames. The larger the motion amplitude, the greater the change between the two adjacent frames. In this case, increasing the bit rate can improve the image quality, which is beneficial for analyzing the content of the picture; the smaller the motion amplitude, the smaller the change between the two adjacent frames. In this case, reducing the bit rate can improve the compression rate, which is beneficial for reducing the video volume.

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

[0076] Exemplarily, if the motion amplitude is greater than the maximum value of the second setting range, the maximum quantization step of the key frame and the maximum quantization step of the current frame are reduced, wherein the second setting range may be 120 to 200 pixels. When the motion amplitude is large, such as greater than 200 pixels, by reducing the maximum quantization step of the I frame and the maximum quantization step of the current frame, the quantization step of the I frame and the quantization step of the current frame can be limited to a lower range to ensure image quality. The first quantization parameter is adjusted as described above to obtain the second quantization parameter.

[0077] If the motion amplitude is less than the minimum value of the setting range corresponding to the second setting range, increase the maximum quantization step of the key frame and the minimum quantization step of the current frame. When the motion amplitude is small, such as less than 120 pixels, by increasing the maximum quantization step of the I frame and the minimum quantization step of the current frame, the quantization step of the I frame and the quantization step of the current frame can be limited to a higher range to reduce the volume of the encoded image frame. The second quantization parameter is obtained after the quantization parameter is adjusted as above.

[0078] If the motion amplitude is within the second setting range, the quantization parameter is not 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 key frame to the forward prediction coding frame, and adjust the second quantization parameter according to the comparison result of the ratio and a third set range to obtain a third quantization parameter.

[0080] In some embodiments, the ratio of key frames to forward predictive coding frames, i.e., IP ratio, is the ratio of the data volume of I frames to the data volume of P frames. The larger the ratio, the larger the data volume difference between I frames and P frames, i.e., the larger the image quality difference between I frames and P frames; the smaller the ratio, i.e., the closer to 1, the smaller the data volume difference between I frames and P frames, i.e., the smaller the image quality difference between I frames and P frames, i.e., the smaller the image quality difference between I frames and P frames.

[0081] When the data volume difference between I-frame and P-frame is large, the breathing effect will be more obvious. The breathing effect refers to the periodic change of image quality. Since the encoding mode and image quality of I-frame and P-frame are different, the breathing effect is easy to appear when switching between I-frame and P-frame.

[0082] Before decoding the target frame, the ratio of the decoded key frame to the forward prediction coded frame can be calculated, wherein the decoded key frame can refer to the key frame in the gop (Group of Pictures) where the target frame is located, and the forward prediction coded frame can refer to the P frame in the gop where the target frame is located.

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

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

[0085] Exemplarily, if the IP ratio is greater than the maximum value of the third setting range, the maximum quantization step and the minimum quantization step of the key frame are increased, wherein the third setting range may be 60 to 120. The IP ratio is relatively large. If it is greater than 120, the breathing effect is more obvious. To reduce the breathing effect, the maximum quantization step of the I frame and the minimum quantization step of the I frame can be increased, and the quantization step of the I frame and the quantization step of the current frame can be limited to a higher range, thereby reducing the bit rate of the I frame, reducing the data volume difference between the I frame and the P frame, and achieving the effect of reducing the breathing effect. The third quantization parameter is obtained by adjusting the second quantization parameter as described above.

[0086] If the IP ratio is less than the minimum value of the setting range corresponding to the third setting range, reduce the maximum quantization step and the minimum quantization step of the key frame. When the IP ratio is relatively small, such as less than 60, the breathing effect is weak, and the maximum quantization step and the minimum quantization step of the key frame can be reduced to limit the quantization step of the I frame and the quantization step of the current frame to a higher range, so as to improve the bit rate of the I frame and improve the image quality. The third quantization parameter is obtained after the second quantization parameter is adjusted as above.

[0087] If the IP ratio is within the third setting range, the quantization parameter is not 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 peak signal-to-noise ratio being less than a threshold to obtain a fourth quantization parameter.

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

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

[0091] Exemplarily, the threshold value may be 25 decibels. When the PSNR is small, such as less than 25 decibels, by increasing the maximum quantization step of the I frame, the minimum quantization step of the I frame, the maximum quantization step of the current frame, and the minimum quantization step of the current frame, the quantization step of the I frame and the quantization step of the current frame can be limited to a higher range, thereby improving the PSNR. The fourth quantization parameter is obtained by adjusting the third quantization parameter as described above.

[0092] When 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 to S600 illustrate a method for adjusting the quantization parameters, wherein the adjustment step sizes of the quantization parameters in these steps may be configured to be the same or different, and may be configured specifically according to actual needs.

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

[0095] In some embodiments, after the fourth quantization parameter is obtained, the target frame may be encoded according to the fourth quantization parameter.

[0096] In some embodiments, after encoding of a target frame is completed, the content complexity of the target frame may be calculated for use in adjusting the quantization parameter when encoding the next target frame.

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

[0098] It can be seen from the above embodiments that the video encoding method provided in the embodiments of the present application starts the adaptive adjustment process of the quantization parameters after completing the encoding of the first frame. When encoding the target frame after the first frame, the quantization parameters are automatically adjusted according to multiple data such as content complexity, motion amplitude, IP ratio and PSNR, so that the quantization parameters can automatically adapt to various scenarios and different video contents, with high flexibility, taking into account the bit rate and image quality of video encoding, and achieving better video encoding effect; the user does not need to configure multiple quantization parameters, which reduces the complexity of the user configuration, effectively avoids the mosaic effect, breathing effect, coding block effect and other coding effects caused by inappropriate quantization parameters configured by the user, and improves the user experience.

[0099] The present application also provides a video encoding device. Figure 2 , the video encoding device may include an input module, a first frame encoding module and a target frame encoding module.

[0100] An input module, used to obtain image frames in a target video, wherein the target video includes a plurality of continuous image frames;

[0101] a first frame encoding module connected to the input module, and configured to, when the image frame is a first frame, determine a quantization parameter of the first frame according to the resolution and bit rate of the target video, and encode the first frame according to the quantization parameter of the first frame;

[0102] A target frame encoding module, connected to the input module, comprises:

[0103] a content complexity analysis unit, configured to calculate, when the image frame is a target frame after the first frame, a content complexity of a previous frame of the target frame after encoding, and adjust a quantization parameter of the previous frame according to a comparison result of the content complexity with a first set range to obtain a first quantization parameter;

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

[0105] a ratio analysis unit connected to the motion amplitude analysis unit, and configured to calculate a ratio of a decoded key frame to a forward prediction coding frame, and adjust the second quantization parameter according to a comparison result between the ratio and a third set range to obtain a third quantization parameter;

[0106] a peak signal-to-noise ratio unit, connected to the ratio analysis unit, and configured to calculate a peak signal-to-noise ratio of a previous frame of the target frame, and to adjust the third quantization parameter according to the peak signal-to-noise ratio being less than a threshold value to obtain a fourth quantization parameter;

[0107] An 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 refer to the process description in the video encoding method, which will not be repeated here.

[0109] Similar parts between the embodiments provided in this application can be referenced to each other. The specific implementation methods provided above are only a few examples under the general 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 expanded based on the scheme of this application without creative work belong to the protection scope of this application.

Claims

1. A video encoding method, characterized in that: include: Acquire an image frame in a target video, wherein the target video includes a plurality of continuous image frames; When the image frame is a first frame, determining a quantization parameter of the first frame according to a resolution and a bit rate of the target video, and encoding the first frame according to the quantization parameter of the first frame; When the image frame is a target frame after the first frame, calculating the content complexity of a previous frame of the target frame after encoding, and adjusting the quantization parameter of the previous frame according to a comparison result of the content complexity and a first set range to obtain a first quantization parameter; Calculating a motion amplitude between the target frame and a previous frame of the target frame, and adjusting the first quantization parameter according to a comparison result of the motion amplitude with a second set range to obtain a second quantization parameter; Calculating a ratio of a decoded key frame to a forward prediction coded frame, and adjusting the second quantization parameter according to a comparison result of the ratio with a third set range to obtain a third quantization parameter; Calculating a peak signal-to-noise ratio of a previous frame of the target frame, and adjusting the third quantization parameter according to the peak signal-to-noise ratio being less than a threshold value to obtain a 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 a minimum quantization step size of a current frame, a maximum quantization step size of the current frame, a minimum quantization step size of a key frame, and a maximum quantization step size of a key frame.

3. The video encoding method according to claim 2, characterized in that: The adjusting the quantization parameter of the previous frame according to the comparison result between the content complexity and the first set range includes: If the content complexity is greater than a maximum value of the first set range, reducing the maximum quantization step size of the key frame and the maximum quantization step size of the current frame; If the content complexity is less than the minimum value of the setting range corresponding to the first setting range, the minimum quantization step size of the key frame and the minimum quantization step size of the current frame are increased.

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

5. The video encoding method according to claim 2, characterized in that: The adjusting the second quantization parameter according to the comparison result between the ratio and the third setting range includes: If the ratio is greater than a maximum value of a third setting range, increasing a maximum quantization step size of the key frame and a minimum quantization step size of the key frame; If the ratio is smaller than the minimum value of the third setting range, the maximum quantization step size of the key frame and the minimum quantization step size of the key frame are reduced.

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

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

8. A video encoding device, characterized in that: include: An input module, used to obtain image frames in a target video, wherein the target video includes a plurality of continuous image frames; a first frame encoding module connected to the input module, and configured to, when the image frame is a first frame, determine a quantization parameter of the first frame according to the resolution and bit rate of the target video, and encode the first frame according to the quantization parameter of the first frame; A target frame encoding module, connected to the input module, comprises: a content complexity analysis unit, configured to calculate, when the image frame is a target frame after the first frame, a content complexity of a previous frame of the target frame after encoding, and adjust a quantization parameter of the previous frame according to a comparison result of the content complexity with a first set range to obtain a first quantization parameter; a motion amplitude analysis unit connected to the content complexity unit, and configured to calculate the motion amplitude between the target frame and a previous frame of the target frame, and adjust the first quantization parameter according to a comparison result between the motion amplitude and a second set range to obtain a second quantization parameter; a ratio analysis unit connected to the motion amplitude analysis unit, and configured to calculate a ratio of a decoded key frame to a forward prediction coding frame, and adjust the second quantization parameter according to a comparison result between the ratio and a third set range to obtain a third quantization parameter; a peak signal-to-noise ratio unit, connected to the ratio analysis unit, and configured to calculate a peak signal-to-noise ratio of a previous frame of the target frame, and to adjust the third quantization parameter according to the peak signal-to-noise ratio being less than a threshold value to obtain a fourth quantization parameter; An encoding unit is used to encode the target frame according to the fourth quantization parameter.

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

10. The video encoding device according to claim 9, characterized in that: In the quantization parameters of the first frame, the minimum quantization step of the current frame is the same as the minimum quantization step of the key frame, and the maximum quantization step of the current frame is the same as the maximum quantization step 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

  • Image coding method and device, equipment and storage medium

    CN113766226A

  • System and method of adaptive rate control for a video encoder

    US20070263720A1

  • Constant rate factor control for adaptive resolution video coding

    WO2021000245A1