Video encoding method and device, electronic device, and storage medium
By determining the first quantization parameter in video encoding and adjusting it to the second quantization parameter based on the image quality noise value and the target mapping relationship, and encoding video frames one by one, the problem of poor bit rate stability in the prior art is solved, and the bit rate is reduced while maintaining stable image quality.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-05-21
- Publication Date
- 2026-06-23
Smart Images

Figure CN122269030A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of video processing technology, and in particular to a video encoding method and apparatus, electronic device, and storage medium. Background Technology
[0002] In video encoding, the quantizer parameter (QP) controls the degree of detail preservation in the image during compression, determining the quality and bitrate of the encoded image. Bitrate refers to the amount of data output per unit of time. A larger quantizer parameter results in greater image distortion but a lower bitrate. Conversely, a smaller quantizer parameter results in less image distortion but a higher bitrate. Therefore, the quantizer parameter (QP) is a primary factor determining image distortion during video encoding.
[0003] In related technologies, the setting of quantization parameters usually only considers image quality, resulting in poor stability of the encoded output bitrate. For example, when using a fixed QP mode for video encoding, the image quality of the encoded output is constant, but its bitrate depends on the image content, resulting in poor stability. Summary of the Invention
[0004] This disclosure provides a video encoding method and apparatus, an electronic device, a computer-readable storage medium, and a computer program product.
[0005] In a first aspect, this disclosure provides a video encoding method, which includes: determining a first quantization parameter for encoding a target video to be encoded; determining a second quantization parameter based on a preset image quality noise value, a target mapping relationship, and the first quantization parameter; wherein the image quality noise value is used to indicate the human eye's observation error value of image quality; the target mapping relationship is used to indicate the correspondence between the quantization parameter and the image quality score at the image size of the target video; and encoding multiple video frames of the target video frame by frame based on the first quantization parameter and the second quantization parameter to obtain encoded data of the target video.
[0006] Secondly, this disclosure provides a video encoding apparatus, comprising: a first parameter determination module, configured to determine a first quantization parameter for encoding a target video to be encoded; a second parameter determination module, configured to determine a second quantization parameter based on a preset image quality noise value, a target mapping relationship, and the first quantization parameter; wherein the image quality noise value is used to indicate the human eye's observation error value of image quality; the target mapping relationship is used to indicate the correspondence between the quantization parameter and the image quality score at the image size of the target video; and an encoding module, configured to encode multiple video frames of the target video frame by frame based on the first quantization parameter and the second quantization parameter to obtain encoded data of the target video.
[0007] Thirdly, this disclosure provides an electronic device comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores one or more computer programs executable by the at least one processor, the one or more computer programs being executed by the at least one processor to enable the at least one processor to perform the video encoding method described above.
[0008] Fourthly, this disclosure provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the video encoding method described above.
[0009] Fifthly, this disclosure provides a computer program product that includes computer-readable code or a non-volatile computer-readable storage medium carrying computer-readable code, wherein when the computer-readable code is run in a processor of an electronic device, the processor in the electronic device executes the video encoding method described above.
[0010] According to the video encoding method of this disclosure, during video encoding, a first quantization parameter for encoding the target video to be encoded is first determined. Then, a second quantization parameter is determined based on the image quality noise value (indicating the human eye's observation error value of image quality), the target mapping relationship, and the first quantization parameter. Subsequently, multiple video frames of the target video are encoded frame by frame based on the first and second quantization parameters to obtain the encoded data of the target video. This allows the image quality and the human eye's observation error value of image quality to be considered when setting the quantization parameters for video encoding. During video encoding, multiple video frames are encoded frame by frame based on the original quantization parameter (first quantization parameter) and the quantization parameter adjusted based on the image quality noise value (second quantization parameter), so as to minimize the bitrate during video encoding. This improves the stability of the bitrate while maintaining stable image quality during the video encoding process.
[0011] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description
[0012] The accompanying drawings are provided to further illustrate the present disclosure and form part of the specification. They are used together with the embodiments of the present disclosure to explain the disclosure and do not constitute a limitation thereof. The above and other features and advantages will become more apparent to those skilled in the art from the detailed description of exemplary embodiments with reference to the accompanying drawings, in which:
[0013] Figure 1 This is a flowchart of a video encoding method provided in an embodiment of the present disclosure.
[0014] Figure 2 This is a schematic diagram of the mapping relationship in a video encoding method provided in an embodiment of this disclosure.
[0015] Figure 3 This is a schematic diagram illustrating the determination of a second quantization parameter in a video coding method provided in an embodiment of this disclosure.
[0016] Figure 4 This is a schematic diagram of a video encoding method provided in an embodiment of the present disclosure.
[0017] Figure 5 This is a block diagram of a video encoding apparatus provided in an embodiment of the present disclosure.
[0018] Figure 6 This is a block diagram of an electronic device provided in an embodiment of the present disclosure. Detailed Implementation
[0019] To enable those skilled in the art to better understand the technical solutions of this disclosure, exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments of this disclosure to aid understanding. These should be considered merely exemplary. Therefore, those skilled in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this disclosure. Similarly, for clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0020] Where there is no conflict, the various embodiments of this disclosure and the features thereof in the embodiments may be combined with each other.
[0021] As used herein, the term “and / or” includes any and all combinations of one or more related enumerated entries.
[0022] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit this disclosure. As used herein, the singular forms “a” and “the” are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will also be understood that when the terms “comprising” and / or “made of” are used in this specification, the presence of the stated feature, integral, step, operation, element, and / or component is specified, but the presence or addition of one or more other features, integrals, steps, operations, elements, components, and / or groups thereof is not excluded. Words such as “connected” or “linked” are not limited to physical or mechanical connections but can include electrical connections, whether direct or indirect.
[0023] Unless otherwise specified, all terms used herein (including technical and scientific terms) have the same meaning as commonly understood by one of ordinary skill in the art. It will also be understood that terms such as those defined in commonly used dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the relevant art and this disclosure, and will not be interpreted as having an idealized or overly formal meaning, unless expressly so defined herein.
[0024] To address the aforementioned technical problems, embodiments of this disclosure provide a video encoding method, comprising: determining a first quantization parameter for encoding a target video to be encoded; determining a second quantization parameter based on a preset image quality noise value, a target mapping relationship, and the first quantization parameter; wherein the image quality noise value is used to indicate the human eye's observation error value of image quality; the target mapping relationship is used to indicate the correspondence between the quantization parameter and the image quality score at the image size of the target video; and encoding multiple video frames of the target video frame by frame based on the first quantization parameter and the second quantization parameter to obtain encoded data of the target video.
[0025] According to the video encoding method of this disclosure, during video encoding, a first quantization parameter for encoding the target video to be encoded is first determined. Then, a second quantization parameter is determined based on the image quality noise value, which indicates the human eye's observation error value of image quality, and the first quantization parameter. Subsequently, multiple video frames of the target video are encoded frame by frame based on the first quantization parameter, the target mapping relationship, and the second quantization parameter to obtain the encoded data of the target video. This allows the image quality and the human eye's observation error value of image quality to be considered when setting the quantization parameters for video encoding. During video encoding, multiple video frames are encoded frame by frame based on the initial quantization parameter (first quantization parameter) and the quantization parameter adjusted based on the image quality noise value (second quantization parameter) to minimize the bitrate during video encoding. This improves the stability of the bitrate while maintaining stable image quality during the video encoding process.
[0026] The video encoding method according to embodiments of this disclosure can be executed by an electronic device such as a terminal device or a server. The terminal device can be a user equipment (UE), mobile device, user terminal, terminal, cellular phone, cordless phone, personal digital assistant (PDA), handheld device, computing device, in-vehicle device, wearable device, etc. The method can be implemented by a processor calling computer-readable program instructions stored in memory. Alternatively, the method can be executed by a server.
[0027] Figure 1A flowchart illustrating a video encoding method provided in an embodiment of this disclosure. (Refer to...) Figure 1 The method includes the following steps S11-S13, which are described in detail below.
[0028] In step S11, a first quantization parameter is determined for encoding the target video to be encoded.
[0029] In step S12, a second quantization parameter is determined based on a preset image quality noise value, a target mapping relationship, and the first quantization parameter. The image quality noise value indicates the human eye's observation error in image quality; the target mapping relationship indicates the correspondence between the quantization parameter and the image quality score at the image size of the target video.
[0030] In step S13, the target video is encoded frame by frame according to the first quantization parameter and the second quantization parameter to obtain the encoded data of the target video.
[0031] In some possible implementations, when encoding the target video to be encoded, a first quantization parameter for encoding the target video can be determined in step S11. The first quantization parameter can be set by the video application to which the target video belongs. The first quantization parameter can also be set by the encoder performing video encoding based on the image content, image size (e.g., resolution) in the target video. This disclosure does not limit the specific value or setting method of the first quantization parameter.
[0032] In some possible implementations, image quality refers to subjective image quality, which is an image quality score or index determined by human observation. Image quality can be determined through Video Multimethod Assessment Fusion (VMAF) or other subjective image quality calculation methods, and this disclosure does not limit this. Since the human eye has errors within a certain range, the observation error value of the human eye in terms of image quality can be regarded as the image quality noise value. For example, when image quality is represented by the VMAF index, the image quality noise value is 1, which can be written as ΔVMAF=1. That is, when ΔVMAF≤1, the two images can be considered to have the same quality. For example, an image with VMAF of 92.3 and an image with VMAF of 92.8 can be considered to have the same quality.
[0033] It should be noted that different methods of calculating image quality will result in different values for image quality noise. Therefore, the specific value of the image quality noise can be set by those skilled in the art according to the actual situation, and this disclosure does not impose any restrictions on it.
[0034] In some possible implementations, in step S12, a second quantization parameter can be determined based on the image quality noise value, the target mapping relationship, and the first quantization parameter. The first quantization parameter can be the original quantization parameter. Determining the second quantization parameter based on the image quality noise value, the target mapping relationship, and the first quantization parameter aims to maximize the value of the quantization parameter without affecting image quality. Therefore, the second quantization parameter determined based on the image quality noise value, the target mapping relationship, and the first quantization parameter is greater than the first quantization parameter.
[0035] When determining the second quantization parameter, the first quantization parameter can be adjusted based on the target mapping relationship and the image quality noise value. For example, the quantization parameter adjustment value corresponding to the image quality noise value can be determined based on the target mapping relationship, and then the sum of the first quantization parameter and the quantization parameter adjustment value can be determined as the second quantization parameter. Alternatively, when determining the second quantization parameter, the image quality score corresponding to the first quantization parameter can be adjusted based on the image quality noise value and the target mapping relationship, and then the second quantization parameter can be determined based on the adjusted image quality score and the target mapping relationship. It should be noted that other methods can also be used to determine the second quantization parameter based on the image quality noise value, the target mapping relationship, and the first quantization parameter, and this disclosure does not limit this.
[0036] In some possible implementations, after obtaining the second quantization parameter, in step S13, multiple video frames of the target video can be encoded frame by frame according to the first quantization parameter and the second quantization parameter to obtain the encoded data of the target video.
[0037] Since the image type (e.g., text image, landscape image, moving image, person image, pet image, etc.) of each video frame in the target video may be different, during encoding, for any video frame in the target video, a target quantization parameter that results in a lower bitrate can be selected from the first and second quantization parameters based on the correspondence between the image type, bitrate, and quantization parameters of that video frame. Then, the video frame is encoded according to the target quantization parameter to obtain the corresponding encoded data for that video frame. This method can be used to encode the video frames in the target video frame by frame, and the resulting encoded data of the video frames is concatenated according to the time sequence of the video frames to obtain the encoded data of the target video, which can be a video bitstream.
[0038] According to the video encoding method of this disclosure, during video encoding, a first quantization parameter for encoding the target video to be encoded is first determined. Then, a second quantization parameter is determined based on the image quality noise value (indicating the human eye's observation error value of image quality), the target mapping relationship, and the first quantization parameter. Subsequently, multiple video frames of the target video are encoded frame by frame based on the first and second quantization parameters to obtain the encoded data of the target video. This allows the image quality and the human eye's observation error value of image quality to be considered when setting the quantization parameters for video encoding. During video encoding, multiple video frames are encoded frame by frame based on the original quantization parameter (first quantization parameter) and the quantization parameter adjusted based on the image quality noise value (second quantization parameter), so as to minimize the bitrate during video encoding. This improves the stability of the bitrate while maintaining stable image quality during the video encoding process.
[0039] The video encoding method according to embodiments of this disclosure will now be described in detail.
[0040] In some possible implementations, to facilitate the determination of the second quantization parameter based on the image quality noise value and the first quantization parameter, a mapping relationship between the quantization parameter and the image quality score can be established. Since the mapping relationship between the quantization parameter and the image quality score varies depending on the image size (e.g., resolution), a mapping relationship set can be established, which includes mapping relationships corresponding to multiple image sizes.
[0041] In some possible implementations, the video encoding method of this disclosure further includes: classifying sample data of multiple sample video frames in a sample set according to a preset plurality of image sizes to obtain a sample subset corresponding to each image size; wherein, the sample data of the sample video frame includes the image size of the sample video frame, a plurality of sample quantization parameters and a sample image quality score corresponding to each sample quantization parameter; for any sample subset corresponding to an image size, determining the mapping relationship corresponding to the image size according to the sample subset.
[0042] The preset image sizes can be multiple preset typical resolutions. For example, the preset image sizes are: 1280px × 720px, 1920px × 1080px, 2560px × 1440px, and 3840px × 2160px. Here, px represents a pixel. The specific number and size of the preset image sizes can be set by those skilled in the art according to actual conditions, and this disclosure does not impose any limitations on this.
[0043] The sample set used to establish the mapping relationship set includes sample data from multiple sample video frames. The sample data for any sample video frame includes the image size of the sample video frame, multiple sample quantization parameters, and the sample image quality score corresponding to each sample quantization parameter.
[0044] Based on multiple preset image sizes and the image sizes of each sample video frame in the sample set, the sample data of multiple sample video frames in the sample set can be classified to obtain sample subsets corresponding to each image size. For example, if the preset image sizes are 1280px×720px, 1920px×1080px, 2560px×1440px, and 3840px×2160px, then the sample data of multiple sample video frames in the sample set can be divided into four sample subsets. All sample video frames in the sample subset corresponding to image size 1280px×720px have an image size of 1280px×720px. All sample video frames in the sample subset corresponding to image size 1920px×1080px have an image size of 1920px×1080px. All sample video frames in the sample subset corresponding to image size 2560px×1440px have an image size of 2560px×1440px. The image size of all sample video frames in the sample subset corresponding to the image size of 3840px×2160px is 3840px×2160px.
[0045] After obtaining the sample subsets corresponding to each image size, for any sample subset corresponding to an image size, the mapping relationship corresponding to that image size can be determined based on the multiple sample quantization parameters in the sample data of multiple sample video frames in that sample subset and the sample image quality scores corresponding to each sample quantization parameter.
[0046] In the embodiments of this disclosure, sample data of multiple sample video frames in a sample set can be classified according to multiple image sizes to obtain sample subsets corresponding to each image size; then, for any sample subset corresponding to an image size, the mapping relationship corresponding to that image size can be determined based on the sample subset, thereby establishing a mapping relationship set including mapping relationships corresponding to multiple image sizes, which improves the accuracy of the mapping relationship.
[0047] In some possible implementations, determining the mapping relationship corresponding to the image size based on the sample subset includes: for any sample video frame in the sample subset, establishing a correspondence between the sample quantization parameters and the sample image quality scores of the sample video frame based on multiple sample quantization parameters in the sample data of the sample video frame and the sample image quality scores corresponding to each sample quantization parameter; determining the convex envelope curve of the correspondence between the sample quantization parameters and the sample image quality scores of each sample video frame in the sample subset; and determining the convex envelope curve as the mapping relationship corresponding to the image size.
[0048] To determine the mapping relationship corresponding to any image size, we can first determine the sample subset corresponding to that image size. Then, for any sample video frame in that sample subset, based on multiple sample quantization parameters in the sample data of that sample video frame and the sample image quality score corresponding to each sample quantization parameter, we can establish the correspondence between the sample quantization parameters and the sample image quality score of that sample video frame through methods such as curve fitting. Afterwards, we can determine the minimum convex hull of the correspondence between the sample quantization parameters and the sample image quality score of each sample video frame in that sample subset, and based on the minimum convex hull, determine a continuous and smooth curve. This curve is the convex hull curve of the correspondence between the sample quantization parameters and the sample image quality score of each sample video frame in that sample subset. This convex hull curve is the mapping relationship corresponding to that image size.
[0049] Figure 2 This is a schematic diagram illustrating the mapping relationship in a video encoding method provided by an embodiment of this disclosure. (Refer to...) Figure 2 The sample subset corresponding to this image size includes four sample video frames. The four curves drawn as solid lines in the figure represent the correspondence between the sample quantization parameters and the sample image quality scores of these four sample video frames. Specifically: Curve A represents the correspondence between the quantization parameters and the sample image quality score of the first sample video frame; Curve B represents the correspondence between the quantization parameters and the sample image quality score of the second sample video frame; Curve C represents the correspondence between the quantization parameters and the sample image quality score of the third sample video frame; and Curve D represents the correspondence between the quantization parameters and the sample image quality score of the fourth sample video frame. The curves drawn as dashed lines in the figure are the convex embossed curves of the correspondence between the sample quantization parameters and the sample image quality scores of these four sample video frames, i.e., the mapping relationship corresponding to this image size.
[0050] In the embodiments of this disclosure, when determining the mapping relationship corresponding to the image size based on a sample subset, for any sample video frame in the sample subset, a correspondence between the sample quantization parameters and the sample image quality scores of the sample video frame can be established based on multiple sample quantization parameters in the sample data of the sample video frame and the sample image quality scores corresponding to each sample quantization parameter. Then, the convex envelope curve of the correspondence between the sample quantization parameters and the sample image quality scores of each sample video frame in the sample subset is determined, and the convex envelope curve is determined as the mapping relationship corresponding to the image size. Thus, the mapping relationship corresponding to the image size can be determined based on the convex envelope curve of the correspondence between the sample quantization parameters and the sample image quality scores of each sample video frame, thereby improving the accuracy of the mapping relationship.
[0051] In some possible implementations, determining the mapping relationship corresponding to the image size based on the sample subset includes: processing the sample subset using a preset mapping relationship model to obtain the mapping relationship corresponding to the image size.
[0052] When determining the mapping relationship corresponding to any image size, a subset of samples corresponding to that image size can be determined first. Then, multiple sample quantization parameters and the corresponding image quality scores of each sample video frame in the subset are input into the mapping relationship model for processing to obtain the mapping relationship corresponding to that image size. The mapping relationship model is a pre-trained neural network, which can be a Multilayer Perceptron (MLP), Extreme Learning Machine (ELM), Deep Residual Network (ResNet), Generalized Regression Neural Network (GRNN), etc. Those skilled in the art can set the specific implementation of the mapping relationship model according to the actual situation, and this disclosure does not limit this.
[0053] In the embodiments of this disclosure, a subset of samples is processed by a mapping relationship model to obtain the mapping relationship corresponding to the image size, thereby improving the processing efficiency when determining the mapping relationship corresponding to the image size.
[0054] In some possible implementations, after establishing the mapping relationship set in the above manner, the method further includes: determining the target mapping relationship from a preset mapping relationship set based on the image size of the target video.
[0055] When determining the target mapping relationship, the image size of the target video (i.e., the image size of each video frame in the target video) can be determined first. Then, based on this image size, the target mapping relationship corresponding to the image size of the target video can be determined from the mapping relationship set. In other words, the target mapping relationship is used to indicate the correspondence between quantization parameters and image quality scores at the image size of the target video.
[0056] In the embodiments of this disclosure, the target mapping relationship can be quickly and accurately determined from the mapping relationship set based on the image size of the target video, thereby improving the processing efficiency when determining the target mapping relationship.
[0057] In some possible implementations, step S12 may include: determining a first image quality score corresponding to the first quantization parameter according to the target mapping relationship; adjusting the first image quality score according to a preset image quality noise value to obtain a second image quality score; and determining a second quantization parameter corresponding to the second image quality score according to the target mapping relationship.
[0058] When determining the second quantization parameter based on the image quality noise value (ΔVMAF) and the first quantization parameter (start_qp), the first image quality score (min_score) corresponding to the first quantization parameter (start_qp) can first be determined according to the target mapping relationship. Then, the first image quality score (min_score) can be adjusted according to the image quality noise value (ΔVMAF) to obtain the second image quality score (min_trans_score). Specifically, the difference between the first image quality score (min_score) and the image quality noise value (ΔVMAF) can be determined as the second image quality score (min_trans_score). Afterwards, the second quantization parameter (trans_qp) corresponding to the second image quality score (min_trans_score) can be determined according to the target mapping relationship.
[0059] Figure 3 This is a schematic diagram illustrating the determination of a second quantization parameter in a video coding method provided in an embodiment of this disclosure. (Refer to...) Figure 3The target mapping relationship is represented by a dashed curve. First, based on this target mapping relationship, the first image quality score (min_score) corresponding to the first quantization parameter (start_qp) can be determined. Then, based on the image quality noise value (ΔVMAF), the first image quality score (min_score) can be adjusted to obtain the second image quality score (min_trans_score). Next, based on the target mapping relationship, the second quantization parameter (trans_qp) corresponding to the second image quality score (min_trans_score) can be determined. The second quantization parameter (trans_qp) is greater than the first quantization parameter (start_qp). The difference between the first and second quantization parameters can be considered as the calculated difference (Δqp_calc).
[0060] It should be noted that, Figure 3 The curve E, plotted as a solid line, represents the correspondence between the actual image quality score and the quantization parameters of a sample video frame. Since the slope of each point on the curve representing the target mapping relationship (i.e., each point in the calculated minimum convex hull) is greater than the slope of the corresponding point on curve E, the calculated difference (Δqp_calc) between the first and second quantization parameters is less than the actual difference (Δqp_real) of the quantization parameters corresponding to the reduction of the image quality score by ΔVMAF on curve E. Based on this, the difference between the image quality score of the reconstructed image obtained after encoding with the second quantization parameter (trans_qp) and the image quality score of the reconstructed image obtained after encoding with the first quantization parameter (start_qp) is within the range of image quality noise values.
[0061] In the embodiments of this disclosure, a first image quality score corresponding to a first quantization parameter can be determined based on a target mapping relationship; then, the first image quality score is adjusted based on the image quality noise value to obtain a second image quality score; and then, a second quantization parameter corresponding to the second image quality score is determined based on the target mapping relationship. This allows the second quantization parameter to be determined quickly and accurately based on the target mapping relationship and the image quality noise value, thereby improving processing efficiency.
[0062] In some possible implementations, step S13 may include: encoding the video frame according to the first quantization parameter to obtain first encoded data; encoding the video frame according to the second quantization parameter to obtain second encoded data; and determining the second encoded data as target encoded data if the bitrate of the first encoded data is greater than or equal to the bitrate of the second encoded data.
[0063] To minimize the bitrate of the video encoding output, frame-by-frame encoding of the target video is performed. For any given video frame, it is encoded using a first quantization parameter (start_qp) to obtain first encoded data, and then encoded using a second quantization parameter (trans_qp) to obtain second encoded data. The bitrates of the first and second encoded data are then calculated and compared. If the bitrate of the first encoded data is greater than or equal to the bitrate of the second encoded data, the second encoded data with the lower bitrate is selected as the encoded data for that video frame.
[0064] In the embodiments of this disclosure, when encoding multiple video frames of a target video frame by frame, for any given video frame, the video frame can be encoded according to a first quantization parameter to obtain first encoded data, and the video frame can be encoded according to a second quantization parameter to obtain second encoded data. Then, if the bitrate of the first encoded data is greater than or equal to the bitrate of the second encoded data, the second encoded data is determined as the encoded data of that video frame. This allows the bitrate of the encoded data to be calculated by encoding the video frame using the original quantization parameter (first quantization parameter) and the quantization parameter adjusted based on the image quality noise value (second quantization parameter), respectively, thereby selecting the encoded data with the lower bitrate. This method is simple, fast, and accurate, not only easy to implement but also improving the efficiency and accuracy of video encoding.
[0065] In some possible implementations, step S13 may further include: determining the first encoded data as the target encoded data when the bit rate of the first encoded data is less than the bit rate of the second encoded data.
[0066] When the bitrate of the first encoded data is less than that of the second encoded data, the first encoded data with the lower bitrate can be determined as the encoded data of the video frame. This is simple, fast, and accurate, and is not only easy to implement, but also improves the efficiency and accuracy of video encoding.
[0067] In some possible implementations, the method further includes: transmitting the encoded data of the target video to a video application so that the video application performs image reconstruction based on the encoded data of the target video.
[0068] After obtaining the encoded data of the target video, the encoded data can be transmitted to the video application. Upon receiving the encoded data, the video application can decode it to obtain decoded data, and then perform image reconstruction based on the decoded data to obtain the reconstructed video.
[0069] In embodiments of this disclosure, encoded data of a target video can be transmitted to a video application, enabling the video application to perform image reconstruction based on the encoded data of the target video. Since the bitrate of the encoded data is kept as low as possible, not only is the bandwidth required for data transmission reduced, but the processing efficiency of image reconstruction is also improved.
[0070] Figure 4 This is a schematic diagram illustrating a video encoding method provided in an embodiment of this disclosure. (Refer to...) Figure 4 The video encoding method may include the following steps S401-S410.
[0071] Step S401: Determine the first quantization parameter to be used for encoding the target video to be encoded.
[0072] Step S402: Determine the target mapping relationship from a preset mapping relationship set based on the image size of the target video.
[0073] The target mapping relationship is used to indicate the correspondence between quantization parameters and image quality scores at the image size of the target video.
[0074] Step S403: Determine the first image quality score corresponding to the first quantization parameter based on the target mapping relationship.
[0075] Step S404: Adjust the first image quality score according to the preset image quality noise value to obtain the second image quality score.
[0076] Step S405: Determine the second quantization parameter corresponding to the second image quality score based on the target mapping relationship.
[0077] In step S406, when encoding multiple video frames of the target video frame by frame, for any video frame, the video frame is encoded according to the first quantization parameter to obtain the first encoded data, and the video frame is encoded according to the second quantization parameter to obtain the second encoded data.
[0078] Step S407: If the bit rate of the first encoded data is less than the bit rate of the second encoded data, the first encoded data is determined as the encoded data of the video frame.
[0079] Step S408: If the bit rate of the first encoded data is greater than or equal to the bit rate of the second encoded data, the second encoded data is determined as the encoded data of the video frame.
[0080] Step S409: The encoded data of each video frame is spliced together according to the time sequence of the video frames to obtain the encoded data of the target video.
[0081] Step S410: The encoded data of the target video is transmitted to the video application so that the video application can perform image reconstruction based on the encoded data of the target video.
[0082] According to the video encoding method of this disclosure, during video encoding, a first quantization parameter for encoding the target video to be encoded is first determined. Then, a second quantization parameter is determined based on the image quality noise value (indicating the human eye's observation error value of image quality), the target mapping relationship, and the first quantization parameter. Subsequently, multiple video frames of the target video are encoded frame by frame based on the first and second quantization parameters to obtain the encoded data of the target video. This allows the image quality and the human eye's observation error value of image quality to be considered when setting the quantization parameters for video encoding. During video encoding, multiple video frames are encoded frame by frame based on the original quantization parameter (first quantization parameter) and the quantization parameter adjusted based on the image quality noise value (second quantization parameter), so as to minimize the bitrate during video encoding. This improves the stability of the bitrate while maintaining stable image quality during the video encoding process.
[0083] It is understood that the various method embodiments mentioned above in this disclosure can be combined with each other to form combined embodiments without violating the principle and logic. Due to space limitations, this disclosure will not elaborate further. Those skilled in the art will understand that in the above methods of specific implementation, the specific execution order of each step should be determined by its function and possible internal logic.
[0084] In addition, this disclosure also provides video encoding apparatus, electronic equipment, and computer-readable storage medium, all of which can be used to implement any of the video encoding methods provided in this disclosure. The corresponding technical solutions and descriptions are described in the corresponding section of the method and will not be repeated here.
[0085] Figure 5 This is a block diagram of a video encoding apparatus provided in an embodiment of the present disclosure.
[0086] Reference Figure 5 This disclosure provides a video encoding apparatus, which includes:
[0087] The first parameter determination module 51 is used to determine the first quantization parameter for encoding the target video to be encoded.
[0088] The second parameter determination module 52 is used to determine a second quantization parameter based on a preset image quality noise value, a target mapping relationship, and the first quantization parameter; wherein the image quality noise value is used to indicate the human eye's observation error value of image quality; the target mapping relationship is used to indicate the correspondence between the quantization parameter and the image quality score under the image size of the target video;
[0089] The encoding module 53 is used to encode multiple video frames of the target video frame by frame according to the first quantization parameter and the second quantization parameter to obtain the encoded data of the target video.
[0090] In some possible implementations, the encoding module 53 is specifically configured to: encode any video frame in the target video according to the first quantization parameter to obtain first encoded data; encode the video frame according to the second quantization parameter to obtain second encoded data; and determine the second encoded data as the encoded data of the video frame if the bitrate of the first encoded data is greater than or equal to the bitrate of the second encoded data.
[0091] In some possible implementations, the encoding module 53 is further specifically used to: determine the first encoded data as the encoded data of the video frame when the bit rate of the first encoded data is less than the bit rate of the second encoded data.
[0092] In some possible implementations, the second parameter determination module 52 is specifically used to: determine a first image quality score corresponding to the first quantization parameter according to the target mapping relationship; adjust the first image quality score according to a preset image quality noise value to obtain a second image quality score; and determine a second quantization parameter corresponding to the second image quality score according to the target mapping relationship.
[0093] In some possible implementations, the apparatus further includes a mapping relationship determination module, configured to determine the target mapping relationship from a preset mapping relationship set based on the image size of the target video.
[0094] In some possible implementations, the mapping relationship set includes mapping relationships corresponding to multiple image sizes; the device further includes: a classification module, used to classify sample data of multiple sample video frames in the sample set according to multiple preset image sizes, to obtain sample subsets corresponding to each image size; wherein, the sample data of the sample video frame includes the image size of the sample video frame, multiple sample quantization parameters, and sample image quality scores corresponding to each sample quantization parameter; and a mapping relationship establishment module, for any sample subset corresponding to an image size, determining the mapping relationship corresponding to the image size based on the sample subset.
[0095] In some possible implementations, the mapping relationship establishment module is specifically used to: for any sample video frame in the sample subset, establish a correspondence between the sample quantization parameters and the sample image quality scores of the sample video frame based on multiple sample quantization parameters in the sample data of the sample video frame and the sample image quality scores corresponding to each sample quantization parameter; determine the convex envelope curve of the correspondence between the sample quantization parameters and the sample image quality scores of each sample video frame in the sample subset; and determine the convex envelope curve as the mapping relationship corresponding to the image size.
[0096] In some possible implementations, the mapping relationship establishment module is specifically used to: process the sample subset through a preset mapping relationship model to obtain the mapping relationship corresponding to the image size.
[0097] In some possible implementations, the apparatus further includes a transmission module for transmitting the encoded data of the target video to a video application, so that the video application performs image reconstruction based on the encoded data of the target video.
[0098] Figure 6 This is a block diagram of an electronic device provided in an embodiment of the present disclosure.
[0099] Reference Figure 6 This disclosure provides an electronic device, which includes: at least one processor 701; at least one memory 702; and one or more I / O interfaces 703 connected between the processor 701 and the memory 702; wherein the memory 702 stores one or more computer programs that can be executed by the at least one processor 701, and the one or more computer programs are executed by the at least one processor 701 to enable the at least one processor 701 to perform the video encoding method described above.
[0100] This disclosure also provides a computer-readable storage medium storing a computer program thereon, wherein the computer program, when executed by a processor, implements the video encoding method described above. The computer-readable storage medium may be volatile or non-volatile.
[0101] This disclosure also provides a computer program product, including computer-readable code, or a non-volatile computer-readable storage medium carrying computer-readable code, wherein when the computer-readable code is run in a processor of an electronic device, the processor in the electronic device executes the above-described video encoding method.
[0102] Those skilled in the art will understand that all or some of the steps, systems, and apparatuses disclosed above, and their functional modules / units, can be implemented as software, firmware, hardware, or suitable combinations thereof. In hardware implementations, the division between functional modules / units mentioned above does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed collaboratively by several physical components. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit (ASIC). Such software can be distributed on a computer-readable storage medium, which may include computer storage media (or non-transitory media) and communication media (or transient media).
[0103] As is known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information, such as computer-readable program instructions, data structures, program modules, or other data. Computer storage media includes, but is not limited to, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), static random access memory (SRAM), flash memory or other memory technologies, portable compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical disc storage, magnetic cartridges, magnetic tape, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and is accessible to a computer. Furthermore, it is known to those skilled in the art that communication media typically contain computer-readable program instructions, data structures, program modules, or other data in modulated data signals such as carrier waves or other transmission mechanisms, and may include any information delivery medium.
[0104] The computer-readable program instructions described herein can be downloaded from computer-readable storage media to various computing / processing devices, or downloaded via a network, such as the Internet, local area network, wide area network, and / or wireless network, to an external computer or external storage device. The network may include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers, and / or edge servers. A network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards them to the computer-readable storage media in the respective computing / processing device.
[0105] Computer program instructions used to perform the operations of this disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, status setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages such as Smalltalk, C++, etc., and conventional procedural programming languages such as the "C" language or similar programming languages. The computer-readable program instructions may execute entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or may be connected to an external computer (e.g., via the Internet using an Internet service provider). In some embodiments, electronic circuitry, such as programmable logic circuitry, field-programmable gate arrays (FPGAs), or programmable logic arrays (PLAs), is personalized by utilizing the status information of the computer-readable program instructions to implement various aspects of this disclosure.
[0106] The computer program product described herein can be implemented specifically through hardware, software, or a combination thereof. In one alternative embodiment, the computer program product is specifically embodied in a computer storage medium; in another alternative embodiment, the computer program product is specifically embodied in a software product, such as a software development kit (SDK), etc.
[0107] Various aspects of this disclosure are described herein with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this disclosure. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer-readable program instructions.
[0108] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that, when executed by the processor of the computer or other programmable data processing apparatus, they create means for implementing the functions / actions specified in one or more blocks of the flowchart and / or block diagram. These computer-readable program instructions can also be stored in a computer-readable storage medium that causes a computer, programmable data processing apparatus, and / or other device to operate in a particular manner; thus, the computer-readable medium storing the instructions comprises an article of manufacture that includes instructions for implementing aspects of the functions / actions specified in one or more blocks of the flowchart and / or block diagram.
[0109] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to perform the functions / actions specified in one or more boxes of a flowchart and / or block diagram.
[0110] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of an instruction containing one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions marked in the blocks may occur in a different order than those shown in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.
[0111] Example embodiments have been disclosed herein, and while specific terminology has been used, it is for illustrative purposes only and should be construed as such, and is not intended to be limiting. In some instances, it will be apparent to those skilled in the art that features, characteristics, and / or elements described in connection with particular embodiments may be used alone, or in combination with features, characteristics, and / or elements described in connection with other embodiments, unless otherwise expressly indicated. Therefore, those skilled in the art will understand that various changes in form and detail may be made without departing from the scope of this disclosure as set forth by the appended claims.
Claims
1. A video encoding method, characterized in that, include: Determine the first quantization parameter to be used for encoding the target video to be encoded; A second quantization parameter is determined based on a preset image quality noise value, a target mapping relationship, and the first quantization parameter; wherein the image quality noise value is used to indicate the human eye's observation error value of image quality; and the target mapping relationship is used to indicate the correspondence between the quantization parameter and the image quality score under the image size of the target video. Based on the first quantization parameter and the second quantization parameter, multiple video frames of the target video are encoded frame by frame to obtain the encoded data of the target video.
2. The method according to claim 1, characterized in that, The step of encoding multiple video frames of the target video frame by frame according to the first quantization parameter and the second quantization parameter to obtain the encoded data of the target video includes: For any video frame in the target video, the video frame is encoded according to the first quantization parameter to obtain first encoded data; The video frame is encoded according to the second quantization parameter to obtain second encoded data; If the bitrate of the first encoded data is greater than or equal to the bitrate of the second encoded data, the second encoded data is determined as the encoded data of the video frame.
3. The method according to claim 2, characterized in that, The step of encoding multiple video frames of the target video frame by frame according to the first quantization parameter and the second quantization parameter to obtain the encoded data of the target video further includes: If the bitrate of the first encoded data is less than the bitrate of the second encoded data, the first encoded data is determined as the encoded data of the video frame.
4. The method according to claim 1, characterized in that, The step of determining the second quantization parameter based on the preset image quality noise value, target mapping relationship, and the first quantization parameter includes: Based on the target mapping relationship, determine the first image quality score corresponding to the first quantization parameter; The first image quality score is adjusted according to the preset image quality noise value to obtain the second image quality score; Based on the target mapping relationship, the second quantization parameter corresponding to the second image quality score is determined.
5. The method according to claim 4, characterized in that, The method further includes: Based on the image size of the target video, the target mapping relationship is determined from a preset mapping relationship set.
6. The method according to claim 5, characterized in that, The mapping set includes mapping relationships corresponding to multiple image sizes; the method further includes: Based on multiple preset image sizes, the sample data of multiple sample video frames in the sample set are classified to obtain sample subsets corresponding to each image size; wherein, the sample data of the sample video frame includes the image size of the sample video frame, multiple sample quantization parameters, and sample image quality scores corresponding to each sample quantization parameter; For any sample subset corresponding to any image size, determine the mapping relationship corresponding to the image size based on the sample subset.
7. The method according to claim 6, characterized in that, Determining the mapping relationship corresponding to the image size based on the sample subset includes: For any sample video frame in the sample subset, a correspondence between the sample quantization parameters and the sample image quality scores of the sample video frame is established based on multiple sample quantization parameters in the sample data of the sample video frame and the sample image quality scores corresponding to each sample quantization parameter. A convex envelope curve that determines the correspondence between the sample quantization parameters and the sample image quality scores of each video frame in the sample subset; The convex envelope curve is determined as the mapping relationship corresponding to the image size.
8. The method according to claim 6, characterized in that, Determining the mapping relationship corresponding to the image size based on the sample subset includes: The sample subset is processed using a preset mapping model to obtain the mapping relationship corresponding to the image size.
9. The method according to any one of claims 1-8, characterized in that, The method further includes: The encoded data of the target video is transmitted to a video application so that the video application can perform image reconstruction based on the encoded data of the target video.
10. A video encoding device, characterized in that, include: The first parameter determination module is used to determine the first quantization parameter for encoding the target video to be encoded. The second parameter determination module is used to determine a second quantization parameter based on a preset image quality noise value, a target mapping relationship, and the first quantization parameter; wherein the image quality noise value is used to indicate the human eye's observation error value of image quality; and the target mapping relationship is used to indicate the correspondence between the quantization parameter and the image quality score under the image size of the target video. The encoding module is used to encode multiple video frames of the target video frame by frame according to the first quantization parameter and the second quantization parameter to obtain the encoded data of the target video.
11. An electronic device, characterized in that, include: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores one or more computer programs that can be executed by the at least one processor, the one or more computer programs being executed by the at least one processor to enable the at least one processor to perform the video encoding method as described in any one of claims 1-9.
12. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the video encoding method as described in any one of claims 1-9.