Video compression method, device, equipment and medium
By acquiring and adjusting the quantization parameter offset value of the video frame, determining the quantization parameter value with the constant code rate factor, and compressing the target video frame, the problem of imbalance in the video quality and compression efficiency in the prior art is solved, and a better video compression effect is achieved.
Patent Information
- Application Number
- CN202411456954.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-16
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2044-10-16
AI Technical Summary
The prior art is difficult to achieve a balance between video quality and compression efficiency in video compression, resulting in problems such as excessive video quality but low compression efficiency or excessive compression efficiency but low video quality.
By obtaining the video parameters of the target video frame, including the reference complexity of the reference frame, the complexity of the target video frame, the impact coefficient and the complexity adjustment coefficient, the quantization parameter offset value is determined, and the preset boundary value is adjusted. Finally, the quantization parameter value is determined based on the adjusted quantization parameter offset value and the constant code rate factor, and the target video frame is compressed.
The balance between video quality and compression efficiency is achieved, and the situation where video quality is too high but compression efficiency is too low or compression efficiency is too high but video quality is too low, which improves the performance of video compression method.
Smart Images

Figure CN118972584B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer data processing technology, and in particular to a video compression method, device, equipment and medium. Background Art
[0002] With the development of industries such as short videos and live videos, the technologies used to process videos are also diverse and constantly updated. Among them, video encoding is one of the core technologies for live video and short video services, and is a necessary technology for processing short videos and live videos. Video encoding technology is directly related to the user's video viewing experience and bandwidth costs.
[0003] Therefore, how to provide a video compression method with excellent performance is a technical problem that needs to be solved urgently. Summary of the invention
[0004] The embodiments of this specification provide a video compression method, apparatus, device and medium to provide a video compression method with excellent performance.
[0005] In order to provide the above-mentioned video compression method with excellent performance, the embodiment of this specification provides a video compression method, including:
[0006] Acquire video parameters of a target video frame; the video parameters at least include a baseline complexity of a reference frame, a complexity of the target video frame, an influence coefficient, and a complexity adjustment coefficient;
[0007] Determining a quantization parameter offset value of the target video frame according to the video parameter;
[0008] If the quantization parameter offset value is less than a first preset boundary value, the quantization parameter offset value is adjusted to the value of the first preset boundary value; the first preset boundary value is used to represent the lower limit value of the quantization parameter offset value;
[0009] If the quantization parameter offset value is greater than a second preset boundary value, the quantization parameter offset value is adjusted to the value of the second preset boundary value; the second preset boundary value is used to represent the upper limit value of the quantization parameter offset value; the second preset boundary value is greater than the first preset boundary value;
[0010] Determining a quantization parameter value of the target video frame based on the adjusted quantization parameter offset value and the constant bit rate factor;
[0011] The target video frame is compressed according to the quantization parameter value.
[0012] The embodiment of this specification also provides a video compression device, including:
[0013] A video parameter acquisition module, used to acquire video parameters of a target video frame; the video parameters at least include a baseline complexity of a reference frame, a complexity of the target video frame, an influence coefficient, and a complexity adjustment coefficient;
[0014] A quantization parameter offset value determination module, used to determine the quantization parameter offset value of the target video frame according to the video parameter;
[0015] A first adjustment module, configured to adjust the quantization parameter offset value to a value of the first preset boundary value if the quantization parameter offset value is less than a first preset boundary value; the first preset boundary value is used to indicate a lower limit value of the quantization parameter offset value;
[0016] a second adjustment module, configured to adjust the quantization parameter offset value to a value of the second preset boundary value if the quantization parameter offset value is greater than a second preset boundary value; the second preset boundary value is used to represent an upper limit value of the quantization parameter offset value; the second preset boundary value is greater than the first preset boundary value;
[0017] A quantization parameter value determination module, configured to determine a quantization parameter value of the target video frame based on the adjusted quantization parameter offset value and a constant bit rate factor;
[0018] A compression module is used to compress the target video frame according to the quantization parameter value.
[0019] The embodiment of this specification also provides a video compression device, including:
[0020] at least one processor; and,
[0021] a memory communicatively connected to the at least one processor; wherein,
[0022] The memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to:
[0023] Acquire video parameters of a target video frame; the video parameters at least include a baseline complexity of a reference frame, a complexity of the target video frame, an influence coefficient, and a complexity adjustment coefficient;
[0024] Determining a quantization parameter offset value of the target video frame according to the video parameter;
[0025] If the quantization parameter offset value is less than a first preset boundary value, the quantization parameter offset value is adjusted to the value of the first preset boundary value; the first preset boundary value is used to represent the lower limit value of the quantization parameter offset value;
[0026] If the quantization parameter offset value is greater than a second preset boundary value, the quantization parameter offset value is adjusted to the value of the second preset boundary value; the second preset boundary value is used to represent the upper limit value of the quantization parameter offset value; the second preset boundary value is greater than the first preset boundary value;
[0027] Determining a quantization parameter value of the target video frame based on the adjusted quantization parameter offset value and the constant bit rate factor;
[0028] The target video frame is compressed according to the quantization parameter value.
[0029] The embodiments of the present specification also provide a computer-readable storage medium on which a computer program or instruction is stored. The computer program or instruction can be executed by a processor to implement a video compression method.
[0030] At least one embodiment in the present specification can achieve the following beneficial effects: by obtaining the video parameters of the target video frame, the quantization parameter offset value of the target video frame is determined, if the quantization parameter offset value is less than the first preset boundary value, the quantization parameter offset value is adjusted to the first preset boundary value; if the quantization parameter offset value is greater than the second preset boundary value, the quantization parameter offset value is adjusted to the second preset boundary value; based on the adjusted quantization parameter offset value and the constant bit rate factor, the quantization parameter value of the target video frame is determined to compress the target video frame. The present application limits the quantization parameter offset value within a certain value range, so that after the video frame is compressed using the quantization parameter value obtained based on the quantization parameter offset value and the constant bit rate factor, a balance can be achieved between video quality and compression efficiency, avoiding the situation where the video quality is too high but the compression efficiency is too low or the compression efficiency is too high but the video quality is too low, thereby improving the performance of the video compression method. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the technical solutions in the embodiments of this specification or the prior art, the following briefly introduces the drawings required for use in the embodiments or the prior art description. Obviously, the drawings described below are only some embodiments recorded in this application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0032] Figure 1 This is a schematic diagram of an application scenario of a video compression method provided by an embodiment of this specification;
[0033] Figure 2 It is a flowchart of a video compression method provided by an embodiment of this specification;
[0034] Figure 3is a structural schematic diagram of a video compression device provided in an embodiment of this specification;
[0035] Figure 4 It is a structural diagram of a video compression device provided in an embodiment of this specification. DETAILED DESCRIPTION
[0036] In order to make the purpose, technical solutions and advantages of one or more embodiments of this specification clearer, the technical solutions of one or more embodiments of this specification will be clearly and completely described below in combination with the specific embodiments of this specification and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of one or more embodiments of this specification.
[0037] In order to facilitate understanding of the technical solutions of one or more embodiments of this specification, some terms are explained:
[0038] Quantization Parameter (QP): The QP value can indicate the compression of image spatial details. The smaller the QP value, the more image spatial details will be retained and the higher the image quality will be. The larger the QP value, the more image spatial details will be lost and the lower the clarity of the video. The QP value is negatively correlated with the bit rate, and the negative correlation becomes greater with the increase of video complexity.
[0039] Constant Rate Factor (CRF) coding control technology: CRF coding control technology is a method of controlling the bit rate in video encoding through a preset constant rate factor (CRF) value, which can also be called a CRF coding control algorithm. The constant rate factor is a constant value set by the user based on the required video quality when determining the quantization parameter value based on the CRF coding control technology. The value of the constant rate factor can be between 0 and 51. The smaller the value of the constant rate factor, the better the video quality processed by the constant rate factor based on this value, and the larger the video bit rate; the larger the value of the constant rate factor, the worse the video quality processed by the constant rate factor based on this value, and the smaller the video bit rate. The quality of the video can be controlled by adjusting the value of the constant rate factor.
[0040] BD-Rate (Bjøntegaard-Delta rate): BD-Rate can be one of the main parameters used to evaluate the performance of video encoding algorithms. It indicates the changes in the bit rate (rate) and quality (PSNR) after encoding the video using the improved algorithm compared to the bit rate (rate) and quality (PSNR) after encoding the video using the algorithm before the improvement. If the BD-Rate is a negative value, it means that the improved algorithm saves bit rate while maintaining the same video quality compared to the algorithm before the improvement. The larger the absolute value of the negative value of the BD-Rate value, the greater the bit rate saved; if the BD-Rate value is a positive value, it means that the improved algorithm may require a higher bit rate to maintain the same video quality compared to the algorithm before the improvement.
[0041] Group Of Pictures (GOP): A group of pictures can include multiple frames, such as I frames, P frames and B frames. These frames are arranged in a certain order to obtain a video sequence structure, in which key frames can be used as reference points.
[0042] In the prior art, the CRF coding algorithm or the CQP coding algorithm can be used to process each video frame in the video. Among them, the CQP (Constant Quantization Parameter, CQP) coding algorithm compresses the video frames based on a fixed quantization parameter value. Compared with the CRF coding algorithm, the video quality stability obtained by compression based on the CQP coding algorithm is poor. In practical applications, in order to maintain the picture quality of short videos and live videos, the CRF coding algorithm is often used to adjust the quality and bit rate of video encoding. However, the CRF coding algorithm considers more the effects at the user's visual perception level. In the process of adjusting the quantization parameter value, the adjusted quantization parameter value may be too large or too small, resulting in poor BD-Rate performance of the CRF coding algorithm.
[0043] The technical solutions provided by the embodiments of this specification are described in detail below in conjunction with the accompanying drawings.
[0044] Figure 1 The present invention is a schematic diagram of an application scenario of a video compression method in an embodiment of the present specification.
[0045] like Figure 1 As shown, the encoder 2 can obtain the original video file 1, and the encoder 2 can also process the original video file 1 using the CRF coding technology to obtain a compressed video file 3. The compressed video file 3 is smaller in size than the original video file 1 and has better video quality.
[0046] Figure 2A schematic flow chart of a video compression method provided in an embodiment of the present specification. From a program perspective, the execution subject of the process may be a program or application client mounted on an application server. From a hardware perspective, the execution subject of the process may be a device or server with video encoding. An encoder for encoding the video is provided in the server. The encoder may be a hardware encoder or a software encoder.
[0047] like Figure 2 As shown, the method may include the following steps.
[0048] Step 202: Obtain video parameters of the target video frame.
[0049] The video parameters at least include a base complexity of a reference frame, a complexity of the target video frame, an influence coefficient, and a complexity adjustment coefficient.
[0050] In the embodiments of the present specification, the frame type of the target video frame may be any one of a key frame (I frame, referred to as I frame), a difference frame (P frame, referred to as P frame), or a bidirectional difference frame (B frame, referred to as B frame).
[0051] The reference frame is in the same video sequence as the target video frame. The reference frame can be the target video frame or any frame in the video sequence other than the target video frame. The height and width of each frame in the same video sequence can be the same. The benchmark complexity can be calculated based on the height and width of the reference frame in the video sequence.
[0052] The complexity of the target video frame can represent the complexity of the target video frame itself, which can be specifically determined according to the content, type, etc. of the target video frame. The influence coefficient is used to represent the intensity of the adjustment of the quantization parameter value. The complexity adjustment coefficient is a coefficient used to adjust the reference complexity. The video parameters can also include parameters such as video resolution, video scene information, and video clarity, which are not listed here one by one.
[0053] Step 204: Determine a quantization parameter offset value of the target video frame according to the video parameter.
[0054] The quantization parameter offset value in the embodiment of this specification may represent the size of the target video frame that needs to be offset based on the constant bit rate factor when the quantization parameter value of the target video frame is calculated based on the CRF coding algorithm. The quantization parameter offset value may be determined based on the size of the complexity of the target video frame relative to the reference complexity.
[0055] Step 206: If the quantization parameter offset value is less than a first preset boundary value, the quantization parameter offset value is adjusted to a value of the first preset boundary value.
[0056] The first preset boundary value is used to represent the lower limit value of the quantization parameter offset value.
[0057] The first preset boundary value in the embodiments of this specification may represent the first critical point of the balance between video quality and bit rate. If it is lower than the critical point, it is easy to cause an imbalance between the quality of the encoded video and the bit rate, making the bit rate too large and increasing the video processing cost. The first preset boundary value may be obtained by analyzing historical data based on expert experience or a network model.
[0058] Step 208: If the quantization parameter offset value is greater than a second preset boundary value, the quantization parameter offset value is adjusted to the value of the second preset boundary value.
[0059] Among them, the second preset boundary value is used to represent the upper limit value of the quantization parameter offset value; the second preset boundary value is greater than the first preset boundary value.
[0060] In the embodiment of the present specification, the second preset boundary value can be determined based on the scene type corresponding to the target video frame, and the second preset boundary values corresponding to different scene types can be different. The second preset boundary value can also be obtained by analyzing historical data through expert experience or network model. The second preset boundary value can represent the maximum value of the quantization parameter offset value, that is, the value of the quantization parameter offset value is less than or equal to the second preset boundary value.
[0061] Step 210: Determine the quantization parameter value of the target video frame based on the adjusted quantization parameter offset value and the constant bit rate factor.
[0062] The constant bit rate factor in the embodiments of this specification may represent a value input by a user into the encoder based on the required video quality, or may be a default value of the encoder or a value determined by the encoder based on the content of the video to which the target video frame belongs. The quantization parameter value may represent the compression of the image spatial details, and may be obtained by calculating the sum of the quantization parameter offset value and the constant bit rate factor value.
[0063] Step 212: compress the target video frame according to the quantization parameter value.
[0064] In the embodiments of this specification, an encoder can be used to compress the image space details of the target video frame based on the quantization parameter value, thereby reducing the size of the video file, improving the video quality, and reducing the bit rate required for transmitting the video. The encoder can be an x264 encoder or an x265 encoder, or other types of encoders, which are not specifically limited here.
[0065] It should be understood that the order of some steps in the methods described in one or more embodiments of this specification can be interchanged according to actual needs, or some steps can be omitted or deleted.
[0066] Figure 2 According to the method, a quantization parameter offset value determined by a video parameter of a target video frame can adjust a quantization parameter offset value lower than a first preset boundary value to the first preset boundary value, and adjust a quantization parameter offset value higher than a second preset boundary value to the second preset boundary value, so that a quantization parameter value calculated based on the quantization parameter offset value and a constant bit rate factor can be within a certain range, avoiding a quantization parameter value that is too large or too small, so as to compress the target video frame based on a quantization parameter value within a certain range, thereby ensuring a balance between video quality and compression efficiency, avoiding a situation where the video quality is too high but the compression efficiency is too low or the compression efficiency is too high but the video quality is too low, and improving the performance of the video compression method.
[0067] In practical applications, the video compression method provided in the embodiments of this specification can be applied to the cloud transcoding process.
[0068] based on Figure 2 The method, the embodiments of this specification also provide some specific implementation methods of the method, which are described below.
[0069] Optionally, the determining of the quantization parameter offset value of the target video frame according to the video parameter in the embodiments of this specification may specifically include:
[0070] Determining an adjusted baseline complexity according to the baseline complexity and the complexity adjustment coefficient;
[0071] Determining a relative complexity of the target video frame relative to the reference frame according to a ratio of the complexity of the target video frame to the adjusted reference complexity;
[0072] Determining a weight value according to the influence coefficient and a first preset value; the weight value is used to indicate the intensity of adjusting the relative complexity;
[0073] The product of the weight value and the relative complexity is rounded to obtain the quantization parameter offset value.
[0074] The values of the complexity adjustment coefficients corresponding to different types of video scenes in the embodiments of this specification may be different. The complexity adjustment coefficient can be determined according to the degree of motion represented by the video scene. For example, the scene may include an outdoor fixed camera scene and an outdoor mobile camera scene, wherein the video picture in the outdoor fixed camera scene has a smaller degree of motion than the video picture in the outdoor mobile camera scene, and since the human eye is more sensitive to videos with a smaller degree of motion, the complexity adjustment coefficient of the outdoor fixed camera scene can be set to a value greater than the complexity coefficient of the outdoor mobile camera scene. The adjusted baseline complexity corresponding to the outdoor fixed camera scene is greater than the adjusted baseline complexity corresponding to the outdoor mobile camera scene. For scenes with a large degree of motion of the video picture, the baseline complexity can be reduced by the complexity adjustment coefficient, and the calculation result of the quantization parameter offset value can be increased, so that when compressing the video of the scene with a large degree of motion, less image space details can be retained, so as to reduce the bit rate while ensuring the image quality seen by the user based on human eye vision.
[0075] In practical applications, users have different sensitivities to video frames of different frame types, and the image space details contained in video frames of different frame types are also different. The complexity adjustment coefficients of different types of video frames can also be set to different values. For example, the frame types can include key frames and difference frames, where the key frames contain more image details than the difference frames, and the human eye is more sensitive to key frames than to difference frames. The complexity adjustment coefficient of the key frame can be set to a value greater than the complexity coefficient of the difference frame. The adjusted baseline complexity corresponding to the key frame is greater than the adjusted baseline complexity corresponding to the difference frame, so that the quantization parameter offset value of the key frame obtained after calculation is less than the quantization parameter offset value of the difference frame, so as to ensure that the image quality of the key frame image and the difference frame image seen by the user based on human eye vision is basically the same.
[0076] In the embodiments of this specification, the relative complexity can be obtained by processing the complexity of the target video frame and the adjusted reference complexity through a logarithmic algorithm. The relative complexity can indicate the degree of deviation of the complexity of the target video frame relative to the reference complexity, and specifically can indicate whether the complexity of the target video frame is higher or lower than the reference complexity. The first preset value can be set to 6, or a value such as 5, 7, etc., which can be set based on the type of encoder and actual needs, and is not specifically limited here.
[0077] In the embodiment of this specification, the quantization parameter offset value can be calculated according to the first formula (1) shown below:
[0078] (1)
[0079] in, Indicates the quantization parameter offset value; the round function indicates the rounding function of the rounding method, and other rounding functions can also be used for calculation, such as rounding up, rounding down, etc.; q c Indicates the influence coefficient, which can be determined by whether the Coding Unit Tree (CU Tree) is used in the video processing process. If the macroblock tree is used, the value can be 1, and if the macroblock tree is not used, the value can be 0.6. As for whether the macroblock tree needs to be used for video processing, the user can choose based on the video scene. It should be noted that the use of the macroblock tree will increase the delay; Cplx cur Indicates the complexity of the target video frame; Cplx base Indicates the baseline complexity of the reference frame; Fact represents the complexity adjustment coefficient. The complexity adjustment coefficient of the key frame I frame can be recorded as Fact I , the complexity adjustment coefficient of the difference frame P frame can be recorded as Fact P , different identifiers can be set to distinguish the complexity adjustment coefficient values of different frame types, so as to avoid using the complexity adjustment coefficient corresponding to the P frame video frame for the I frame video frame or using the complexity adjustment coefficient corresponding to the I frame video frame for the P frame video frame when processing the video, so as to avoid confusion in the use of the complexity adjustment coefficient, thereby reducing the error rate in the process of processing the video.
[0080] In the embodiments of this specification, when determining the quantization parameter offset value, the influence of the baseline complexity on video frames of different frame types is taken into consideration. The baseline complexity can be adjusted by the complexity adjustment coefficient to improve the reference value of the baseline complexity to achieve better video quality and compression efficiency.
[0081] If the quantization parameter offset value is within the preset range, it does not need to be adjusted and can be used directly, which can also make the compression result of the target video frame meet the user's needs. Optionally, the method described in the embodiment of this specification may also include:
[0082] If the quantization parameter offset value is greater than the first preset boundary value and less than the second preset boundary value, the quantization parameter value of the target video frame is determined according to the quantization parameter offset value and a constant bit rate factor.
[0083] The final quantization parameter offset value in the embodiment of this specification can be calculated according to the second formula (2) shown below:
[0084] (2)
[0085] Wherein, a represents the first preset boundary value; b represents the second preset boundary value; QP' represents the quantization parameter offset value calculated by the above formula (1); the clip function is used to limit the value interval of the quantization parameter offset value to [a, b], so that the value of the quantization parameter offset value can fall into a better value interval, so that the quantization parameter value can be calculated based on the quantization parameter offset value, and the video frame is compressed according to the quantization parameter value to improve the compression efficiency, thereby optimizing the CRF coding algorithm.
[0086] Considering that if a quantization parameter offset value less than zero is used to process the video frame to be compressed, the improvement of the image quality of the video frame is small, the bit rate will increase, and the bandwidth cost is relatively high. In order to reduce the bandwidth cost, in the embodiment of this specification, the first preset boundary value can be set to a value greater than or equal to zero, such as setting the value of a in the above formula (2) to zero, so that the quantization parameter offset value less than zero can be adjusted to zero.
[0087] In practical applications, if the quantization parameter offset value greater than the second preset boundary value is not adjusted, the target video frame is processed using the unadjusted quantization parameter offset value. Although the bit rate of the target video frame is low, the image quality of the target video frame is relatively blurred and cannot meet the quality requirements of the user for watching the video. It is necessary to adjust the quantization parameter offset value exceeding the b value by using the above formula (2) so that the quantization parameter value can be within a certain range, thereby improving the compression efficiency in the video processing process.
[0088] As an implementation method, in order to improve the accuracy of quantization parameter value calculation and make video spatial detail compression more accurate, when compressing video frames of different frame types, the parameters used to calculate the quantization parameter value may also be different. Optionally, for the difference frame, the quantization parameter value of the target video frame is determined based on the adjusted quantization parameter offset value and the constant bit rate factor in the embodiment of this specification, which may specifically include:
[0089] If the target video frame is a difference frame, obtaining a first quantization parameter difference value; the first quantization parameter difference value is a difference between a first quantization parameter value of the difference frame and a second quantization parameter value of a key frame belonging to the same picture group as the difference frame;
[0090] The quantization parameter value of the target video frame is determined according to the first quantization parameter difference, the adjusted quantization parameter offset value, and a constant bit rate factor.
[0091] As an implementation, a GOP may include a key frame, zero or more P frames and zero or more B frames. If a GOP includes one or more P frames, when compressing the P frames, the I frames may be referred to for compression.
[0092] The quantization parameter value of the difference frame in the embodiment of this specification can be calculated according to the third formula (3) shown below:
[0093] (3)
[0094] in, Indicates the quantization parameter value of the difference frame; crf indicates the constant bit rate factor; dqp p represents the first quantization parameter difference; C P Indicates that when the target video frame is a difference frame, the corresponding second preset boundary value; Fact P It can represent the corresponding complexity adjustment coefficient when the target video frame is a difference frame; the physical meaning of other strings in formula (3) is the same as the physical meaning of the same string in the previous formula.
[0095] It is worth noting that dqp p , C P And Fact P The parameter values can be different or the same in different scenarios. p , C P And Fact P These three parameters ensure that the quality of compressed frame images in different scenes can meet the user's visual needs.
[0096] In the embodiment of this specification, if the target video frame is a key frame, the sum of the constant bit rate factor and the adjusted quantization parameter offset value can be directly calculated to obtain the corresponding quantization parameter value. The quantization parameter value of the key frame can be specifically calculated according to the fourth formula (4) shown below:
[0097] (4)
[0098] in, Indicates the quantization parameter value of the key frame; C I Indicates the second preset boundary value corresponding to the target video frame as a key frame; Fact I Indicates the corresponding complexity adjustment coefficient when the target video frame is a key frame; the physical meaning of other strings in formula (4) is the same as the physical meaning of the same string in the previous formula. In different video scenes, C I And Fact I The values of the parameters can be different or the same.
[0099] As an implementation manner, optionally, for a bidirectional difference frame, determining the quantization parameter value of the target video frame based on the adjusted quantization parameter offset value and the constant bit rate factor in the embodiments of this specification may specifically include:
[0100] If the target video frame is a bidirectional difference frame, a first quantization parameter difference value and a second quantization parameter difference value are obtained; the first quantization parameter difference value is a difference between a first quantization parameter value of the difference frame and a second quantization parameter value of the key frame; the second quantization parameter difference value is a difference between a third quantization parameter value of the bidirectional difference frame and the first quantization parameter value of the difference frame; the difference frame, the key frame and the bidirectional difference frame belong to the same picture group; the difference frame is a difference frame located after the bidirectional difference frame in the picture group;
[0101] The quantization parameter information of the target video frame is determined according to the first quantization parameter difference, the second quantization parameter difference, the adjusted quantization parameter value, and a constant bit rate factor.
[0102] In actual applications, when compressing a B frame, you can refer to the I frame in the same image group and the first adjacent P frame that is behind the B frame and closest to the B frame; if the P frame in other video frames before the B frame is closer to the B frame than the I frame, you can also refer to the second adjacent P frame that is closest to the B frame before the B frame and the first adjacent P frame that is closest to the B frame after the B frame for compression.
[0103] In the embodiments of the present specification, in addition to determining the quantization parameter value of the B frame based on the above method, the quantization parameter value of the first adjacent P frame after the B frame can also be directly obtained, and the second quantization parameter difference value is added to the quantization parameter value of the P frame to obtain the quantization parameter value of the B frame. The quantization parameter value of the B frame can be calculated according to the fifth formula (5) shown below:
[0104] (5)
[0105] in, Indicates the quantization parameter value of the B frame; It can represent the quantization parameter value of the first adjacent P frame after the B frame, which can be calculated based on the above formula (3); dqp B A second quantization parameter difference may be represented.
[0106] In practical applications, if a B frame is compressed with reference to two P frames, It may also represent the quantization parameter value of the P frame that is located before the B frame and closest to it, or it may represent the average value of the quantization parameter values of the two P frames referenced by the B frame.
[0107] The parameter value can be quickly obtained according to the corresponding relationship, thereby speeding up the video processing and improving the efficiency. Optionally, the acquisition of the second preset boundary value in the embodiment of this specification may specifically include:
[0108] Determining scene information of the target video frame;
[0109] The second preset boundary value is acquired according to the scene information and a pre-established corresponding relationship; the corresponding relationship is used to represent the relationship between the scene information and the second preset boundary value.
[0110] In the embodiments of this specification, the scene information may be description information used to describe the scene of the video to which the target video frame belongs; or it may be identification information used to identify the scene of the video to which the target video frame belongs. The scene of the video to which the target video frame belongs may include at least one of a static live streaming scene, an outdoor fixed camera scene, an outdoor mobile camera scene, a dynamic live streaming scene, a short video scene, a computer-generated image scene, and the like. If the scene information is description information, the feature information of the video input to the encoder may be identified according to an existing image recognition model, and the description information of the video may be determined based on the feature information, thereby determining the description information of the target video frame. If the scene information is identification information, the identification information may be carried in the video input to the encoder.
[0111] In the embodiment of this specification, scene information and dqp can also be stored p 、dqp B 、Fact I And Fact P The corresponding relationship between parameters.
[0112] In the embodiment of this specification, after the video is input into the encoder, the dqp can be obtained based on the recognized scene information. p 、dqp B 、Fact I 、Fact P , C I and C P The values corresponding to the six parameters are used to adjust the parameters of the CRF coding technology based on the six parameters, and the quantization parameter values of each video frame in the video are calculated using the adjusted CRF coding technology.
[0113] Before calculating the quantization parameter value of each video frame, the frame type of any video frame in each video frame may be determined, a corresponding calculation method may be determined according to the frame type, and the quantization parameter value of the any video frame may be calculated based on the calculation method. The corresponding quantization parameter value calculation formula may be determined from the above formulas (3)-(5) based on the frame type.
[0114] In practical applications, when establishing the correspondence between scene information and parameters, a one-to-many correspondence can be established, such as dynamic live scene information: dqp P =2, dqp B=4, C I =1, C p =2、Fact I =2.0、Fact p =0.5; a one-to-one correspondence can also be established, such as dynamic live scene information: dqp P =2; Dynamic live scene information: dqp B =4; Dynamic live scene information: C I =1; Dynamic live scene information: C p =2; Dynamic live scene information: Fact I =2.0; Dynamic live scene information: Fact p =0.5 to establish a one-to-one correspondence. Alternatively, the parameters may be divided into different groups to establish a correspondence with the scene information, or other methods may be used to establish a correspondence based on user preferences, which is not specifically limited here.
[0115] In order to avoid the problem that when a new scene appears, the parameters required for the scene cannot be determined based on the known correspondence, and compression processing cannot be performed, the default initial value of the parameter can be set, such as dqp P =3, dqp B =6, C I =2, C p =2、Fact I =4.0、Fact p =0.2, so that the processing of each video frame in the video corresponding to the new scene can be completed based on the default initial value of the parameter, so as to compress each video frame later. The default value can be set according to user needs and the version type of the encoder, etc., and is not specifically limited here. The above values are only used as examples.
[0116] As an implementation method, the appropriate parameters can be determined by training the CRF code control model. Optionally, before obtaining the second preset boundary value in the embodiment of this specification, the following method may be further included:
[0117] Obtaining a number of candidate second boundary values;
[0118] Based on the plurality of candidate second boundary values, a video sequence of the scene corresponding to the scene information is processed to obtain a plurality of processing results;
[0119] Determine, according to the multiple processing results, a bit rate distortion performance value corresponding to each of the candidate second boundary values;
[0120] Determine the candidate second boundary value corresponding to the bit rate distortion performance value with the smallest numerical value as the second preset boundary value;
[0121] A correspondence between the second preset boundary value and the scene corresponding to the scene information is established.
[0122] In the embodiments of this specification, the bit rate distortion performance value can be represented by a BD-Rate value. The BD-Rate can be used to evaluate the performance of the CRF coding algorithm before and after the improvement, and to determine the degree to which the bit rate of the improved CRF coding algorithm is reduced compared to the CRF coding algorithm before the improvement while ensuring that the quality of the video image seen by the user based on human vision remains unchanged, so as to determine the performance improvement or optimization degree of the improved CRF coding algorithm.
[0123] In the embodiments of the present specification, the candidate second boundary values may be a plurality of values determined from a preset value range according to a preset step value. The preset value range may be determined based on expert experience, or may be determined by analyzing historical data using a network model. The value ranges of the candidate second boundary values of video frames of different frame types may be different or the same, such as the value ranges of the candidate second boundary values of I frames and P frames are both set to [1,3], or the value range corresponding to I frames may be set to [1,3], and the value range corresponding to P frames may be set to [1,4]. The step values of the candidate second boundary values of video frames of different frame types may be the same, and the step values corresponding to I frames and P frames may be set to values such as 1, 0.1, or 0.01.
[0124] In the embodiments of this specification, the improved CRF coding algorithm can be used to process the video sequence based on each candidate second boundary value to obtain a number of processing results; based on the several processing results, the BD-Rate value corresponding to each candidate second boundary value is determined. The BD-Rate values can be sorted, and the candidate second boundary value corresponding to the smallest BD-Rate value is selected as the second preset boundary value.
[0125] In practical applications, the above method can also be used to determine the values of other parameters in the improved CRF coding algorithm in the scene corresponding to the scene information, such as the complexity adjustment coefficient and the quantization parameter difference.
[0126] For the preset value range and the preset step value, it can be assumed that C I The value range of C is [1,3]. P The value range is [1,3], dqp P The value range is [1,5], dqp B The value range is [dqpI,10], Fact I The value range is [0,10], Fact p The value range is [0,2]; used to select C I , C P 、FactI 、Fact p 、dqp P and dqp B The preset step value can be set to 0.01, or it can be set to 1, 0.1, or 0.02, etc. The step value can be set based on the actual needs of the user, and is not specifically limited here. In practical applications, the QP value can be calculated based on the candidate values of the above parameters. If the calculated QP value is a floating point number, the floating point number can be rounded to obtain an integer QP value.
[0127] In practical applications, C I , C P 、dqp P 、dqp B 、Fact I 、Fact p The candidate values corresponding to these six parameters are used so that after using the improved CRF coding algorithm to process the video based on the candidate values of the six parameters, the BD-Rate value corresponding to the improved CRF coding algorithm adjusted based on each candidate value can be obtained, and the six candidate values corresponding to the smallest BD-Rate value are used as the values of the six parameters to establish a correspondence with the scene.
[0128] In practical applications, in order to improve the accuracy of the values of the above six parameters, the encoder can process multiple videos under the scene corresponding to the scene information, obtain multiple BD-Rate values, and calculate the average of the multiple BD-Rate values; establish a corresponding relationship between the candidate values of the six parameters corresponding to the smallest average value and the scene.
[0129] As an implementation manner, optionally, determining the bit rate distortion performance value corresponding to each of the candidate second boundary values according to the multiple processing results in the embodiments of this specification may specifically include:
[0130] Using a first CRF coding algorithm to process the video sequence to obtain a first processing result; the maximum value of the quantization parameter offset value in the first CRF coding algorithm is obtained based on the reference complexity and the complexity of the target video frame;
[0131] For one of the candidate second boundary values to be processed, a second CRF coding algorithm is used to process the video sequence to obtain a second processing result; the maximum value of the quantization parameter offset value in the second CRF coding algorithm is less than or equal to the candidate second boundary value to be processed;
[0132] According to the first processing result and the second processing result, a bit rate distortion performance value of the degree of performance improvement of the first CRF coding algorithm by the candidate second boundary value to be processed is determined.
[0133] The first CRF code control algorithm in the embodiment of the present specification can represent the existing CRF code control algorithm, and no other parameters are introduced for improvement. The maximum value of the quantization parameter offset value in the first CRF code control algorithm can be obtained based on the first preset value, the benchmark complexity, the complexity of the target video frame, and the influence coefficient. The upper limit value of the quantization parameter offset value in the first CRF code control algorithm is not limited, and the influence of the frame type on the benchmark complexity is not considered. The second CRF code control algorithm can represent an algorithm that improves the existing CRF code control algorithm by introducing variable parameters. The second CRF code control algorithm can limit the quantization parameter offset value to a certain value range through the first preset boundary value and the second preset boundary value, so that the minimum value of the quantization parameter offset value is greater than or equal to the first preset boundary value, and the maximum value is less than or equal to the second preset boundary value. The complexity adjustment coefficient can also be introduced in the second CRF code control algorithm to consider the degree of influence of different frame types on the benchmark complexity and improve the accuracy of the quantization parameter value corresponding to the video frame.
[0134] The encoder may adopt a preset constant rate factor and use a first CRF coding algorithm to process the video sequence to obtain a first processing result; the first processing result may include a first image quality and a first bit rate of the video sequence obtained after processing based on the first CRF coding algorithm. The encoder may also adopt the preset constant rate factor and use a second CRF coding algorithm to process the video sequence to obtain a second processing result; the second processing result may include a second image quality and a second bit rate of the video sequence obtained after processing based on the second CRF coding algorithm. The first processing result and the second processing result may be processed as inputs of an Excel spreadsheet file or a matlab script program to output a BD-Rate value; the first processing result and the second processing result may also be evaluated in other ways, such as obtaining two rate-distortion (RD) curves based on the first processing result and the second processing result, integrating the overlapping area of the two RD curves to obtain a BD-Rate value. The specific method used to calculate the BD-Rate value is not specifically limited here.
[0135] The preset constant bit rate factor may include one constant bit rate factor or multiple constant bit rate factors with different values. In order to further illustrate the method of determining the BD-Rate value, multiple constant bit rate factors with different values are used for illustration here. It can be assumed that when the crf values are 22, 27, 32 and 37, the same video is processed, and the encoder processes it based on the second CRF code control algorithm, and determines that when the crf is 22, the bit rate is 686.76kbps and the quality is 40.28dB; when the crf is 27, the bit rate is 309.58kbps and the quality is 37.18dB; when the crf is 32, the bit rate is 157.11kbps and the quality is 34.24dB; when the crf is 37, the bit rate is 85.95kbps and the quality is 31.42dB. The encoder processes based on the first CRF code control algorithm and determines that when crf is 22, the bit rate is 893.34kbps and the quality is 40.39dB; when crf is 27, the bit rate is 407.8kbps and the quality is 37.21dB; when crf is 32, the bit rate is 204.93kbps and the quality is 34.17dB; when crf is 37, the bit rate is 112.75kbps and the quality is 31.24dB; the bit rate, quality and constant bit rate factor values are input into the loaded Ex file for calculating BD-Rate. cel file, BD-Rate=-31.40% can be obtained based on the preset algorithm in the Excel file; it can be understood that the first CRF coding algorithm needs to use 31.4% more bit rate to process the video than the second CRF coding algorithm to achieve the video quality after processing by the second CRF coding algorithm. That is to say, when the first CRF coding algorithm and the second CRF coding algorithm are used to process the video respectively, if the output video quality is the same, the second CRF coding algorithm saves 31.4% bit rate than the first CRF coding algorithm.
[0136] As an implementation manner, optionally, in the embodiment of this specification, when the video parameter is the baseline complexity of the reference frame, the acquiring the video parameter of the target video frame may specifically include:
[0137] Acquire a first number of macroblocks in a row direction and a second number of macroblocks in a column direction of the reference frame;
[0138] Based on a second preset value, the product of the first number of macroblocks and the second number of macroblocks is processed to obtain the benchmark complexity; the second preset value is greater than the first preset value.
[0139] The macroblock in the embodiments of this specification may represent a rectangular area of a fixed size in an image, which is usually composed of several continuous pixel blocks. A macroblock is the smallest coding unit and is used to compress a video frame. The macroblock size may be 16*16 pixels, 32*32 pixels, and 64*64 pixels, which are not specifically limited here and may be determined based on the video coding standard. The second preset value may be obtained based on expert experience or a network model analyzed based on historical data.
[0140] As an implementation method, the benchmark complexity can be calculated according to the sixth formula (6) shown below:
[0141] (6)
[0142] MBcount w It can represent the number of the first macroblock in the row direction of the video frame; MBcount h It can represent the second number of macroblocks in the column direction of the video frame; the second preset value can be 120 or 80, or other values, which can be adjusted according to the macroblock size. For example, when the macroblock size is 32*32 pixels, 30 can be used as the second preset value when bframes>0, and 20 can be used as the second preset value when bframes=0; when the macroblock size is 128*128 pixels, 480 can be used as the second preset value when bframes>0, and 320 can be used as the second preset value when bframes=0. bframes can represent the number of B frames between I frames and P frames in the video, or the number of B frames between P frames.
[0143] If the number of B frames is less than 3, the amount of data will be large, resulting in a high bit rate and high cost; if the number of B frames is greater than 3, it is necessary to wait for the first adjacent P frame closest to the B frame to be decoded before the B frame can be decoded, which will cause a high delay in the process. Optionally, in the embodiment of this specification, bframes can be 3 to achieve a balance between delay and cost. The video sequence when bframes is 3 can be sorted in the order of IBBBPBBBP.
[0144] In the embodiments of the present specification, the complexity of the target video frame can be obtained by processing the prediction cost generated by the forward prediction (lookahead) module; the forward prediction module can be a module in the encoder. Regarding the prediction cost, the target video frame can be predicted by using the inter-frame prediction (inter prediction) method to obtain the inter-frame prediction cost value evaluated by the sum of absolute differences (SAD); or the target video frame can be predicted by using the intra-frame prediction (intra prediction) method to obtain the intra-frame prediction cost value evaluated by the sum of absolute differences, and based on the formula Determine the complexity of the target video frame, where intra_sad_cost represents the intra-frame prediction cost value generated by predicting the target video frame using the intra-frame prediction method based on the SAD algorithm evaluation; inter_sad_cost represents the inter-frame prediction cost value generated by predicting the target video frame using the inter-frame prediction method based on the SAD algorithm evaluation.
[0145] Based on the processing of videos in various scenarios, compared with the existing compression method, according to the compression method with excellent performance provided in the embodiments of this specification, the BD-Rate of the CRF code control algorithm in the static live streaming scenario is increased by 2.26%; the BD-Rate of the CRF code control algorithm in the outdoor fixed camera scenario is increased by 2.05%; the BD-Rate of the CRF code control algorithm in the outdoor mobile camera scenario is increased by 1.21%; the BD-Rate of the CRF code control algorithm in the computer-generated image scenario is increased by 0.71%; the BD-Rate of the CRF code control algorithm in the live short video scenario is increased by 1.72%.
[0146] Through the above method, the corresponding parameter value can be obtained according to the video scene, so as to determine the value range of the quantization parameter value based on the parameter value, so that the quantization parameter value can be within the value range, and the benchmark complexity is adjusted by the complexity adjustment coefficient to improve the reference value of the benchmark complexity, thereby improving the accuracy of the quantization parameter value of the target video frame, so that the BD-Rate performance of the CRF coding technology is improved. While ensuring that the video quality perceived by the human eye remains unchanged, the video bit rate can also be reduced, thereby reducing the bandwidth cost.
[0147] Based on the same idea, the embodiments of this specification also provide a device corresponding to the above method. Figure 3 The structure diagram of a video compression device provided in the embodiment of this specification is shown in FIG. Figure 3 As shown, the device may include:
[0148] The video parameter acquisition module 302 is used to acquire the video parameters of the target video frame; the video parameters at least include the baseline complexity of the reference frame, the complexity of the target video frame, the influence coefficient and the complexity adjustment coefficient;
[0149] A quantization parameter offset value determination module 304, configured to determine a quantization parameter offset value of the target video frame according to the video parameters;
[0150] A first adjustment module 306, configured to adjust the quantization parameter offset value to a value of the first preset boundary value if the quantization parameter offset value is less than a first preset boundary value; the first preset boundary value is used to indicate a lower limit value of the quantization parameter offset value;
[0151] A second adjustment module 308 is configured to adjust the quantization parameter offset value to a value of the second preset boundary value if the quantization parameter offset value is greater than a second preset boundary value; the second preset boundary value is used to represent an upper limit value of the quantization parameter offset value; the second preset boundary value is greater than the first preset boundary value;
[0152] A quantization parameter value determination module 310, configured to determine a quantization parameter value of the target video frame based on the adjusted quantization parameter offset value and a constant bit rate factor;
[0153] The compression module 312 is used to compress the target video frame according to the quantization parameter value.
[0154] Optionally, the quantization parameter offset value determination module in the embodiments of this specification may specifically include:
[0155] A reference complexity adjustment unit, configured to determine an adjusted reference complexity according to the reference complexity and the complexity adjustment coefficient;
[0156] a relative complexity determination unit, configured to determine the relative complexity of the target video frame relative to the reference frame according to a ratio of the complexity of the target video frame to the adjusted reference complexity;
[0157] A weight value determination unit, used to determine a weight value according to the influence coefficient and a first preset value; the weight value is used to represent the intensity of the relative complexity adjustment;
[0158] The quantization parameter offset value calculation unit is used to round the product of the weight value and the relative complexity to obtain the quantization parameter offset value.
[0159] Optionally, the device described in the embodiments of this specification may also include:
[0160] If the quantization parameter offset value is greater than the first preset boundary value and less than the second preset boundary value, the quantization parameter value of the target video frame is determined according to the quantization parameter offset value and a constant bit rate factor.
[0161] Optionally, the quantization parameter value determination module described in the embodiments of this specification may be specifically used for:
[0162] If the target video frame is a difference frame, obtaining a first quantization parameter difference value; the first quantization parameter difference value is a difference between a first quantization parameter value of the difference frame and a second quantization parameter value of a key frame belonging to the same picture group as the difference frame;
[0163] The quantization parameter value of the target video frame is determined according to the first quantization parameter difference, the adjusted quantization parameter offset value, and a constant bit rate factor.
[0164] Optionally, the quantization parameter value determination module described in the embodiments of this specification may be specifically used for:
[0165] If the target video frame is a bidirectional difference frame, a first quantization parameter difference value and a second quantization parameter difference value are obtained; the first quantization parameter difference value is a difference between a first quantization parameter value of the difference frame and a second quantization parameter value of the key frame; the second quantization parameter difference value is a difference between a third quantization parameter value of the bidirectional difference frame and the first quantization parameter value of the difference frame; the difference frame, the key frame and the bidirectional difference frame belong to the same picture group; the difference frame is a difference frame located after the bidirectional difference frame in the picture group;
[0166] The quantization parameter information of the target video frame is determined according to the first quantization parameter difference, the second quantization parameter difference, the adjusted quantization parameter value, and a constant bit rate factor.
[0167] Optionally, the device described in the embodiments of this specification may further include a second preset boundary value acquisition module, which may specifically include:
[0168] A scene information determination unit, used to determine the scene information of the target video frame;
[0169] The second preset boundary value acquisition unit is used to acquire the second preset boundary value according to the scene information and a pre-established corresponding relationship; the corresponding relationship is used to represent the relationship between the scene information and the second preset boundary value.
[0170] Optionally, the device described in the embodiments of this specification may further include a corresponding relationship establishment module, which may specifically include:
[0171] Obtaining a number of candidate second boundary values;
[0172] Based on the plurality of candidate second boundary values, a video sequence of the scene corresponding to the scene information is processed to obtain a plurality of processing results;
[0173] Determine, according to the multiple processing results, a bit rate distortion performance value corresponding to each of the candidate second boundary values;
[0174] Determine the candidate second boundary value corresponding to the bit rate distortion performance value with the smallest numerical value as the second preset boundary value;
[0175] A correspondence between the second preset boundary value and the scene corresponding to the scene information is established.
[0176] Optionally, the corresponding relationship establishing module described in the embodiments of this specification may be specifically used for:
[0177] Using a first CRF coding algorithm to process the video sequence to obtain a first processing result; the maximum value of the quantization parameter offset value in the first CRF coding algorithm is obtained based on the reference complexity and the complexity of the target video frame;
[0178] For one of the candidate second boundary values to be processed, a second CRF coding algorithm is used to process the video sequence to obtain a second processing result; the maximum value of the quantization parameter offset value in the second CRF coding algorithm is less than or equal to the candidate second boundary value to be processed;
[0179] According to the first processing result and the second processing result, a bit rate distortion performance value of the degree of performance improvement of the first CRF coding algorithm by the candidate second boundary value to be processed is determined.
[0180] Optionally, the quantization parameter offset value determination module described in the embodiments of this specification may be specifically used for:
[0181] Acquire a first number of macroblocks in a row direction and a second number of macroblocks in a column direction of the reference frame;
[0182] Based on a second preset value, the product of the first number of macroblocks and the second number of macroblocks is processed to obtain the benchmark complexity; the second preset value is greater than the first preset value.
[0183] Based on the same idea, the embodiments of this specification also provide a device corresponding to the above method.
[0184] Figure 4 This is a schematic diagram of the structure of a video compression device provided in an embodiment of this specification. Figure 4 As shown, the device 400 may include:
[0185] at least one processor 410; and,
[0186] A memory 430 is communicatively connected to the at least one processor; wherein,
[0187] The memory 430 stores instructions 420 executable by the at least one processor 410. The instructions are executed by the at least one processor 410 to enable the at least one processor 410 to:
[0188] Acquire video parameters of a target video frame; the video parameters at least include a baseline complexity of a reference frame, a complexity of the target video frame, an influence coefficient, and a complexity adjustment coefficient;
[0189] Determining a quantization parameter offset value of the target video frame according to the video parameter;
[0190] If the quantization parameter offset value is less than a first preset boundary value, the quantization parameter offset value is adjusted to the value of the first preset boundary value; the first preset boundary value is used to represent the lower limit value of the quantization parameter offset value;
[0191] If the quantization parameter offset value is greater than a second preset boundary value, the quantization parameter offset value is adjusted to the value of the second preset boundary value; the second preset boundary value is used to represent the upper limit value of the quantization parameter offset value; the second preset boundary value is greater than the first preset boundary value;
[0192] Determining a quantization parameter value of the target video frame based on the adjusted quantization parameter offset value and the constant bit rate factor;
[0193] The target video frame is compressed according to the quantization parameter value.
[0194] Based on the same idea, the embodiment of this specification also provides a computer-readable storage medium corresponding to the above method. The computer-readable storage medium stores a computer program or instruction, which can be executed by a processor to implement the above video compression method.
[0195] Each embodiment in this specification is described in a progressive manner. The same or similar parts between the embodiments can be referred to each other. Each embodiment focuses on the differences from other embodiments. Figure 3 Devices and Figure 4 As for the device shown, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0196] In the 1990s, it was very clear whether the improvement of a technology was hardware improvement (for example, improvement of the circuit structure of diodes, transistors, switches, etc.) or software improvement (improvement of the method flow). However, with the development of technology, many improvements of the method flow today can be regarded as direct improvements of the hardware circuit structure. Designers can almost get the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that the improvement of a method flow cannot be realized by hardware entity modules. For example, a programmable logic device (PLD) (such as a field programmable gate array (FPGA)) is such an integrated circuit whose logical function is determined by the user's programming of the device. Designers can "integrate" a digital system on a PLD by programming themselves, without having to ask chip manufacturers to design and make dedicated integrated circuit chips. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly implemented by "logic compiler" software, which is similar to the software compiler used when developing and writing programs, and the original code before compilation must also be written in a specific programming language, which is called hardware description language (HDL). There is not only one kind of HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also know that it is only necessary to program the method flow slightly in the above-mentioned hardware description languages and program it into the integrated circuit, and then it is easy to obtain the hardware circuit that implements the logic method flow.
[0197] The controller may be implemented in any suitable manner, for example, the controller may take the form of a microprocessor or processor and a computer-readable medium storing a computer-readable program code (such as software or firmware) executable by the (micro)processor, a logic gate, a switch, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller may also be implemented as part of the control logic of the memory. It is also known to those skilled in the art that, in addition to implementing the controller in a purely computer-readable program code manner, the controller may be implemented in the form of a logic gate, a switch, an application-specific integrated circuit, a programmable logic controller, and an embedded microcontroller by logically programming the method steps. Therefore, such a controller may be considered as a hardware component, and the devices for implementing various functions included therein may also be considered as structures within the hardware component. Or even, the devices for implementing various functions may be considered as both software modules for implementing the method and structures within the hardware component.
[0198] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0199] For the convenience of description, the above device is described in various units according to their functions. Of course, when implementing the present application, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0200] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0201] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0202] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0203] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0204] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0205] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
[0206] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined in this article, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0207] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0208] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0209] The present application may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.
[0210] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. A video compression method, comprising: Obtaining video parameters of a target video frame; the video parameters at least include a baseline complexity of a reference frame, a complexity of the target video frame, an influence coefficient, and a complexity adjustment coefficient; the baseline complexity of the reference frame is calculated based on the height and width of the reference frame; the influence coefficient is used to indicate the intensity of adjustment of the quantization parameter value of the target video frame; The complexity adjustment coefficient is a coefficient used to represent the base complexity of adjusting the reference frame; Determining a quantization parameter offset value of the target video frame according to the video parameter; The quantization parameter offset value represents the value of the quantization parameter of the target video frame that needs to be offset based on the constant bit rate factor; If the quantization parameter offset value is less than a first preset boundary value, the quantization parameter offset value is adjusted to the value of the first preset boundary value; the first preset boundary value is used to represent the lower limit value of the quantization parameter offset value; If the quantization parameter offset value is greater than a second preset boundary value, the quantization parameter offset value is adjusted to the value of the second preset boundary value; the second preset boundary value is used to represent the upper limit value of the quantization parameter offset value; the second preset boundary value is greater than the first preset boundary value; Determining a quantization parameter value of the target video frame based on the adjusted quantization parameter offset value and the constant bit rate factor; The target video frame is compressed according to the quantization parameter value.
2. The method according to claim 1, wherein determining the quantization parameter offset value of the target video frame according to the video parameter comprises: Determining an adjusted baseline complexity according to the baseline complexity and the complexity adjustment coefficient; Determining a relative complexity of the target video frame relative to the reference frame according to a ratio of the complexity of the target video frame to the adjusted reference complexity; Determining a weight value according to the influence coefficient and a first preset value; the weight value is used to indicate the intensity of adjusting the relative complexity; The product of the weight value and the relative complexity is rounded to obtain the quantization parameter offset value.
3. The method according to claim 1, further comprising: If the quantization parameter offset value is greater than the first preset boundary value and less than the second preset boundary value, the quantization parameter value of the target video frame is determined according to the quantization parameter offset value and a constant bit rate factor.
4. The method according to claim 1, wherein determining the quantization parameter value of the target video frame based on the adjusted quantization parameter offset value and the constant bit rate factor comprises: If the target video frame is a difference frame, obtaining a first quantization parameter difference; The first quantization parameter difference is a difference between a first quantization parameter value of the difference frame and a second quantization parameter value of a key frame belonging to the same picture group as the difference frame; The quantization parameter value of the target video frame is determined according to the first quantization parameter difference, the adjusted quantization parameter offset value, and a constant bit rate factor.
5. The method according to claim 1, wherein determining the quantization parameter value of the target video frame based on the adjusted quantization parameter offset value and the constant bit rate factor comprises: If the target video frame is a bidirectional difference frame, obtaining a first quantization parameter difference value and a second quantization parameter difference value; The first quantization parameter difference is the difference between the first quantization parameter value of the difference frame and the second quantization parameter value of the key frame; The second quantization parameter difference value is a difference between a third quantization parameter value of the bidirectional difference frame and the first quantization parameter value of the difference frame; The difference frame, the key frame and the bidirectional difference frame belong to the same picture group; The difference frame is a difference frame located after the bidirectional difference frame in the group of pictures; The quantization parameter information of the target video frame is determined according to the first quantization parameter difference, the second quantization parameter difference, the adjusted quantization parameter value, and a constant bit rate factor.
6. According to the method of claim 1, obtaining the second preset boundary value specifically comprises: Determining scene information of the target video frame; Acquire the second preset boundary value according to the scene information and the pre-established corresponding relationship; The corresponding relationship is used to represent the relationship between the scene information and the second preset boundary value.
7. The method according to claim 6, before obtaining the second preset boundary value, further comprising: Obtaining a number of candidate second boundary values; Based on the plurality of candidate second boundary values, a video sequence of the scene corresponding to the scene information is processed to obtain a plurality of processing results; Determine, according to the multiple processing results, a bit rate distortion performance value corresponding to each of the candidate second boundary values; Determine the candidate second boundary value corresponding to the bit rate distortion performance value with the smallest numerical value as the second preset boundary value; A correspondence between the second preset boundary value and the scene corresponding to the scene information is established.
8. The method according to claim 7, wherein determining the bit rate distortion performance value corresponding to each of the candidate second boundary values according to the multiple processing results specifically comprises: Using a first CRF coding algorithm to process the video sequence to obtain a first processing result; The maximum value of the quantization parameter offset value in the first CRF coding algorithm is obtained based on the reference complexity and the complexity of the target video frame; For one of the candidate second boundary values to be processed, using a second CRF coding algorithm to process the video sequence to obtain a second processing result; The maximum value of the quantization parameter offset value in the second CRF coding algorithm is less than or equal to the candidate second boundary value to be processed; According to the first processing result and the second processing result, a bit rate distortion performance value of the degree of performance improvement of the first CRF coding algorithm by the candidate second boundary value to be processed is determined.
9. The method according to claim 2, if the video parameter is a base complexity of a reference frame, obtaining the video parameter of the target video frame specifically comprises: Acquire a first number of macroblocks in a row direction and a second number of macroblocks in a column direction of the reference frame; Based on a second preset value, processing the product of the first number of macroblocks and the second number of macroblocks to obtain the reference complexity; The second preset value is greater than the first preset value.
10. A video compression device, comprising: A video parameter acquisition module, used to acquire video parameters of a target video frame; the video parameters at least include a baseline complexity of a reference frame, a complexity of the target video frame, an influence coefficient, and a complexity adjustment coefficient; the baseline complexity of the reference frame is calculated based on the height and width of the reference frame; the influence coefficient is used to indicate the intensity of adjustment of the quantization parameter value of the target video frame; The complexity adjustment coefficient is a coefficient used to represent the base complexity of adjusting the reference frame; A quantization parameter offset value determination module, used to determine the quantization parameter offset value of the target video frame according to the video parameter; The quantization parameter offset value represents the value of the quantization parameter of the target video frame that needs to be offset based on the constant bit rate factor; A first adjustment module, configured to adjust the quantization parameter offset value to a value of the first preset boundary value if the quantization parameter offset value is less than a first preset boundary value; the first preset boundary value is used to indicate a lower limit value of the quantization parameter offset value; a second adjustment module, configured to adjust the quantization parameter offset value to a value of the second preset boundary value if the quantization parameter offset value is greater than a second preset boundary value; the second preset boundary value is used to represent an upper limit value of the quantization parameter offset value; the second preset boundary value is greater than the first preset boundary value; A quantization parameter value determination module, configured to determine a quantization parameter value of the target video frame based on the adjusted quantization parameter offset value and a constant bit rate factor; A compression module is used to compress the target video frame according to the quantization parameter value.
11. A video compression device, comprising: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to: Obtaining video parameters of a target video frame; the video parameters at least include a baseline complexity of a reference frame, a complexity of the target video frame, an influence coefficient, and a complexity adjustment coefficient; the baseline complexity of the reference frame is calculated based on the height and width of the reference frame; the influence coefficient is used to indicate the intensity of adjustment of the quantization parameter value of the target video frame; the complexity adjustment coefficient is a coefficient used to indicate adjustment of the baseline complexity of the reference frame; Determine a quantization parameter offset value of the target video frame according to the video parameter; the quantization parameter offset value represents a value to which the quantization parameter of the target video frame needs to be offset based on a constant bit rate factor; If the quantization parameter offset value is less than a first preset boundary value, the quantization parameter offset value is adjusted to the value of the first preset boundary value; the first preset boundary value is used to represent the lower limit value of the quantization parameter offset value; If the quantization parameter offset value is greater than a second preset boundary value, the quantization parameter offset value is adjusted to the value of the second preset boundary value; the second preset boundary value is used to represent the upper limit value of the quantization parameter offset value; the second preset boundary value is greater than the first preset boundary value; Determining a quantization parameter value of the target video frame based on the adjusted quantization parameter offset value and the constant bit rate factor; The target video frame is compressed according to the quantization parameter value.
12. A computer-readable storage medium having a computer program or instructions stored thereon, wherein the computer program or instructions are executed by a processor to implement the steps of the method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Video encoding code rate control method, apparatus and system
CN106254868A
Video coding method, device, equipment, storage medium and computer program product
CN117880507A