Video encoding method and related apparatus, encoding device, and storage medium
By adjusting the quantization parameters based on the bitrate control model and numerical mapping relationship, the problems of unstable video quality and visual abrupt changes in traditional video coding are solved, thereby achieving stability in video coding and improving user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZHEJIANG DAHUA TECH CO LTD
- Filing Date
- 2022-09-19
- Publication Date
- 2026-06-30
AI Technical Summary
Traditional video encoding methods cannot ensure stable video quality, resulting in poor user experience and a tendency for visual abrupt changes.
By analyzing the actual allocated bitrate based on the bitrate control model, the quantization parameters of the current frame are obtained, and the quality parameters are determined using numerical mapping relationships. The quantization parameters are then adjusted based on the quality difference between the previous and next frames to ensure the stability of video encoding quality.
It improves the accuracy of video encoding parameters, reduces visual abrupt changes, and ensures the stability of video quality.
Smart Images

Figure CN115941946B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and in particular to a video encoding method and related apparatus, encoding equipment, and storage medium. Background Technology
[0002] In recent years, with the continuous optimization of information infrastructure, people's demand for high-definition and ultra-high-definition audiovisual technology has also increased, profoundly affecting the technological innovation process in the video field. In particular, video coding technology has become one of the key research and development areas.
[0003] Traditional video encoding methods, during the encoding of the current frame, cannot guarantee stable subjective quality and are susceptible to visual abrupt changes, resulting in a poor user experience. Therefore, ensuring stable video quality while minimizing visual abrupt changes has become a pressing issue. Summary of the Invention
[0004] The main technical problem addressed by this application is to provide a video encoding method and related apparatus, encoding equipment, and storage medium that can ensure video quality stability and minimize visual abrupt changes.
[0005] To address the aforementioned issues, the first aspect of this application provides a video coding method, comprising: analyzing the actual allocated bitrate based on a bitrate control model to obtain a first quantization parameter of the current frame in the video to be encoded; mapping the first quantization parameter based on a numerical mapping relationship to obtain a first quality parameter of the current frame, wherein the numerical mapping relationship characterizes the correspondence between the quantization parameter and the quality parameter; the first quality parameter characterizes the value of the quality parameter after encoding the current frame based on the first quantization parameter; and determining whether to correct the first quantization parameter based on a first difference between the first quality parameter and a second quality parameter of a reference frame to obtain a target quantization parameter of the current frame; wherein the reference frame is the frame preceding the current frame in the video to be encoded; the second quality parameter characterizes the value of the quality parameter after encoding the reference frame based on the second quantization parameter; and encoding the current frame based on the target quantization parameter of the current frame.
[0006] To address the aforementioned problems, a second aspect of this application provides a video encoding apparatus, comprising an acquisition module, an analysis module, a mapping module, a determination module, and an encoding module. The analysis module performs analysis based on a bitrate control model and the actual allocated bitrate to obtain a first quantization parameter of the current frame in the video to be encoded. The mapping module maps the first quantization parameter based on a numerical mapping relationship to obtain a first quality parameter of the current frame. The numerical mapping relationship represents the correspondence between the quantization parameter and the quality parameter. The first quality parameter represents the value of the quality parameter encoded based on the first quantization parameter. The determination module determines whether to correct the first quantization parameter based on a first difference between the first quality parameter and a second quality parameter of a reference frame, thereby obtaining a target quantization parameter for the current frame. The reference frame is the frame preceding the current frame in the video to be encoded. The second quality parameter represents the value of the quality parameter encoded based on the second quantization parameter of the reference frame. The encoding module encodes the current frame based on the target quantization parameter.
[0007] To address the aforementioned problems, a third aspect of this application provides an encoding device, including a memory and a processor coupled to each other, wherein the memory stores program instructions and the processor executes the program instructions to implement the video encoding method of the first aspect described above.
[0008] To address the aforementioned problems, a fourth aspect of this application provides a computer-readable storage medium storing program instructions executable by a processor, the program instructions being used to implement the video encoding method described in the first aspect.
[0009] The above scheme analyzes the actual allocated bitrate based on the bitrate control model to obtain the first quantization parameter of the current frame in the video to be encoded; then, it maps the first quantization parameter based on the numerical mapping relationship to obtain the first quality parameter of the current frame, where the numerical mapping relationship represents the correspondence between the quantization parameter and the quality parameter; the first quality parameter represents the value of the quality parameter after encoding the current frame based on the first quantization parameter; and based on the first difference between the first quality parameter and the second quality parameter of the reference frame, it determines whether to correct the first quantization parameter to obtain the target quantization parameter of the current frame; the reference frame is the frame preceding the current frame in the video to be encoded; the second quality parameter represents the value of the quality parameter after encoding the reference frame based on the second quantization parameter; and finally, the current frame is encoded based on the target quantization parameter of the current frame. On the one hand, analysis based on the bitrate control model and the actual allocated bitrate is performed to obtain the first quantization parameter of the current frame in the video to be encoded, which helps to improve the accuracy of the video encoding parameters of the current frame in the video to be encoded. On the other hand, by constraining the values of the quality parameters of the two frames before and after, that is, by using the first difference between the encoding parameters of the two frames before and after, it is determined whether to correct the first quantization parameter. Thus, after the video to be encoded is encoded, the stability of video quality can be ensured and visual abrupt changes can be minimized.
[0010] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this application. Attached Figure Description
[0011] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with this application and, together with the specification, serve to explain the technical solutions of this application.
[0012] Figure 1 This is a flowchart illustrating an embodiment of the video encoding method of this application;
[0013] Figure 2 This is a flowchart illustrating one embodiment of the process of obtaining the target quantization parameters of the current frame;
[0014] Figure 3 This is a flowchart illustrating another embodiment of the video encoding method of this application;
[0015] Figure 4 This is a schematic diagram of the framework of an embodiment of the video encoding apparatus of this application;
[0016] Figure 5 This is a schematic diagram of the framework of an embodiment of the encoding device of this application;
[0017] Figure 6 This is a schematic diagram of a framework of an embodiment of the computer-readable storage medium of this application. Detailed Implementation
[0018] The embodiments of this application will now be described in detail with reference to the accompanying drawings.
[0019] In the following description, specific details such as particular system architectures, interfaces, and technologies are presented for illustrative purposes rather than for limiting purposes, in order to provide a thorough understanding of this application.
[0020] In this document, the term "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Additionally, the character " / " generally indicates that the preceding and following related objects have an "or" relationship. Furthermore, "many" in this document means two or more. Moreover, the term "at least one" in this document means any combination of at least two of any one or more of a plurality of objects. For example, including at least one of A, B, and C can mean including any one or more elements selected from the set consisting of A, B, and C.
[0021] Please see Figure 1 , Figure 1This is a flowchart illustrating an embodiment of the video encoding method of this application.
[0022] Specifically, this may include the following steps:
[0023] Step S11: Based on the bitrate control model and the actual allocated bitrate, analyze to obtain the first quantization parameter of the current frame in the video to be encoded.
[0024] In one implementation scenario, before analyzing the bitrate control model and the actual allocated bitrate to obtain the first quantization parameter of the current frame in the video to be encoded, the actual allocated bitrate can be obtained first. Specifically, the user can directly input the set allocated bitrate, and after obtaining the user-set allocated bitrate, the set allocated bitrate is determined as the actual allocated bitrate.
[0025] In another implementation scenario, to improve the accuracy of the actual allocated bitrate, the target allocated bitrate and target quality level set by the user can be received first. The target allocated bitrate is the user's desired allocated bitrate, and the target quality level is no higher than the highest quality level. After obtaining the user-set target allocated bitrate and target quality level, the target allocated bitrate can be weighted based on the ratio between the target quality level and the highest quality level to obtain the actual allocated bitrate. For example, let R... target The target bitrate is set by the user, and quality is the target quality level. max For the highest quality level, where `function` represents the functional allocation, the actual allocated bitrate R is... alloc It can be calculated using the following formula:
[0026] R alloc =function(R target quality, quality max )
[0027] The function includes, but is not limited to, the following formulas:
[0028]
[0029] Here, θ is a weighting coefficient, with a value ranging from 0 to 1. In a specific implementation scenario, θ can range from 0.9 to 1, thus ensuring that the actual allocated bitrate does not exceed the target allocated bitrate during the weighting process. By weighting the target allocated bitrate, errors in confirming the actual allocated bitrate can be reduced, thereby improving the accuracy of the obtained quantization parameters.
[0030] In one implementation scenario, after obtaining the actual allocated bitrate, further analysis can be performed based on the bitrate control model and the actual allocated bitrate to obtain the first quantization parameter of the current frame in the video to be encoded. For example, the QP or quantization factors λ, ρ, etc., of the current frame in the encoded video can be calculated based on the bitrate control model. Specifically, QP, λ, etc., can be calculated using the R-λ model, the RQ model, or the R-ρ model. It should be noted that the bitrate control model is selected from a model set, which includes at least one of the R-λ, R-ρ, and RQ models. The bitrate control model represents the correspondence between quantization parameters and bitrate, and the quantization parameters include QP or any of the quantization factors of the bitrate control model. When the R-λ model is selected as the bitrate control model, the quantization factor is λ; when the R-ρ model is selected, the quantization factor is ρ; and when the RQ model is selected, the quantization factor is qscale.
[0031] In a specific implementation scenario, the rate control model is the R-λ model. The R-λ model establishes a mapping relationship between the allocated bits R (bpp) and the quantization factor λ, which can be represented as follows:
[0032] λ=α·bpp β
[0033] Here, α and β are parameters that can be initialized. For example, α can be initialized to 3.2003, β to -1.367, and bpp to 0.4. Alternatively, α can be initialized to 3, β to -1, and bpp to 0.3. The initial values of the parameters can be set according to the actual situation and are not specifically limited here. For example, when α is initialized to 3.2003, β to -1.367, and bpp to 0.4, the corresponding calculation result for λ is:
[0034] λ=α·bpp β =3.2003*(0.4) -1.367 =11.2
[0035] The quantization factor λ of the current frame with respect to video coding is calculated by allocating bits bpp and parameters α and β. The quantization parameter QP is obtained through a fixed mapping relationship. The mapping relationship between λ and QP is expressed as follows:
[0036] QP=4.2*ln(λ)+13=4.2*ln(11.2)+13≈24
[0037] It should be noted that QP is the quantization step number, and therefore must be an integer. From this, we can derive the quantization factor λ of the current frame as 11.2 and the quantization parameter QP as 24.
[0038] Furthermore, after obtaining the quantization factor of the current frame with respect to video coding, the parameters in the mapping relationship between the allocated bits R (bpp) and the quantization factor λ can be updated. Specifically, α and β can be updated based on the quantization parameters of the previous frame, thereby ensuring that the difference in quantization parameters between frames is small. The update method used for parameter α can be expressed as follows:
[0039] α new =α old +θ α *(ln(λ act )-ln(λ com ))*α old
[0040] Where, α new This represents the updated parameter α, α old Represents the quantization parameters α and θ of the previous frame. α λ represents a coefficient used to adjust the convergence speed of the formula. It can be set according to the actual situation; for example, it can be set to 0.1. act It is calculated through a mapping relationship using the QP actually used in the encoding process of the previous frame of video. That is, first obtain the QP actually used in the encoding process of the previous frame of video, and then calculate λ through the mapping relationship between λ and QP. act Value; λ com It is calculated using the allocated bits bpp actually used in the encoding of the previous frame of video through a mapping relationship. It should be noted that during the calculation, the parameter values for α and β are the quantization parameters of the previous frame. Specifically, the allocated bits bpp actually used in the encoding of the previous frame of video can be obtained first, and then λ can be calculated using the mapping relationship between the allocated bits bpp and the quantization factor λ. com The update method used for parameter β can be expressed as follows:
[0041] β new =β old +θ β *(ln(λ act )-ln(λ com ))*lnbpp act
[0042] Where, β new This represents the updated parameter β, β old Represents the quantization parameters β and θ of the previous frame. βThis represents a coefficient used to adjust the convergence speed of the formula. It can be set according to the actual situation; for example, it can be set to 0.05, or 0.04, 0.03, etc., depending on the specific circumstances. λ act It is calculated through a mapping relationship using the QP actually used in the encoding process of the previous frame of video. That is, first obtain the QP actually used in the encoding process of the previous frame of video, and then calculate λ through the mapping relationship between λ and QP. act Value; λ com It is calculated using the allocated bits bpp actually used in the encoding of the previous frame of video through a mapping relationship. It should be noted that during the calculation, the parameter values for α and β are the quantization parameters of the previous frame. Specifically, the allocated bits bpp actually used in the encoding of the previous frame of video can be obtained first, and then λ can be calculated using the mapping relationship between the allocated bits bpp and the quantization factor λ. com Value; bpp act This represents the allocated bits (bpp) actually used during the encoding of the previous frame of video. After updating the video encoding parameters α and β for each frame, the quantization parameter QP for each frame is obtained based on the updated parameters. Of course, the rate control model can also be the RQ model, R-ρ model, etc., and the way different rate control models calculate the quantization parameter QP for each frame can be deduced by analogy, which will not be elaborated here.
[0043] It should be noted that if the bitrate control parameter is an R-λ model and the quantization parameter is a quantization factor λ, after obtaining the quantization parameter, QP must be calculated based on the mapping relationship expression between λ and QP, and then the first quantization parameter of the current frame in the video to be encoded can be obtained.
[0044] Step S12: Map the first quantization parameter based on the numerical mapping relationship to obtain the first quality parameter of the current frame.
[0045] In one implementation scenario, before mapping the first quantization parameter based on the numerical mapping relationship to obtain the first quality parameter of the current frame, the correspondence between the quantization parameter and the quality parameter can be obtained first, i.e., the numerical mapping relationship between the quantization parameter and the quality parameter. Specifically, the numerical mapping relationship between the quality parameter and the quantization parameter can be obtained by fitting sample videos under different scenarios. It should be noted that this can be any numerical mapping relationship between the quantization parameter and the quality parameter. For example, when the bitrate control model is an R-λ model, it can be the mapping relationship between the quantization factor λ and the quality parameter PSNR, or it can be the mapping relationship between QP and the quality parameter SSIM. For example, the sample video can be a video shot during the day, a video shot at night, or even a video shot in the rain. The shooting scenario of the sample video can be selected according to the actual situation and is not specifically limited here. Specifically, a Fix-QP encoding process can be performed multiple times on sample videos of a specific scene. This involves encoding a single frame of the video with a fixed QP (or a fixed quantization factor) to obtain the PSNR. From this, the quantization parameters corresponding to that frame are obtained. These parameters can include spatiotemporal texture complexity, QP, PSNR, etc., without specific limitations. After obtaining a large number of quantization parameters for different scenes, a fitting process is performed to obtain the numerical mapping relationship between the quality parameters and the quantization parameters. This method, by fitting sample videos from different scenes separately, helps to improve the accuracy of the numerical mapping relationship between quality parameters and quantization parameters in different scenes.
[0046] In a specific implementation scenario, scene detection is first performed on the video to be encoded to obtain the target scene to which the video belongs. Then, the numerical mapping relationship between quality parameters and quantization parameters under the target scene is selected as the applicable numerical mapping relationship for the video to be encoded. This method, by detecting the scene and selecting the corresponding numerical mapping relationship, improves the accuracy of selecting the numerical mapping relationship between quality assessment parameters and quantization parameters.
[0047] In one implementation scenario, the quality parameter represents the evaluation parameter used to assess the coding quality after encoding. For example, the quality parameter can be PSNR (Peak Signal-to-Noise Ratio) or SSIM (Structural Similarity Index). The quality parameter can be determined according to the actual situation, and no specific limitation is made here.
[0048] In one implementation scenario, quantization parameters are used to encode each video frame, and these parameters can be determined based on a bitrate control model. For example, quantization parameters may include QP, or quantization factors λ, ρ, and qscale. The specific quantization parameters can be determined based on the actual situation and are not specifically limited here. Furthermore, the quantization parameters can be determined based on a bitrate control model selected from a model set. The model set must include at least one of the R-λ model, R-ρ model, and RQ model; of course, the model set may also include the URQ model. The models in the model set can be selected based on the actual situation and are not specifically limited here.
[0049] In a specific implementation scenario, the quantization parameters can be further selected after the rate control model is determined. For example, when the rate control model is an R-λ model, the quantization parameters include either the quantization factor λ or QP (Quantizer Parameter), and the quality parameters can be either PSNR or SSIM; when the rate control model is an RQ model, the quantization parameters include either the quantization factor qscale or QP, and the quality parameters can be either PSNR or SSIM; when the rate control model is an R-ρ model, the quantization parameters include either the quantization factor ρ or QP, and the quality parameters can be either PSNR or SSIM. The rate control model can be selected according to the actual situation, and the quantization parameters can be determined based on the rate control model; no specific limitations are made here.
[0050] In one implementation scenario, the numerical mapping relationship between quality parameters and quantization parameters can be represented by a functional relationship, which may include, but is not limited to, exponential functions, logarithmic functions, power functions, etc.
[0051] In one implementation scenario, the numerical mapping relationship is also related to the spatiotemporal texture complexity, and several numerical intervals of the spatiotemporal texture complexity each correspond to different numerical mapping relationships. Therefore, we can first obtain the complexity value of the current frame with respect to the spatiotemporal texture complexity, and then select the numerical mapping relationship corresponding to the numerical interval where the complexity value lies as the applicable numerical mapping relationship for the current frame. This method, by selecting the corresponding numerical mapping relationship based on the complexity value of the current frame with respect to the spatiotemporal texture complexity, helps to improve the accuracy of selecting the numerical mapping relationship.
[0052] In a specific implementation scenario, temporal texture information is used to measure the temporal texture complexity of the current frame, while spatial texture information is used to measure the spatial texture complexity of the current frame. To obtain the complexity value of the current frame with respect to its temporal and spatial texture complexity, we can first obtain the first complexity value of the current frame relative to the reference frame with respect to its temporal texture complexity. It should be noted that the reference frame is the frame preceding the current frame in the video to be encoded. Specifically, we can first obtain the information of the reference frame, using P... curr-1 This means that, based on the pixel difference between the current block and the block at the same position in the reference frame image, the temporal texture complexity BlkT of the current block is calculated. The calculation formula is as follows:
[0053]
[0054] Where ∑ represents the cumulative sum, and M and N represent the width and height of the current block, respectively. This represents the value of the current frame's pixels. This represents the value of the reference frame pixel, and || indicates taking the absolute value. Assuming the total number of macroblocks in the current frame image is D, the temporal texture complexity of the current frame image is the average of the sum of the temporal texture complexities of all macroblocks, calculated as follows:
[0055]
[0056] Where ∑ represents the cumulative sum, and textureT is the first complexity value of the temporal texture complexity. Furthermore, to obtain the second complexity value of the spatial texture complexity of the current frame, specifically, we can first calculate the average pixel value of the current block. Assuming the current block size is M*N, the calculation formula is as follows:
[0057]
[0058] Where ∑ represents the cumulative sum, M and N represent the width and height of the current block, respectively, and P i,j Indicates the current block pixel value. This represents the average pixel value. Based on this, the difference between the values of all pixels in the current block and the average pixel value is calculated. These differences are then summed and averaged to obtain the spatial texture complexity BlkS for each pixel block. The calculation formula is as follows:
[0059]
[0060] Where ∑ represents the cumulative sum, M and N represent the width and height of the current block, respectively, and P i,j Indicates the current block pixel value. represents the average pixel value, and || represents taking the absolute value. Assuming the total number of macroblocks in the current frame image is D, the spatial texture complexity of the current frame image is the average of the sum of the spatial texture complexities of all macroblocks, calculated as follows:
[0061]
[0062] Where ∑ represents BlkT, where k takes values from 0 to D-1. S The sum of these values, where textureS is the second complexity value of the spatial texture complexity of the current frame. Based on this, to more accurately represent the texture information of the current frame image, the spatial and temporal texture complexity of the image can be combined. That is, a weighted average can be performed based on the first and second complexity values to obtain the spatiotemporal texture complexity of the current frame. Specifically, the first complexity value is textureT, and the second complexity value is textureS. The weighted average of textureS and textureT is calculated using the following formula:
[0063] textureST=k1·textureS+k2·textureT
[0064] Here, textureST represents the complexity value of the current frame's spatiotemporal texture complexity, and k1 and k2 are the weighting coefficients of the first and second complexity values, respectively, with the relationship k1+k2=1. This method, by weighting the first and second complexity values, helps improve the accuracy of the current frame's spatiotemporal texture complexity value.
[0065] In a specific implementation scenario, based on the spatiotemporal texture complexity value of the video to be encoded, a numerical mapping relationship between the quality parameters and quantization parameters is fitted. Furthermore, the spatiotemporal texture complexity value of the video to be encoded can be obtained. Based on this complexity value, the numerical mapping relationship between the quality parameters and quantization parameters corresponding to the complexity value is selected as the applicable numerical mapping relationship for the video to be encoded. Then, based on the bitrate control model and the actual allocated bitrate, analysis is performed to obtain the first quantization parameter of the current frame in the video to be encoded.
[0066] In an implementation scenario, a numerical mapping relationship between a quality parameter and a quantization parameter can be obtained by fitting based on the video to be encoded in different scenarios and in combination with the complexity value of the spatio-temporal domain texture complexity of the video to be encoded. Specifically, the quantization parameter QP or quantization factors λ, ρ, etc. can be used to determine the PSNR, and then the quantization parameter corresponding to the current frame image can be obtained. After obtaining a large number of quantization parameters with different spatio-temporal domain texture complexities, fitting is performed, and then the numerical mapping relationship between the quality parameter and the quantization parameter is determined. Exemplarily, the numerical mapping relationship between the quality parameter and the quantization parameter can be expressed as:
[0067] PSNR = function(quantization parameter, textureST)
[0068] where PSNR is the quality evaluation parameter, function represents the functional function, and textureST is the complexity value of the spatio-temporal domain texture complexity; it should be noted that the quantization parameter can be QP, or quantization factors λ, ρ, etc. Further, taking the quantization parameter QP as an example, this mapping relationship can be expressed as:
[0069] function(QP, textureST) = α * exp(β * QP)
[0070] where α and β are parameters that can be determined according to the actual situation and are not specifically limited here.
[0071] In a specific implementation scenario, scene detection is performed on the video to be encoded to obtain the target scene to which the video to be encoded belongs. Then, in combination with the complexity value of the spatio-temporal domain texture complexity of the video to be encoded, the numerical mapping relationship between the quality parameter and the quantization parameter in the current scene is selected as the numerical mapping relationship applicable to the video to be encoded. Based on this, analysis is performed based on the bitrate control model and the actual allocated bitrate to obtain the first quantization parameter of the current frame in the video to be encoded.
[0072] In an implementation scenario, in order to obtain the first quality parameter of the current frame, the first quantization parameter of the current frame regarding the quantization parameter can be obtained first, and the numerical mapping relationship between the quality parameter and the quantization parameter is determined. Based on the numerical mapping relationship, the first quality parameter after encoding the current frame based on the first quantization parameter can be obtained. Exemplarily, if the complexity value of the spatio-temporal domain texture complexity of the current frame is 20, the quantization parameter is QP, the quality parameter is PSNR, and the numerical mapping relationship between the quality parameter and the quantization parameter is: when 15 < textureST < 30, this mapping relationship is expressed as:
[0073] PSNR = α * exp(β * QP) = 40 * exp(-0.02 * QP)
[0074] If the value of QP is 24, then the first quality parameter after encoding the current frame based on the first quantization parameter is calculated as follows:
[0075] PSNR=40*exp(-0.02*QP)=24.8
[0076] In another implementation scenario, to obtain the second quality parameter of the reference frame after encoding, the second quantization parameter of the reference frame can be obtained first, and the numerical mapping relationship between the quality parameter and the quantization parameter can be determined. Based on the numerical mapping relationship, the second quality parameter of the reference frame encoded based on the second quantization parameter can be obtained. For example, if the spatiotemporal texture complexity of the reference frame is 40, the quantization parameter is QP, the quality parameter is PSNR, and the numerical mapping relationship between the quality parameter and the quantization parameter is: when 30 ≤ textureST < 50, this mapping relationship is expressed as:
[0077] PSNR=α*exp(β*QP)=30*exp(-0.03*QP)
[0078] If the value of QP is 24, then the second quality parameter calculated based on the first quantization parameter after encoding the reference frame is:
[0079] PSNR=30*exp(-0.03*QP)=14.6
[0080] Therefore, it can be seen that when the numerical mapping relationship between the quality parameter and the quantization parameter is represented by a piecewise function, the numerical mapping relationship expression remains the same for determining the target scene to which the video to be encoded belongs, provided that the spatiotemporal texture complexity value is within a certain range. Of course, the numerical mapping relationship between the quality parameter and the quantization parameter can be determined according to the actual situation, and no specific limitation is made here.
[0081] Step S13: Based on the first difference between the first quality parameter and the second quality parameter of the reference frame, determine whether to correct the first quantization parameter to obtain the target quantization parameter of the current frame.
[0082] Please see Figure 2 , Figure 2 This is a flowchart illustrating one embodiment of the process of obtaining the target quantization parameters of the current frame. Specifically, it may include the following steps:
[0083] Step S21: Determine whether the first difference is not less than the preset threshold; if not, proceed to step S22; otherwise, proceed to step S23.
[0084] In one implementation scenario, the first quality parameter of the current frame and the second quality parameter of the reference frame are first obtained. It should be noted that the first quality parameter represents the value of the quality parameter encoded based on the first quantization parameter of the current frame, and the second quality parameter represents the value of the quality parameter encoded based on the second quantization parameter of the reference frame. Based on this, the first difference between the first and second quality parameters is calculated, and then compared with a preset threshold to obtain the comparison result. The preset threshold can be set to 2, 3, 4, etc., and can be set according to actual conditions; no specific limitation is made here. Based on the comparison result, it is selected whether to revise the first quantization parameter, thereby obtaining the target quantization parameter of the current frame. It should be noted that the reference frame is the frame preceding the current frame in the video to be encoded.
[0085] Specifically, the second quality parameter of the reference frame encoding can be represented as PSNR. pre The first quality parameter of the current frame is represented as PSNR. curr If the first difference between the first quality parameter and the second quality parameter is lower than a preset threshold, it can be expressed as:
[0086] |PSNR curr- PSNR pre |<ε
[0087] Where ε is a preset threshold and ε>0, and || represents taking the absolute value.
[0088] Step S22: Use the first quantization parameter as the target quantization parameter.
[0089] In one implementation scenario, in response to the first difference threshold being lower than the preset error, that is, the first quantization parameter does not need to be revised, and the first quantization parameter can be directly used as the target quantization parameter.
[0090] Step S23: Multiply the preset threshold by the preset ratio to obtain the quality adjustment range, and determine the quality adjustment direction based on the relationship between the first quality parameter and the second quality parameter.
[0091] In an implementation scenario, in response to the first difference being not lower than a preset threshold, that is, the first quantization parameter needs to be optimized, the first quality parameter is adjusted based on the preset threshold to obtain a third quality parameter, and the second difference between the third quality parameter and the second quality parameter is less than the preset threshold. Specifically, the preset threshold can be multiplied by a preset ratio to obtain a quality adjustment range. The value range of the preset ratio is between 0 and 1. For example, the preset ratio can be 0.4, 0.5, 0.7, etc. In a specific implementation scenario, the preset ratio can be set to 0.5. Setting the preset ratio to 0.5 to adjust the first quantization parameter can make the video quality more stable. The preset ratio can be set according to the actual situation and is not specifically limited here. In addition, based on the magnitude relationship between the first quality parameter and the second quality parameter, the adjustment direction is determined. The preset ratio is determined based on the quality stability requirement between adjacent video frames. It should be noted that setting the preset ratio not greater than 1 can make the quality stability between adjacent video frames higher. The adjustment direction includes any one of the direction of increasing the first quality parameter and the direction of decreasing the first quality parameter. Specifically, when the first quality parameter is less than the second quality parameter, the adjustment direction is the direction of increasing the first quality parameter; when the first quality parameter is greater than the second quality parameter, the adjustment direction is the direction of decreasing the first quality parameter. Exemplarily, the range of the spatio-temporal domain texture complexity of the current frame and the reference frame is both 15 < textureST < 30, and the mapping relationship expression corresponding to the preset threshold ε = 2 is expressed as:
[0092] PSNR = 40 * exp(-0.02 * QP)
[0093] If the quantization parameters of the current frame and the reference frame are respectively set to QP curr = 27, QP pre = 22, then the calculation results of the first quality parameter of the current frame and the second quality parameter of the reference frame are respectively PSNR curr = 23.4, PSNR pre = 25.8. Then the first difference between the first quality parameter and the second quality parameter can be expressed as:
[0094] |PSNR curr -PSNR pre | = |23.4 - 25.8| = 2.4
[0095] Since the first difference between the first quality parameter and the second quality parameter is greater than the preset threshold, and the first quality parameter is less than the second quality parameter, it is determined that the adjustment direction is the direction of increasing the first quality parameter. Setting the preset ratio to 0.5, the quality adjustment range can be obtained by multiplying the preset ratio by the preset threshold, that is, the quality adjustment range is 1.
[0096] Step S24: Adjust the first quality parameter according to the quality adjustment direction and the quality adjustment amplitude to obtain a third quality parameter.
[0097] In an implementation scenario, if the adjustment direction is to increase the first quality parameter, then increase the quality adjustment amplitude based on the first quality parameter to obtain the third quality parameter; if the adjustment direction is to decrease the first quality parameter, then decrease the quality adjustment amplitude based on the first quality parameter to obtain the third quality parameter. Exemplarily, the quality adjustment amplitude is 1, the adjustment direction is to increase the first quality parameter, and the first quality parameter is 23.4. Then, increase 1 based on the first quality parameter to obtain the third quality parameter of 24.4. It should be noted that the second difference between the third quality parameter and the second quality parameter is lower than the preset threshold. Thus, after obtaining the third quality parameter, the second difference between the third quality parameter and the second quality parameter can be further obtained. In response to the second difference not being lower than the preset threshold, adjust the third quality parameter to a new third quality parameter, and obtain the difference based on the new third quality parameter and the second quality parameter, and iterate continuously until the difference between the new third quality parameter and the second quality parameter satisfies the preset threshold and then stop.
[0098] Step S25: Map the third quality parameter based on the numerical mapping relationship to obtain the target quantization parameter.
[0099] In an implementation scenario, obtain the corresponding numerical mapping relationship, and map the third quality parameter based on the numerical mapping relationship to obtain the target quantization parameter. Exemplarily, the ranges of the spatio-temporal domain texture complexities of the current frame and the reference frame are both 15 < textureST < 30, and the mapping relationship expression corresponding to the preset threshold ε = 2 is PSNR = 40 * exp(-0.02 * QP). The quantization parameters of the current frame and the reference frame are set to QP curr = 27, QP pre = 22, then the calculation results of the first quality parameter of the current frame and the second quality parameter of the reference frame are PSNR curr = 23.4, PSNR pre = 25.8, then the third quality parameter is obtained as 24.4, and mapping is performed based on the mapping relationship expression PSNR = 40 * exp(-0.02 * QP) to obtain QP as 25.
[0100] Step S14: Encode the current frame based on the target quantization parameter of the current frame.
[0101] In one implementation scenario, optimizing the first quantization parameter yields the target quantization parameter. Encoding the current frame using the target quantization parameter ensures video quality stability and minimizes visual abrupt changes. It should be noted that if the bitrate control parameter is an R-λ model, the quantization parameter can be either the quantization factor λ or QP. If the quantization parameter is the quantization factor λ, after obtaining the target quantization parameter, the quantization parameter QP must be calculated based on the mapping relationship expression between λ and QP.
[0102] It should be noted that the first quantization parameter, the second quantization parameter, and the third quantization parameter are all essentially quantization parameters. The difference lies in the fact that they represent the specific values of the quantization parameter under different conditions.
[0103] The above scheme analyzes the actual allocated bitrate based on the bitrate control model to obtain the first quantization parameter of the current frame in the video to be encoded; then, it maps the first quantization parameter based on the numerical mapping relationship to obtain the first quality parameter of the current frame, where the numerical mapping relationship represents the correspondence between the quantization parameter and the quality parameter; the first quality parameter represents the value of the quality parameter after encoding the current frame based on the first quantization parameter; and based on the first difference between the first quality parameter and the second quality parameter of the reference frame, it determines whether to correct the first quantization parameter to obtain the target quantization parameter of the current frame; the reference frame is the frame preceding the current frame in the video to be encoded; the second quality parameter represents the value of the quality parameter after encoding the reference frame based on the second quantization parameter; and finally, the current frame is encoded based on the target quantization parameter of the current frame. On the one hand, analysis based on the bitrate control model and the actual allocated bitrate is performed to obtain the first quantization parameter of the current frame in the video to be encoded, which helps to improve the accuracy of the video encoding parameters of the current frame in the video to be encoded. On the other hand, by constraining the values of the quality parameters of the two frames before and after, that is, by using the first difference between the encoding parameters of the two frames before and after, it is determined whether to correct the first quantization parameter. Thus, after the video to be encoded is encoded, the stability of video quality can be ensured and visual abrupt changes can be minimized.
[0104] Please see Figure 3 , Figure 3 This is a flowchart illustrating another embodiment of the video encoding method of this application.
[0105] Specifically, this may include the following steps:
[0106] Step S31: Analyze the actual allocated bitrate based on the bitrate control model to obtain the first quantization parameter of the current frame in the video to be encoded.
[0107] In one implementation scenario, the actual allocated bitrate can be obtained first. The actual allocated bitrate can be determined based on direct user input, or the target allocated bitrate and target quality level set by the user can be received first. Then, the target allocated bitrate is weighted based on the ratio between the target quality level and the highest quality level to obtain the actual allocated bitrate. For details, please refer to the aforementioned implementation of the actual allocated bitrate, which will not be repeated here.
[0108] In one implementation scenario, after determining the rate control model, the actual allocated bitrate is analyzed based on the determined rate control model to obtain the first quantization parameter of the current frame. The method for obtaining the first quantization parameter can be based on the aforementioned disclosed embodiments, and will not be repeated here.
[0109] Step S32: Obtain the numerical mapping relationship between quantization parameters and quality parameters.
[0110] In one implementation scenario, the target scene to which the video to be encoded belongs is first determined. Based on the target scene, a numerical mapping relationship between the quality parameters and the quantization parameters is selected. Alternatively, the numerical mapping relationship between the quantization parameters and the quality parameters can be determined based on the correlation between spatiotemporal texture complexity and the numerical mapping relationship. Step S33: Obtain the first quality parameter of the current frame and the second quality parameter of the reference frame.
[0111] In one implementation scenario, the method for obtaining the first quality parameter of the current frame and the second quality parameter of the reference frame can be referred to the method for obtaining the first quality parameter and the second quality parameter in the aforementioned public embodiments, and will not be repeated here.
[0112] Step S34: Obtain the first difference between the first mass parameter and the second mass parameter.
[0113] In one implementation scenario, after determining the first quality parameter and the second quality parameter, the absolute value of the difference between the first quality parameter and the second quality parameter is taken to obtain the first difference between the first quality parameter and the second quality parameter.
[0114] Step S35: Determine whether the first difference is not less than the preset threshold; if not, proceed to step S36; otherwise, proceed to step S37.
[0115] Step S36: Use the first quantization parameter as the target quantization parameter.
[0116] In one implementation scenario, if the first difference is lower than a preset threshold, the first quantization parameter can be used as the target quantization parameter. Furthermore, since the difference between the first quality parameter and the second quality parameter is lower than the preset threshold, stable video quality is ensured after video encoding.
[0117] Step S37: Adjust the first mass parameter to the third mass parameter.
[0118] In one implementation scenario, the adjustment method for changing the first quality parameter to the third quality parameter can refer to the adjustment method in the aforementioned disclosed embodiments, and will not be repeated here.
[0119] Step S38: Map the third quality parameter based on the numerical mapping relationship to obtain the target quantization parameter.
[0120] In one implementation scenario, after adjusting the first quality parameter to the third quality parameter, if the third difference between the third quality parameter and the second quality parameter is lower than a preset threshold, then the corresponding numerical mapping relationship can be selected, and mapping can be performed based on the selected numerical mapping relationship to obtain the target quantization parameter.
[0121] Step S39: Encode the current frame based on the target quantization parameters of the current frame.
[0122] In one implementation scenario, the current frame is encoded based on the determined target quantization parameters, which avoids the breathing effect in the subjective quality of the video caused by the large distance between the quantization parameters of the previous and next frames, thereby reducing visual abrupt changes.
[0123] The above scheme analyzes the actual allocated bitrate based on the bitrate control model to obtain the first quantization parameter of the current frame in the video to be encoded; then, it maps the first quantization parameter based on the numerical mapping relationship to obtain the first quality parameter of the current frame, where the numerical mapping relationship represents the correspondence between the quantization parameter and the quality parameter; the first quality parameter represents the value of the quality parameter after encoding the current frame based on the first quantization parameter; and based on the first difference between the first quality parameter and the second quality parameter of the reference frame, it determines whether to correct the first quantization parameter to obtain the target quantization parameter of the current frame; the reference frame is the frame preceding the current frame in the video to be encoded; the second quality parameter represents the value of the quality parameter after encoding the reference frame based on the second quantization parameter; and finally, the current frame is encoded based on the target quantization parameter of the current frame. On the one hand, analysis based on the bitrate control model and the actual allocated bitrate is performed to obtain the first quantization parameter of the current frame in the video to be encoded, which helps to improve the accuracy of the video encoding parameters of the current frame in the video to be encoded. On the other hand, by constraining the values of the quality parameters of the two frames before and after, that is, by using the first difference between the encoding parameters of the two frames before and after, it is determined whether to correct the first quantization parameter. Thus, after the video to be encoded is encoded, the stability of video quality can be ensured and visual abrupt changes can be minimized.
[0124] Those skilled in the art will understand that, in the above-described method of the specific implementation, the order in which each step is written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of each step should be determined by its function and possible internal logic.
[0125] Please see Figure 4 , Figure 4 This is a schematic diagram of the framework of an embodiment of the video encoding apparatus of this application. The video encoding apparatus 40 includes an analysis module 41, a mapping module 42, a determination module 43, and an encoding module 44. The analysis module 41 is used to analyze the actual allocated bitrate based on a bitrate control model to obtain a first quantization parameter of the current frame in the video to be encoded. The mapping module 42 is used to map the first quantization parameter based on a numerical mapping relationship to obtain a first quality parameter of the current frame. The numerical mapping relationship represents the correspondence between the quantization parameter and the quality parameter. The first quality parameter represents the value of the quality parameter after encoding the current frame based on the first quantization parameter. The determination module 43 is used to determine whether to correct the first quantization parameter based on a first difference between the first quality parameter and a second quality parameter of a reference frame to obtain a target quantization parameter of the current frame. The reference frame is the frame preceding the current frame in the video to be encoded. The second quality parameter represents the value of the quality parameter after encoding the reference frame based on the second quantization parameter. The encoding module 44 is used to encode the current frame based on the target quantization parameter of the current frame.
[0126] The above scheme, on the one hand, analyzes the bitrate control model and the actual allocated bitrate to obtain the first quantization parameter of the current frame in the video to be encoded, which helps to improve the accuracy of the video encoding parameters of the current frame in the video to be encoded. On the other hand, by constraining the values of the quality parameters of the two frames before and after, that is, by using the first difference between the encoding parameters of the two frames before and after, it determines whether to correct the first quantization parameter. Thus, after the video to be encoded is encoded, it can ensure the stability of video quality and minimize visual abrupt changes.
[0127] In some disclosed embodiments, the determining module 43 includes an adjustment submodule, which is used to adjust the first quantization parameter in response to the first difference being not less than a preset threshold to obtain a target quantization parameter; the determining module 43 also includes a determining submodule, which is used to take the first quantization parameter as the target quantization parameter in response to the first difference being less than the preset threshold.
[0128] Therefore, by constraining the values of the quality parameters between two consecutive frames, it can be ensured that the difference in the values of the encoding parameters between the two consecutive frames meets the preset conditions, thereby ensuring the stability of video quality after encoding.
[0129] In some disclosed embodiments, the adjustment submodule includes an adjustment unit, which is used to adjust the first quality parameter based on a preset threshold to obtain a third quality parameter; the second difference between the third quality parameter and the second quality parameter is less than the preset threshold; the adjustment submodule also includes a mapping unit, which is used to obtain a target quantization parameter based on the quantization parameter mapped by the third quality parameter in the numerical mapping relationship.
[0130] In some disclosed embodiments, the adjustment unit includes a determining subunit, which is used to multiply a preset threshold by a preset ratio to obtain a quality adjustment range, and to determine a quality adjustment direction based on the relationship between a first quality parameter and a second quality parameter; wherein the preset ratio is determined based on the quality stability requirements between adjacent video frames; the adjustment unit also includes an adjustment subunit, which is used to adjust the first quality parameter according to the quality adjustment direction and the quality adjustment range to obtain a third quality parameter.
[0131] Therefore, by further determining the adjustment direction, it is ensured that the difference in quality parameters between the two frames is within a certain range, and that the magnitude relationship after adjustment remains consistent with that before adjustment. This helps to ensure the stability of video quality after video encoding.
[0132] In some disclosed embodiments, the numerical mapping relationship is related to the spatiotemporal texture complexity, and several numerical intervals of the spatiotemporal texture complexity each correspond to different numerical mapping relationships; the video encoding device 40 includes a calculation module, which is used to obtain the complexity value of the current frame with respect to the spatiotemporal texture complexity; the video encoding device 40 also includes a selection module, which is used to select the numerical mapping relationship corresponding to the numerical interval where the complexity value is located, as the numerical mapping relationship applicable to the current frame.
[0133] Therefore, selecting the corresponding numerical mapping relationship based on the complexity value of the spatiotemporal texture complexity of the current frame helps to improve the accuracy of selecting the numerical mapping relationship.
[0134] In some disclosed embodiments, the calculation module includes an acquisition submodule, which is used to acquire a first complexity value of the current frame relative to the reference frame with respect to the temporal texture complexity, and to acquire a second complexity value of the current frame with respect to the spatial texture complexity; the calculation module also includes a processing submodule, which is used to perform weighted processing based on the first complexity value and the second complexity value to obtain the complexity value of the current frame with respect to the temporal and spatial texture complexity.
[0135] Therefore, by weighting the first complexity value and the second complexity value, it is helpful to improve the accuracy of the complexity value of the current frame with respect to the spatiotemporal texture complexity.
[0136] In some disclosed embodiments, the video encoding apparatus 40 includes a fitting module, which is used to fit sample videos under different scenarios to obtain the correspondence between quantization parameters and quality parameters under different scenarios; perform scene detection based on the video to be encoded to obtain the target scene to which the video to be encoded belongs; and select the correspondence between quantization parameters and quality parameters under the target scene as a numerical mapping relationship applicable to the video to be encoded.
[0137] Therefore, by fitting sample videos under different scenarios, the numerical mapping relationship between quality parameters and quantization parameters under different scenarios can be obtained, which helps to improve the accuracy of the numerical mapping relationship between quality parameters and quantization parameters.
[0138] In some disclosed embodiments, the video encoding apparatus 40 includes a receiving module for receiving a target allocated bitrate and a target quality level set by the user; the video encoding apparatus 40 also includes a weighting module for weighting the target allocated bitrate based on the ratio between the target quality level and the highest quality level to obtain the actual allocated bitrate.
[0139] Therefore, by weighting the target allocated bitrate, the error in confirming the actual allocated bitrate can be reduced, thereby improving the accuracy of the obtained quantization parameters.
[0140] In some disclosed embodiments, the quality parameters include at least one of PSNR and SSIM;
[0141] And / or, the rate control model is selected from a set of models, which includes at least one of the R-λ model, R-ρ model, and RQ model. The rate control model represents the correspondence between quantization parameters and bit rate, and the quantization parameters include QP and the quantization factor of the rate control model. When the R-λ model is selected as the rate control model, the quantization factor is λ. When the R-ρ model is selected as the rate control model, the quantization factor is ρ. When the RQ model is selected, the quantization factor is qscale.
[0142] In the several embodiments provided in this application, it should be understood that the disclosed methods and apparatus can be implemented in other ways. For example, the apparatus implementations described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0143] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment, depending on actual needs.
[0144] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0145] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods of the various embodiments of this application.
[0146] Please see Figure 5 , Figure 5 This is a schematic diagram of the framework of an embodiment of the encoding device of this application. The encoding device 50 includes a memory 51 and a processor 52 coupled to each other. The memory 51 stores program instructions, and the processor 52 is used to execute the program instructions to implement the steps in any of the above-described video encoding method embodiments. Specifically, the encoding device 50 may include, but is not limited to, servers, desktop computers, laptops, etc., and is not limited thereto.
[0147] Specifically, processor 52 controls itself and memory 51 to implement the steps in any of the video encoding method embodiments described above. Processor 52 can also be referred to as a CPU (Central Processing Unit). Processor 52 may be an integrated circuit chip with signal processing capabilities. Processor 52 can also be a general-purpose processor, digital signal processor (DSP), application-specific integrated circuit (ASIC), field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. A general-purpose processor can be a microprocessor or any conventional processor. Furthermore, processor 52 can be implemented by multiple integrated circuit chips.
[0148] The above scheme, on the one hand, analyzes the bitrate control model and the actual allocated bitrate to obtain the first quantization parameter of the current frame in the video to be encoded, which helps to improve the accuracy of the video encoding parameters of the current frame in the video to be encoded. On the other hand, by constraining the values of the quality parameters of the two frames before and after, that is, by using the first difference between the encoding parameters of the two frames before and after, it determines whether to correct the first quantization parameter. Thus, after the video to be encoded is encoded, it can ensure the stability of video quality and minimize visual abrupt changes.
[0149] Please see Figure 6 , Figure 6 This is a schematic diagram of a framework of an embodiment of the computer-readable storage medium of this application. The computer-readable storage medium 60 stores program instructions 61 that can be executed by a processor. The program instructions 61 are used to implement the steps in any of the above-described video encoding method embodiments.
[0150] The above scheme, on the one hand, analyzes the bitrate control model and the actual allocated bitrate to obtain the first quantization parameter of the current frame in the video to be encoded, which helps to improve the accuracy of the video encoding parameters of the current frame in the video to be encoded. On the other hand, by constraining the values of the quality parameters of the two frames before and after, that is, by using the first difference between the encoding parameters of the two frames before and after, it determines whether to correct the first quantization parameter. Thus, after the video to be encoded is encoded, it can ensure the stability of video quality and minimize visual abrupt changes.
[0151] The aforementioned storage media include: USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks or optical disks, and other media that can store program code.
[0152] If the technical solution of this application complies with the relevant laws and regulations regarding the collection, dissemination, and use of data.
Claims
1. A video encoding method, characterized in that, include: Based on the bitrate control model, the actual allocated bitrate is analyzed to obtain the first quantization parameter of the current frame in the video to be encoded; The first quantization parameter is mapped based on the numerical mapping relationship to obtain the first quality parameter of the current frame; wherein, the numerical mapping relationship represents the correspondence between the quantization parameter and the quality parameter; the first quality parameter represents the value of the quality parameter after encoding the current frame based on the first quantization parameter; Based on the first difference between the first quality parameter and the second quality parameter of the reference frame, it is determined whether to correct the first quantization parameter to obtain the target quantization parameter of the current frame; wherein, the reference frame is the frame preceding the current frame in the video to be encoded; the second quality parameter represents the value of the quality parameter after encoding the reference frame based on the second quantization parameter, and the quality parameter includes at least one of PSNR and SSIM; The current frame is encoded based on the target quantization parameters of the current frame.
2. The method according to claim 1, characterized in that, The step of determining whether to correct the first quantization parameter based on the first difference between the first quality parameter and the second quality parameter of the reference frame, to obtain the target quantization parameter of the current frame, includes: In response to the first difference being not less than a preset threshold, the first quantization parameter is adjusted to obtain the target quantization parameter; In response to the first difference being less than the preset threshold, the first quantization parameter is used as the target quantization parameter.
3. The method according to claim 2, characterized in that, The step of adjusting the first quantization parameter to obtain the target quantization parameter includes: The first quality parameter is adjusted based on the preset threshold to obtain the third quality parameter; wherein, the second difference between the third quality parameter and the second quality parameter is less than the preset threshold; The target quantization parameter is obtained based on the quantization parameter mapped by the third quality parameter in the numerical mapping relationship.
4. The method according to claim 3, characterized in that, The step of adjusting the first quality parameter based on the preset threshold to obtain the third quality parameter includes: The preset threshold is multiplied by a preset ratio to obtain the quality adjustment range, and the quality adjustment direction is determined based on the relationship between the first quality parameter and the second quality parameter; wherein, the preset ratio is determined based on the quality stability requirements between adjacent video frames; The first quality parameter is adjusted according to the quality adjustment direction and the quality adjustment range to obtain the third quality parameter.
5. The method according to claim 1, characterized in that, The numerical mapping relationship is related to the spatiotemporal texture complexity, and each of the several numerical ranges of the spatiotemporal texture complexity corresponds to a different numerical mapping relationship. Before mapping the first quantization parameter based on the numerical mapping relationship to obtain the first quality parameter of the current frame, the method further includes: Obtain the complexity value of the current frame with respect to the spatiotemporal texture complexity; Select the numerical mapping relationship corresponding to the numerical range in which the complexity value is located, and use it as the numerical mapping relationship applicable to the current frame.
6. The method according to claim 5, characterized in that, The step of obtaining the complexity value of the current frame with respect to the spatiotemporal domain texture complexity includes: Obtain the first complexity value of the current frame relative to the reference frame with respect to the temporal texture complexity, and obtain the second complexity value of the current frame with respect to the spatial texture complexity; The complexity value of the current frame with respect to the spatiotemporal texture complexity is obtained by weighting the first complexity value and the second complexity value.
7. The method according to claim 1, characterized in that, Before mapping the first quantization parameter based on the numerical mapping relationship to obtain the first quality parameter of the current frame, the method further includes: The quantization parameter and the quality parameter are fitted to sample videos from different scenarios to obtain the correspondence between the quantization parameter and the quality parameter in different scenarios. Scene detection is performed on the video to be encoded to obtain the target scene to which the video to be encoded belongs; The correspondence between the quantization parameters and the quality parameters in the target scene is selected as the numerical mapping relationship applicable to the video to be encoded.
8. The method according to claim 1, characterized in that, Before analyzing the actual allocated bitrate based on the bitrate control model to obtain the first quantization parameter of the current frame in the video to be encoded, the method further includes: Receive the target allocated bitrate and target quality level set by the user; The target allocated bitrate is weighted based on the ratio between the target quality level and the highest quality level to obtain the actual allocated bitrate.
9. The method according to any one of claims 1 to 8, characterized in that, The rate control model is selected from a set of models, which includes at least one of the R-λ model, R-ρ model, and RQ model. The rate control model represents the correspondence between quantization parameters and bitrate, and the quantization parameters include either QP or the quantization factor of the rate control model. When the R-λ model is selected as the rate control model, the quantization factor is λ; when the R-ρ model is selected as the rate control model, the quantization factor is ρ; and when the RQ model is selected, the quantization factor is qscale.
10. A video encoding device, characterized in that, include: The analysis module is used to analyze the actual allocated bitrate based on the bitrate control model to obtain the first quantization parameter of the current frame in the video to be encoded; A mapping module is used to map the first quantization parameter based on a numerical mapping relationship to obtain a first quality parameter of the current frame; wherein, the numerical mapping relationship represents the correspondence between the quantization parameter and the quality parameter; and the first quality parameter represents the value of the quality parameter encoded based on the first quantization parameter for the current frame. The determining module is configured to determine whether to correct the first quantization parameter based on the first difference between the first quality parameter and the second quality parameter of the reference frame, so as to obtain the target quantization parameter of the current frame; wherein, the reference frame is the frame preceding the current frame in the video to be encoded; the second quality parameter represents the value of the quality parameter after encoding the reference frame based on the second quantization parameter, and the quality parameter includes at least one of PSNR and SSIM; The encoding module is used to encode the current frame based on the target quantization parameters of the current frame.
11. An encoding device, characterized in that, The method includes a memory and a processor coupled to each other, the memory storing program instructions, and the processor executing the program instructions to implement the video encoding method according to any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that, The device stores program instructions that can be executed by a processor, the program instructions being used to implement the video encoding method according to any one of claims 1 to 9.