[go: up one dir, main page]

CN119420922A - Video encoding method and device - Google Patents

Video encoding method and device Download PDF

Info

Publication number
CN119420922A
CN119420922A CN202411514932.8A CN202411514932A CN119420922A CN 119420922 A CN119420922 A CN 119420922A CN 202411514932 A CN202411514932 A CN 202411514932A CN 119420922 A CN119420922 A CN 119420922A
Authority
CN
China
Prior art keywords
frame
quantization parameter
quantization step
target
quantization
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202411514932.8A
Other languages
Chinese (zh)
Inventor
翟康
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Aixin Technology Co ltd
Original Assignee
Beijing Aixin Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Aixin Technology Co ltd filed Critical Beijing Aixin Technology Co ltd
Priority to CN202411514932.8A priority Critical patent/CN119420922A/en
Publication of CN119420922A publication Critical patent/CN119420922A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/102Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or selection affected or controlled by the adaptive coding
    • H04N19/124Quantisation
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/169Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding
    • H04N19/17Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being an image region, e.g. an object
    • H04N19/172Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being an image region, e.g. an object the region being a picture, frame or field
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/50Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using predictive coding
    • H04N19/587Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using predictive coding involving temporal sub-sampling or interpolation, e.g. decimation or subsequent interpolation of pictures in a video sequence
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/50Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using predictive coding
    • H04N19/59Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using predictive coding involving spatial sub-sampling or interpolation, e.g. alteration of picture size or resolution

Landscapes

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

Abstract

本申请实施例提供一种视频编码方法及装置,适用于视频处理智能设备,视频处理智能设备可包括安防设备,如IPC(Internet Protocol Camera,网络摄像机)、车载视频处理设备或图像处理设备等设备,视频编码方法包括:获取目标视频中的图像帧;在图像帧为第一帧时,根据第一帧的量化参数对第一帧进行编码;在图像帧为第一帧之后的目标帧时,根据内容复杂度、运动幅度、已解码出的关键帧与前向预测编码帧的比值和峰值信噪比对上一帧的量化参数进行调整,得到目标帧的量化参数;根据目标帧的量化参数对目标帧进行编码。本申请实施例实现了量化参数的自适应调节。

The embodiment of the present application provides a video encoding method and device, 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, and the video encoding method includes: obtaining an image frame in a target video; when the image frame is the first frame, 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, adjusting the quantization parameter of the previous frame according to the content complexity, 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; encoding the target frame according to the quantization parameter of the target frame. The embodiment of the present application realizes adaptive adjustment of the quantization parameter.

Description

Video coding method and device
Technical Field
The present application relates to the field of video coding technologies, and in particular, to a video coding method and apparatus.
Background
Video coding is a technique for reducing video volume by compression, and the coded video volume is reduced, so that the storage and transmission are convenient. For example, video captured by a camera is typically large in volume, and video volume can be efficiently compressed by video encoding.
When video is encoded, the larger the code rate is, the higher the image quality of the encoded video will be, but at the same time, the larger the volume of the encoded video will be. In order to balance the image quality and the volume of the video, the compression rate of the video can be adjusted by QP (Quantizer Parameter, quantization parameter), so as to realize the control of the code rate.
Depending on VBR (Variable Bit Rate ) technology, in the related art, a user may input a setting range of QP at a configuration interface of a video processing smart device, and the video processing smart device automatically adjusts QP within the setting range according to complexity of video. However, if the setting range of the QP input by the user is not proper, the video encoding effect will be affected, for example, if the setting range of the QP is in a high section, the video is compressed too high during encoding, so that the encoded video has a mosaic effect during playing, and the viewing experience of the user is affected.
Disclosure of Invention
The application provides a video coding method and a video coding device, which are used for solving the problem of poor video coding effect.
In a first aspect, the present application provides a video encoding method, including:
Acquiring an image frame in a target video, wherein the target video comprises a plurality of continuous image frames;
When the image frame is a first frame, determining a quantization parameter of the first frame according to the resolution and the code 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 the comparison result of the content complexity and a first set range to obtain a first quantization parameter;
Calculating the motion amplitude between the target frame and the frame above the target frame, and adjusting the first quantization parameter according to the comparison result of the motion amplitude and the second set range to obtain a second quantization parameter;
calculating the ratio of the decoded key frame to the forward predictive coding frame, and adjusting the second quantization parameter according to the comparison result of the ratio and a third setting range to obtain a third quantization parameter;
Calculating the peak signal-to-noise ratio of the last frame of the target frame, and adjusting the third quantization parameter according to the fact that the peak signal-to-noise ratio is smaller than a threshold value to obtain a fourth quantization parameter;
and encoding the target frame according to the fourth quantization parameter.
In some embodiments, the quantization parameter comprises a minimum quantization step size of a current frame, a maximum quantization step size of the current frame, a minimum quantization step size of the key frame, and a maximum quantization step size of the key frame.
In some embodiments, the adjusting the quantization parameter of the previous frame according to the comparison result of the content complexity and the first set range includes:
If the content complexity is larger than the maximum value of the first set range, reducing the maximum quantization step length of the key frame and the maximum quantization step length of the current frame;
And if the content complexity is smaller than the minimum value of the setting range corresponding to the first setting range, increasing the minimum quantization step length of the key frame and the minimum quantization step length of the current frame.
In some embodiments, the adjusting the first quantization parameter according to the comparison result of the motion amplitude and the second set range includes:
If the motion amplitude is larger than the maximum value of the second set range, reducing the maximum quantization step length of the key frame and the maximum quantization step length of the current frame;
and if the motion amplitude is smaller than the minimum value of the second set range, increasing the maximum quantization step length of the key frame and the minimum quantization step length of the current frame.
In some embodiments, the adjusting the second quantization parameter according to the comparison result of the ratio and the third setting range includes:
if the ratio is larger than the maximum value of the third setting range, increasing the maximum quantization step length of the key frame and the minimum quantization step length of the key frame;
and if the ratio is smaller than the minimum value of the third setting range, reducing the maximum quantization step length of the key frame and the minimum quantization step length of the key frame.
In some embodiments, the adjusting the third quantization parameter according to the peak signal-to-noise ratio being less than a threshold value includes:
And if the peak signal-to-noise ratio is smaller than a threshold value, increasing the minimum quantization step length of the current frame, the maximum quantization step length of the current frame, the minimum quantization step length of a key frame and the maximum quantization step length of the key frame.
In some embodiments, in the quantization parameter of the first frame, a minimum quantization step size of the current frame is the same as a minimum quantization step size of the key frame, and a maximum quantization step size of the current frame is the same as a maximum quantization step size of the key frame.
In a second aspect, the present application provides a video encoding apparatus comprising:
The input module is used for acquiring image frames in a target video, wherein the target video comprises a plurality of continuous image frames;
The first frame coding module is connected with the input module and is used for determining a quantization parameter of the first frame according to the resolution and the code rate of the target video when the image frame is the first frame, and coding the first frame according to the quantization parameter of the first frame;
The target frame coding module is connected with the input module and comprises:
The content complexity analysis unit is used for calculating the content complexity of the last frame of the target frame after encoding when the image frame is the target frame after the first frame, and adjusting the quantization parameter of the last frame according to the comparison result of the content complexity and the first setting range to obtain a first quantization parameter;
The motion amplitude analysis unit is connected with the content complexity unit and is used for calculating the motion amplitude between the target frame and the frame above the target frame, and adjusting the first quantization parameter according to the comparison result of the motion amplitude and the second set range to obtain a second quantization parameter;
The ratio analysis unit is connected with the motion amplitude analysis unit and is used for calculating the ratio of the decoded key frame to the forward predictive coding frame, and adjusting the second quantization parameter according to the comparison result of the ratio and a third set range to obtain a third quantization parameter;
the peak signal-to-noise ratio unit is connected with the ratio analysis unit and is used for calculating the peak signal-to-noise ratio of the last frame of the target frame, and adjusting the third quantization parameter according to the fact that the peak signal-to-noise ratio is smaller than a threshold value to obtain a fourth quantization parameter;
and the encoding unit is used for encoding the target frame according to the fourth quantization parameter.
In some embodiments, the quantization parameter comprises a minimum quantization step size of a current frame, a maximum quantization step size of the current frame, a minimum quantization step size of the key frame, and a maximum quantization step size of the key frame.
In some embodiments, in the quantization parameter of the first frame, a minimum quantization step size of the current frame is the same as a minimum quantization step size of the key frame, and a maximum quantization step size of the current frame is the same as a maximum quantization step size of the key frame.
As can be seen from the above technical content, the embodiments of the present application provide a video encoding method and apparatus. After the encoding of the first frame is completed, the embodiment of the application starts the self-adaptive adjustment process of the quantization parameter, automatically adjusts the quantization parameter according to the content complexity, the motion amplitude, the ratio of the key frame to the forward predictive encoding frame and the peak signal to noise ratio when encoding the target frame after the first frame, so that the quantization parameter can be automatically adapted to various scenes, different video contents are adapted, the flexibility is high, the code rate and the image quality of video encoding are both considered, the better video encoding effect is achieved, the user does not need to configure various quantization parameters, the complexity of the user configuration is reduced, the encoding effects such as mosaic effect, respiratory effect and encoding block effect caused by unsuitable quantization parameters configured by the user are effectively avoided, and the user experience is improved.
Drawings
In order to more clearly illustrate the technical solution of the present application, the drawings that are needed in the embodiments will be briefly described below, and it will be obvious to those skilled in the art that other drawings can be obtained from these drawings without inventive effort.
Fig. 1 is a schematic flow chart of a video encoding method according to an embodiment of the present application;
fig. 2 is a schematic structural diagram of a video encoding device according to an embodiment of the present application.
Detailed Description
Reference will now be made in detail to the embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, the same numbers in different drawings refer to the same or similar elements, unless otherwise indicated. The embodiments described in the examples below do not represent all embodiments consistent with the application. Merely exemplary of systems and methods consistent with aspects of the application as set forth in the claims.
The embodiment of the application provides a video coding method and a video coding device, which are suitable for video processing intelligent equipment, wherein the video processing intelligent equipment can comprise security equipment such as IPC (Internet Protocol Camera, network camera), vehicle-mounted video processing equipment or image processing equipment and the like. The quantization parameters are adaptively adjusted through various parameters such as content complexity, motion amplitude and the like, so that the quantization parameters can be adapted to video coding under various scenes, the code rate and the image quality of the video coding can be considered, a user does not need to manually adjust the quantization parameters according to the scenes, and the video coding efficiency and the video coding effect are improved.
Referring to fig. 1, a flowchart of a video encoding method according to an embodiment of the present application is shown. As shown in fig. 1, the video encoding method may include the steps of:
step S100, obtaining an image frame in a target video, wherein the target video comprises a plurality of continuous image frames.
In some embodiments, the target video is an original video captured by a security device, the target video comprising a plurality of consecutive image frames.
After these continuous image frames are encoded, the security device may obtain a plurality of different types of image frames, such as I (intra-frame), B (predictive-frame), and P (bi-directional interpolated prediction frame, bi-predictive interpolated frame). These different types of image frames are combined into encoded video.
I frames are also referred to as key frames. The I frame contains the complete data of the picture of the frame, and has the characteristic of independent decoding, namely, the I frame can be decoded only by the data of the frame. Since the I-frame contains the complete data of the picture of the present frame, the compression rate of the I-frame is generally low.
The P-frame contains the difference data between the present frame and the previous key frame (or P-frame), and the difference defined by the present frame needs to be overlapped by the picture cached before decoding to generate the picture of the present frame. Since the P frame contains only difference data from the previous frame and does not contain the same data as the previous frame, the compression rate of the P frame is generally greater than that of the I frame.
The B frame contains difference data between the present frame and the preceding and following frames, and when decoding, not only the previous buffer picture but also the picture after the present frame is needed, and the final picture is obtained by overlapping the preceding and following frames with the present frame data. Since the B frame contains only difference data with the previous frame and difference data with the following frame, does not contain the same data as the previous frame nor the same data as the following frame, the compression rate of the B frame is generally greater than that of the P frame.
And step 200, when the image frame is a first frame, determining a quantization parameter of the first frame according to the resolution and the code rate of the target video, and encoding the first frame according to the quantization parameter of the first frame.
In the encoding process, quantization parameters are important parameters affecting the compression rate and image quality. The smaller the quantization parameter, the smaller the compression ratio and the higher the image quality, but the larger the encoded image frame volume, and the higher the quantization parameter, the higher the compression ratio and the worse the image quality, and the smaller the encoded image frame volume.
In some embodiments, the user may pre-configure the quantization parameter of the security device, i.e., 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. In order to facilitate the configuration of the user and ensure the adjustment space, the adjustment range can be a larger interval range. The adjustment range may be (1, 51) in bits, for example.
In some embodiments, the quantization parameters may include quantization parameters of the I frame including MaxIQp (maximum quantization step size of the I frame) and MinIQp (minimum quantization step size of the I frame) and quantization parameters of the current frame including MaxQp (maximum quantization step size) and MinQp (minimum quantization step size).
MaxIQp and MinIQp are used to define the quantization step size of the I-frame, which is between MinIQp and MaxIQp. The smaller the quantization step of the I frame is, the clearer the I frame is, and the larger the quantization step of the I frame is, the more blurred the I frame is. Since an I frame is a reference frame for P and B frames, its image quality directly affects the decoding quality of subsequent frames.
MaxQp and MinQp are used to define the quantization step size of the current frame, which is between MinQp and MaxQp. The smaller the quantization step length of the current frame is, the clearer the encoded current frame is, and the larger the quantization step length of the current frame is, the more blurred the encoded current frame is.
In some embodiments, the user may configure the 4 quantization parameters to:
MaxQp:1
MinQp:51
MaxIQp:1
MinIQp:51
After the user configuration is completed, the quantization step ranges of the I frame and the current frame are (1, 51), and the (1, 51) is the maximum range of the quantization parameter, so that the user can configure the quantization step in the range, so that the security device has sufficient adjustment space when adjusting the quantization parameter, and the security device can adapt to various scenes, such as indoor scenes, outdoor scenes, static scenes, moving scenes and the like.
In some embodiments, for a first frame of the target video, bpp (Bits Per Pixel) may be calculated according to the resolution and the code rate of the target video, the quantization parameter of the first frame may be configured according to bpp, and after the quantization parameter of the first frame is configured, the first frame may be encoded according to the quantization parameter of the first frame, so as to obtain an encoded image frame.
And step 300, when the image frame is a target frame after the first frame, calculating the content complexity of the last frame of the target frame after encoding, and adjusting the quantization parameter of the last frame according to the comparison result of the content complexity and the first set range to obtain a first quantization parameter.
In some embodiments, after the first frame is encoded, encoding of subsequent image frames of the target video is started, and when the subsequent image frames are encoded, quantization parameters can be dynamically adjusted according to the already encoded image frames so as to consider both the quality and the volume of the encoded image in real time. Wherein, to facilitate distinguishing from the first frame, an image frame located after the first frame in the target video may be referred to as a target frame.
In some embodiments, in 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. In order to distinguish the quantization parameter from the quantization parameter of the previous frame, the quantization parameter processed by this step is referred to as a first quantization parameter.
The higher the content complexity, the more complex the current scene is represented, and the more difficult the user analyzes the picture content. If the code rate of the subsequent image frames is smaller, the image quality is poor, the analysis of the picture content is affected, if the code rate of the subsequent image frames is larger, the image quality can be ensured, and if the code rate is too high, the encoded video volume is larger. Therefore, the quantization parameter needs to be adjusted so as to adjust the code rate to a larger range, so as to achieve both the quality of the coded image and the video volume.
The lower the content complexity, the simpler the current scene is represented, and the lower the analysis difficulty of the user on the picture content is. If the code rate of the subsequent image frames is larger, the volume of the coded video is larger, if the code rate of the subsequent image frames is smaller, the analysis of the picture content by a user can be ensured because of simpler scenes, and if the code rate is too small, the image quality of the coded video is too poor, so that the user experience is influenced. Therefore, the quantization parameter needs to be adjusted so as to adjust the code rate to a smaller range, so as to achieve both the volume and the image quality of the encoded video.
In some embodiments, the content complexity may be compared with the first setting range to obtain a comparison result, and whether to adjust the quantization parameter and how to adjust the quantization parameter are determined according to the comparison result, where the adjusted step size may be configured according to the actual requirement.
For example, if the content complexity is greater than the maximum value of the first set range, the maximum quantization step size of the key frame and the maximum quantization step size of the current frame are reduced, where the first set range may be 10-14, and the unit is bit rate. When the content complexity is larger, for example, the content complexity is larger than 14, the quantization step length of the I frame and the quantization step length of the current frame can be limited in a lower range by reducing the maximum quantization step length of the I frame and the maximum quantization step length of the current frame, so that the image quality is ensured. And obtaining a first quantization parameter after the quantization parameter is adjusted.
And if the content complexity is smaller than the minimum value of the setting range corresponding to the first setting range, increasing the minimum quantization step length of the key frame and the minimum quantization step length of the current frame. When the content complexity is smaller, for example, smaller than 10, the quantization step length of the current frame and the quantization step length of the I frame can be limited in a higher range by increasing the minimum quantization step length of the I frame and the minimum quantization step length of the current frame, so as to reduce the volume of the encoded image frame. And obtaining a first quantization parameter after the quantization parameter is adjusted.
If the content complexity is within the first set range, the quantization parameter is not adjusted in this step, and the quantization parameter of the previous frame may be directly determined as the first quantization parameter.
And step 400, calculating the motion amplitude between the target frame and the frame above the target frame, and adjusting the first quantization parameter according to the comparison result of the motion amplitude and the second set range to obtain a second quantization parameter.
In some embodiments, the motion amplitude is the degree of displacement or change between two adjacent image frames. The larger the motion amplitude is, the larger the change between two adjacent frames is, at the moment, the improvement of the code rate can improve the image quality, thereby being beneficial to the analysis of the picture content, and the smaller the motion amplitude is, the smaller the change between two adjacent frames is, at the moment, the reduction of the code rate can improve the compression rate, thereby being beneficial to the reduction of the video volume.
In some embodiments, the motion amplitude may be compared with the second set range to obtain a comparison result, and whether the quantization parameter needs to be adjusted or not and how to adjust the quantization parameter are determined according to the comparison result.
For example, if the motion amplitude is greater than the maximum value of the second set range, the maximum quantization step size of the key frame and the maximum quantization step size of the current frame are reduced, where the second set range may be 120-200 pixels. When the motion amplitude is larger, for example, larger than 200 pixels, the quantization step length of the I frame and the quantization step length of the current frame can be limited in a lower range by reducing the maximum quantization step length of the I frame and the maximum quantization step length of the current frame, so that the image quality is ensured. And obtaining a second quantization parameter after the first quantization parameter is adjusted.
And if the motion amplitude is smaller than the minimum value of the setting range corresponding to the second setting range, increasing the maximum quantization step length of the key frame and the minimum quantization step length of the current frame. When the motion amplitude is smaller, for example, less than 120 pixels, the quantization step length of the I frame and the quantization step length of the current frame can be limited in a higher range by increasing the maximum quantization step length of the I frame and the minimum quantization step length of the current frame, so that the volume of the encoded image frame is reduced. And obtaining a second quantization parameter after the quantization parameter is adjusted.
If the motion amplitude is within the second set range, the first quantization parameter may be directly determined as the second quantization parameter without adjusting the quantization parameter in this step.
And S500, calculating the ratio of the decoded key frame to the forward predictive coding frame, and adjusting the second quantization parameter according to the comparison result of the ratio and a third set range to obtain a third quantization parameter.
In some embodiments, the ratio of key frames to forward predictive encoded frames, i.e., the IP ratio, is the ratio of the amount of data for I frames to the amount of data for P frames. The larger the ratio is, the larger the difference of the data amount of the I frame and the P frame is, namely the larger the difference of the image quality of the I frame and the image quality of the P frame is, the smaller the ratio is, namely the closer to 1 is, the smaller the difference of the data amount of the I frame and the P frame is, namely the smaller the difference of the image quality of the I frame and the image quality of the P frame is.
The difference between the data volumes of the I frame and the P frame is large, so that the respiratory effect is obvious. Respiratory effects refer to the periodic variation in image quality. Since the coding modes and image qualities of the I frame and the P frame are not the same, a respiratory effect easily occurs at the time of switching between the I frame and the P frame.
The ratio of the decoded key frame to the forward predictive encoded frame may be calculated prior to decoding the target frame. The decoded key frame may refer to a key frame in a gop (Group of Pictures ) in which the target frame is located, and the forward predictive-coded frame may refer to a P-frame in the gop in which the target frame is located.
In this step, the respiratory effect is optimized by automatically adjusting the IP ratio.
In some embodiments, the IP ratio may be compared with the third setting range to obtain a comparison result, and whether the quantization parameter needs to be adjusted or not and how to adjust the quantization parameter are determined according to the comparison result.
For example, if the IP ratio is greater than the maximum value of the third setting range, the maximum quantization step size and the minimum quantization step size of the key frame are increased, where the third setting range may be 60-120. The ratio at IP is larger. If the respiratory effect is more than 120, in order to reduce the respiratory effect, the quantization step length of the I frame and the quantization step length of the current frame can be limited in a higher range by increasing the maximum quantization step length of the I frame and the minimum quantization step length of the I frame, so that the code rate of the I frame is reduced, the data volume difference between the I frame and the P frame is reduced, and the respiratory effect is reduced. And obtaining a third quantization parameter after the second quantization parameter is adjusted.
And if the IP ratio is smaller than the minimum value of the setting range corresponding to the third setting range, reducing the maximum quantization step length and the minimum quantization step length of the key frame. When the IP is smaller, for example, smaller than 60, the respiratory effect is weaker, and the quantization step length of the I frame and the quantization step length of the current frame can be limited in a higher range by reducing the maximum quantization step length and the minimum quantization step length of the key frame, so that the code rate of the I frame is improved, and the image quality is improved. And obtaining a third quantization parameter after the second quantization parameter is adjusted.
If the IP ratio is within the third setting range, the second quantization parameter may be directly determined as the third quantization parameter without adjusting the quantization parameter in this step.
And S600, calculating the peak signal-to-noise ratio of the last frame of the target frame, and adjusting the third quantization parameter according to the fact that the peak signal-to-noise ratio is smaller than a threshold value to obtain a fourth quantization parameter.
In some embodiments, PSNR (PEAK SIGNAL-to-noise ratio) indicates the similarity between the image frames before and after encoding, with greater PSNR indicating higher similarity and lesser PSNR indicating lower similarity with a mosaic effect.
In some embodiments, the PSNR may be compared with a threshold to obtain a comparison result, and whether or not to adjust the quantization parameter and how to adjust the quantization parameter may be determined according to the comparison result.
The threshold may be, for example, 25 db. When the PSNR is smaller, for example, less than 25 db, the quantization step size of the I frame and the quantization step size of the current frame may be limited to a higher range 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, thereby improving the PSNR. And obtaining a fourth quantization parameter after the third quantization parameter is adjusted.
When the PSNR is greater than or equal to the threshold value, the third quantization parameter may be directly determined as the fourth quantization parameter without adjusting the quantization parameter in this step.
The above-mentioned steps S300-S600 show the method for adjusting the quantization parameter, wherein the adjustment steps of the quantization parameter in these steps may be configured to be the same or different, and may be specifically configured according to actual needs.
And step S700, encoding the target frame according to the fourth quantization parameter.
In some embodiments, after the fourth quantization parameter is obtained, the target frame may be encoded according to the fourth quantization parameter.
In some embodiments, after encoding is completed for one target frame, the content complexity of that target frame may be calculated for quantization parameter adjustment when encoding the next target frame.
In some embodiments, the first setting range, the second setting range, the third setting range and the threshold in the above steps may be set according to actual needs, and the embodiments of the present application are not limited in particular.
According to the video coding method, after the coding of the first frame is completed, the self-adaptive regulation process of the quantization parameter is started, and when the target frame after the first frame is coded, the quantization parameter is automatically regulated according to the content complexity, the motion amplitude, the IP ratio and the PSNR, so that the quantization parameter can be automatically adapted to various scenes, different video contents can be adapted, the flexibility is high, the code rate and the image quality of video coding are considered, a better video coding effect is achieved, a user does not need to configure various quantization parameters, the complexity of user configuration is reduced, the coding effects such as mosaic effect, respiratory effect and coding block effect caused by unsuitable quantization parameters configured by the user are effectively avoided, and the user experience is improved.
The embodiment of the application also provides a video coding device, referring to fig. 2, which may include an input module, a first frame coding module and a target frame coding module.
The input module is used for acquiring image frames in a target video, wherein the target video comprises a plurality of continuous image frames;
The first frame coding module is connected with the input module and is used for determining a quantization parameter of the first frame according to the resolution and the code rate of the target video when the image frame is the first frame, and coding the first frame according to the quantization parameter of the first frame;
The target frame coding module is connected with the input module and comprises:
The content complexity analysis unit is used for calculating the content complexity of the last frame of the target frame after encoding when the image frame is the target frame after the first frame, and adjusting the quantization parameter of the last frame according to the comparison result of the content complexity and the first setting range to obtain a first quantization parameter;
The motion amplitude analysis unit is connected with the content complexity unit and is used for calculating the motion amplitude between the target frame and the frame above the target frame, and adjusting the first quantization parameter according to the comparison result of the motion amplitude and the second set range to obtain a second quantization parameter;
The ratio analysis unit is connected with the motion amplitude analysis unit and is used for calculating the ratio of the decoded key frame to the forward predictive coding frame, and adjusting the second quantization parameter according to the comparison result of the ratio and a third set range to obtain a third quantization parameter;
the peak signal-to-noise ratio unit is connected with the ratio analysis unit and is used for calculating the peak signal-to-noise ratio of the last frame of the target frame, and adjusting the third quantization parameter according to the fact that the peak signal-to-noise ratio is smaller than a threshold value to obtain a fourth quantization parameter;
and the encoding unit is used for encoding the target frame according to the fourth quantization parameter.
In some embodiments, the working process and technical effects of each module of the video encoding apparatus may refer to the flow description in the video encoding method, which is not described herein.
The above-provided specific embodiments are only examples under the general inventive concept, and do not limit the scope of the protection set of the present application. Any other embodiments extended according to the solution of the application without inventive effort fall within the scope of the protection set-up of the application, for a person skilled in the art.

Claims (10)

1. A video encoding method, comprising:
Acquiring an image frame in a target video, wherein the target video comprises a plurality of continuous image frames;
When the image frame is a first frame, determining a quantization parameter of the first frame according to the resolution and the code 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 the comparison result of the content complexity and a first set range to obtain a first quantization parameter;
Calculating the motion amplitude between the target frame and the frame above the target frame, and adjusting the first quantization parameter according to the comparison result of the motion amplitude and the second set range to obtain a second quantization parameter;
calculating the ratio of the decoded key frame to the forward predictive coding frame, and adjusting the second quantization parameter according to the comparison result of the ratio and a third setting range to obtain a third quantization parameter;
Calculating the peak signal-to-noise ratio of the last frame of the target frame, and adjusting the third quantization parameter according to the fact that the peak signal-to-noise ratio is smaller than a threshold value to obtain a fourth quantization parameter;
and encoding the target frame according to the fourth quantization parameter.
2. The video coding method of claim 1, wherein the quantization parameter comprises a minimum quantization step size for a current frame, a maximum quantization step size for the current frame, a minimum quantization step size for the key frame, and a maximum quantization step size for the key frame.
3. The video coding method according to claim 2, wherein the adjusting the quantization parameter of the previous frame according to the comparison result of the content complexity and the first set range includes:
If the content complexity is larger than the maximum value of the first set range, reducing the maximum quantization step length of the key frame and the maximum quantization step length of the current frame;
And if the content complexity is smaller than the minimum value of the setting range corresponding to the first setting range, increasing the minimum quantization step length of the key frame and the minimum quantization step length of the current frame.
4. The method according to claim 2, wherein the adjusting the first quantization parameter according to the comparison result of the motion amplitude and the second set range includes:
If the motion amplitude is larger than the maximum value of the second set range, reducing the maximum quantization step length of the key frame and the maximum quantization step length of the current frame;
and if the motion amplitude is smaller than the minimum value of the second set range, increasing the maximum quantization step length of the key frame and the minimum quantization step length of the current frame.
5. The video coding method according to claim 2, wherein the adjusting the second quantization parameter according to the comparison result of the ratio and the third setting range includes:
if the ratio is larger than the maximum value of the third setting range, increasing the maximum quantization step length of the key frame and the minimum quantization step length of the key frame;
and if the ratio is smaller than the minimum value of the third setting range, reducing the maximum quantization step length of the key frame and the minimum quantization step length of the key frame.
6. The method according to claim 2, wherein said adjusting the third quantization parameter according to the peak signal-to-noise ratio being less than a threshold value comprises:
And if the peak signal-to-noise ratio is smaller than a threshold value, increasing the minimum quantization step length of the current frame, the maximum quantization step length of the current frame, the minimum quantization step length of a key frame and the maximum quantization step length of the key frame.
7. The video encoding method according to claim 2, wherein in the quantization parameter of the first frame, a minimum quantization step size of the current frame is the same as a minimum quantization step size of the key frame, and a maximum quantization step size of the current frame is the same as a maximum quantization step size of the key frame.
8. A video encoding apparatus, comprising:
The input module is used for acquiring image frames in a target video, wherein the target video comprises a plurality of continuous image frames;
The first frame coding module is connected with the input module and is used for determining a quantization parameter of the first frame according to the resolution and the code rate of the target video when the image frame is the first frame, and coding the first frame according to the quantization parameter of the first frame;
The target frame coding module is connected with the input module and comprises:
The content complexity analysis unit is used for calculating the content complexity of the last frame of the target frame after encoding when the image frame is the target frame after the first frame, and adjusting the quantization parameter of the last frame according to the comparison result of the content complexity and the first setting range to obtain a first quantization parameter;
The motion amplitude analysis unit is connected with the content complexity unit and is used for calculating the motion amplitude between the target frame and the frame above the target frame, and adjusting the first quantization parameter according to the comparison result of the motion amplitude and the second set range to obtain a second quantization parameter;
The ratio analysis unit is connected with the motion amplitude analysis unit and is used for calculating the ratio of the decoded key frame to the forward predictive coding frame, and adjusting the second quantization parameter according to the comparison result of the ratio and a third set range to obtain a third quantization parameter;
the peak signal-to-noise ratio unit is connected with the ratio analysis unit and is used for calculating the peak signal-to-noise ratio of the last frame of the target frame, and adjusting the third quantization parameter according to the fact that the peak signal-to-noise ratio is smaller than a threshold value to obtain a fourth quantization parameter;
and the encoding unit is used for encoding the target frame according to the fourth quantization parameter.
9. The video encoding device of claim 8, wherein the quantization parameter comprises a minimum quantization step size for a current frame, a maximum quantization step size for the current frame, a minimum quantization step size for the key frame, and a maximum quantization step size for the key frame.
10. The video coding device of claim 9, wherein in the quantization parameter of the first frame, a minimum quantization step size of the current frame is the same as a minimum quantization step size of the key frame, and a maximum quantization step size of the current frame is the same as a maximum quantization step size of the key frame.
CN202411514932.8A 2024-10-28 2024-10-28 Video encoding method and device Pending CN119420922A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202411514932.8A CN119420922A (en) 2024-10-28 2024-10-28 Video encoding method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202411514932.8A CN119420922A (en) 2024-10-28 2024-10-28 Video encoding method and device

Publications (1)

Publication Number Publication Date
CN119420922A true CN119420922A (en) 2025-02-11

Family

ID=94460878

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202411514932.8A Pending CN119420922A (en) 2024-10-28 2024-10-28 Video encoding method and device

Country Status (1)

Country Link
CN (1) CN119420922A (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070263720A1 (en) * 2006-05-12 2007-11-15 Freescale Semiconductor Inc. System and method of adaptive rate control for a video encoder
CN101110957A (en) * 2007-07-12 2008-01-23 上海交通大学 Video Constant Quality Control Method Based on Pyramid Bidirectional Predictive Mode
WO2021000245A1 (en) * 2019-07-02 2021-01-07 Alibaba Group Holding Limited Constant rate factor control for adaptive resolution video coding
CN113422958A (en) * 2021-05-31 2021-09-21 珠海全志科技股份有限公司 Method, system and medium for controlling size of video coding frame layer code stream
CN113766226A (en) * 2020-06-05 2021-12-07 深圳市中兴微电子技术有限公司 Image encoding method, apparatus, device and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070263720A1 (en) * 2006-05-12 2007-11-15 Freescale Semiconductor Inc. System and method of adaptive rate control for a video encoder
CN101110957A (en) * 2007-07-12 2008-01-23 上海交通大学 Video Constant Quality Control Method Based on Pyramid Bidirectional Predictive Mode
WO2021000245A1 (en) * 2019-07-02 2021-01-07 Alibaba Group Holding Limited Constant rate factor control for adaptive resolution video coding
CN113766226A (en) * 2020-06-05 2021-12-07 深圳市中兴微电子技术有限公司 Image encoding method, apparatus, device and storage medium
CN113422958A (en) * 2021-05-31 2021-09-21 珠海全志科技股份有限公司 Method, system and medium for controlling size of video coding frame layer code stream

Similar Documents

Publication Publication Date Title
JP3748717B2 (en) Video encoding device
JP5676705B2 (en) Improved video rate control for video coding standards
RU2377737C2 (en) Method and apparatus for encoder assisted frame rate up conversion (ea-fruc) for video compression
US9071841B2 (en) Video transcoding with dynamically modifiable spatial resolution
US8406297B2 (en) System and method for bit-allocation in video coding
US8374236B2 (en) Method and apparatus for improving the average image refresh rate in a compressed video bitstream
KR100643454B1 (en) Video data transmission control method
KR20070111550A (en) Similar Fixed Quality Rate Control by Prediction
AU2006223416A1 (en) Content adaptive multimedia processing
CN105072345A (en) Video coding method and device
US7826529B2 (en) H.263/MPEG video encoder for efficiently controlling bit rates and method of controlling the same
CN108632527A (en) Controller, video camera and the method for controlling video camera
JP2007028598A (en) Compression coding apparatus and compression coding method
JPH06225276A (en) Prefilter control method and apparatus in moving picture coding
US20030031377A1 (en) Apparatus and method for removing block artifacts, and displaying device having the same apparatus
JPH06133303A (en) Video coding device
CN119420922A (en) Video encoding method and device
JP4942208B2 (en) Encoder
JP3779066B2 (en) Video encoding device
JP2012105128A (en) Image encoder
JP2005303555A (en) Moving picture coding apparatus and moving picture coding method
JPH0984024A (en) Video signal encoder
KR20010104058A (en) Adaptive quantizer according to DCT mode in MPEG2 encoder
Maksimovic et al. The impact of successive b frames on video using h. 264 and h. 265 compression techniques
JPH08256337A (en) Video coding device

Legal Events

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