Video encoding method

By using the characteristic parameters of the preamble and adjacent coding cycles to calculate coding control parameters in video coding, the problem of resource waste and poor quality caused by improper bit rate control in the existing technology is solved, and high efficiency in limited storage space is achieved. Image quality and bitrate.

CN118214887BActive Publication Date: 2024-09-06ZHEJIANG DAHUA TECH CO LTD
View PDF 18 Cites 0 Cited by

Patent Information

Application Number
CN202410624228.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-20
Publication Date
2024-09-06
Estimated Expiration
2044-05-20

AI Technical Summary

Technical Problem

Existing video encoding methods have problems with resource waste and poor quality in bit rate control, especially when storage space is limited and it is difficult to balance video quality and bit rate.

Method used

By determining the characteristic parameters of the previous coding cycle and adjacent coding cycles during the video coding process, the coding control parameters of the current coding cycle are calculated, and the video data is coded based on these parameters to ensure the rationality and flexibility of the code rate allocation. .

Benefits of technology

Obtain better image quality and code stream with maximum efficiency in limited storage space, and improve the calculation accuracy and flexibility of encoding control parameters.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118214887B
    Figure CN118214887B
Patent Text Reader

Abstract

The present application discloses a video encoding method, which includes: determining the encoding cycle that has been encoded before the current encoding cycle, obtaining the previous encoding cycle set corresponding to the current encoding cycle, and taking the previous encoding cycle adjacent to the current encoding cycle in the previous encoding cycle set as the adjacent encoding cycle; extracting the first encoding feature parameter of each previous encoding cycle, and extracting the second encoding feature parameter corresponding to the adjacent encoding cycle; combining the first encoding feature parameter and the second encoding feature parameter to calculate the encoding control parameter of the current encoding cycle; encoding the video data based on the encoding control parameter to obtain the encoding result. The encoding conditions of all previous encoding cycles corresponding to the current encoding cycle and the encoding conditions of the adjacent encoding cycles can be comprehensively considered to make the code rate allocation more reasonable, so as to obtain a code stream with better image quality with the maximum efficiency in a certain capacity of storage space.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] At present, in the application scenario of video encoding, there are usually two bit rate control modes, including: variable bit rate mode (VBR) and constant bit rate mode (CBR). Among them, VBR sets the bit rate upper limit, and allows the bit rate to fluctuate without exceeding the bit rate upper limit, thereby ensuring the stable quality of the encoded image. This mode is suitable for application scenarios with local storage; CBR sets the target bit rate, does not allow the bit rate to fluctuate, and ensures the stable encoding bit rate. This mode is suitable for application scenarios where the channel bandwidth is basically constant.

[0003] However, when the VBR mode is used, since it is impossible to estimate the bit rate fluctuation, the VBR bit rate upper limit is usually used to calculate the storage space, which will lead to an estimated storage device capacity that is too large, resulting in a waste of storage resources; when the CBR mode is used, although the CBR target bit rate value can be used to accurately estimate the storage space required by the system, the CBR algorithm uses the same target bit rate to encode simple scenes and complex scenes, which will cause a waste of bit rate for simple scenes and poor video quality for complex scenes. In actual applications, the transmission bandwidth and storage capacity are both limited, resulting in the inability of the above two existing methods to effectively balance the relationship between video quality and target bit rate, and it is difficult to obtain a bit stream with better image quality with the maximum efficiency in a certain storage space. Summary of the invention

[0004] In order to solve the above technical problems, the present application at least provides a video encoding method.

[0005] The first aspect of the present application provides a video encoding method, the encoding process includes multiple encoding cycles, and the method includes: determining the encoding cycle that has been completed before the current encoding cycle, obtaining a set of preceding encoding cycles corresponding to the current encoding cycle, and taking the preceding encoding cycles in the preceding encoding cycle set that are adjacent to the current encoding cycle as adjacent encoding cycles; extracting the first encoding feature parameters of each preceding encoding cycle in the preceding encoding cycle set, and extracting the second encoding feature parameters corresponding to the adjacent encoding cycle; wherein the first encoding feature parameters and the second encoding feature parameters are used to describe the execution status of the encoding cycle; combining the first encoding feature parameters corresponding to the preceding encoding cycle set and the second encoding feature parameters corresponding to the adjacent encoding cycle, calculating the encoding control parameters of the current encoding cycle; encoding the video data based on the encoding control parameters to obtain the encoding result corresponding to the video data.

[0006] In one embodiment, the encoding process includes multiple levels of encoding cycles; extracting the first encoding feature parameters of each previous encoding cycle in the previous encoding cycle set, and extracting the second encoding feature parameters corresponding to the adjacent encoding cycle, including: based on the level to which the current encoding cycle belongs, extracting the first encoding feature parameters of each previous encoding cycle in the previous encoding cycle set, and extracting the second encoding feature parameters corresponding to the adjacent encoding cycle.

[0007] In one embodiment, the coding control parameters of the current coding cycle are calculated by combining the first coding feature parameters corresponding to the previous coding cycle set and the second coding feature parameters corresponding to the adjacent coding cycle, including: judging whether the first coding feature parameters corresponding to the previous coding cycle set meet preset conditions; and calculating the coding control parameters of the current coding cycle based on the judgment result and the second coding feature parameters corresponding to the adjacent coding cycle.

[0008] In one embodiment, the current coding cycle belongs to a long cycle, the first coding feature parameter includes the average coding bit rate of each previous coding cycle, the second coding feature parameter includes the average coding bit rate and the expected coding bit rate of adjacent coding cycles, and the coding control parameter includes the expected coding bit rate of the long cycle; judging whether the first coding feature parameter corresponding to the previous coding cycle set meets the preset conditions, including: judging the size relationship between the average coding bit rate of each previous coding cycle and the preset coding bit rate; based on the judgment result and the second coding feature parameter corresponding to the adjacent coding cycle, calculating the coding control parameter of the current coding cycle, including: calculating the bit rate difference between the average coding bit rate of the adjacent coding cycle and the expected coding bit rate of the adjacent coding cycle; and determining the feedback parameter calculation strategy based on the judgment result, and calculating the previous coding feedback parameter according to the feedback parameter calculation strategy; based on the previous coding feedback parameter and the bit rate difference, calculating the expected coding bit rate of the current coding cycle.

[0009] In one embodiment, the second coding feature parameter also includes motion information of adjacent coding cycles; a feedback parameter calculation strategy is determined based on the judgment result, and a preamble coding feedback parameter is calculated according to the feedback parameter calculation strategy, including: if the judgment result shows that the average coding bit rate of each preceding coding cycle is greater than the preset coding bit rate, the preamble coding feedback parameter is calculated using the average coding bit rate of each preceding coding cycle and the preset coding bit rate; if the judgment result shows that the average coding bit rate of each preceding coding cycle is not greater than the preset coding bit rate, the preamble coding feedback parameter is calculated using the motion information of adjacent coding cycles and the bit rate difference.

[0010] In one embodiment, the encoding process includes a long cycle, the long cycle includes multiple short cycles, the current encoding cycle belongs to the short cycle, each previous encoding cycle corresponding to the current encoding cycle and the current encoding cycle belong to the same long cycle, the first encoding feature parameter includes the average encoding bit rate of each previous encoding cycle, the second encoding feature parameter includes the average encoding bit rate and quantization parameter and motion information of adjacent encoding cycles, and the encoding control parameter includes the quantization parameter of the short cycle; judging whether the first encoding feature parameter corresponding to the previous encoding cycle set meets the preset condition, including: obtaining the expected encoding bit rate corresponding to the long cycle to which the current encoding cycle belongs; judging each previous encoding cycle The relationship between the average coding rate of the previous coding period and the expected coding rate of the long period; based on the judgment result and the second coding feature parameter corresponding to the adjacent coding period, the coding control parameter of the current coding period is calculated, including: if the judgment result shows that the average coding rate of each previous coding period is greater than the expected coding rate of the long period, the average coding rate and quantization parameter of the adjacent coding period are used to calculate the quantization parameter of the current coding period; if the judgment result shows that the average coding rate of each previous coding period is not greater than the expected coding rate of the long period, the average coding rate and motion information of the adjacent coding period are used to calculate the quantization parameter of the current coding period.

[0011] In one embodiment, if the judgment result shows that the average encoding bit rate of each previous encoding cycle is greater than the expected encoding bit rate of the long cycle, the average encoding bit rate and quantization parameter of the adjacent encoding cycles are used to calculate the quantization parameter of the current encoding cycle, including: detecting the encoded time and the preset encoding quality level corresponding to the long cycle to which the current encoding cycle belongs; based on the encoded time and the preset encoding quality level, calculating the adjustable ratio; combining the average encoding bit rate and quantization parameter of the adjacent encoding cycles and the adjustable ratio, calculating the quantization parameter of the current encoding cycle.

[0012] In one embodiment, if the judgment result shows that the average encoding bit rate of each previous encoding cycle is not greater than the expected encoding bit rate of the long cycle, the average encoding bit rate and motion information of the adjacent encoding cycles are used to calculate the quantization parameter of the current encoding cycle, including: obtaining the target bit rate interval and the basic quantization parameter corresponding to the current encoding cycle; if the average encoding bit rate of the adjacent encoding cycle is within the target bit rate interval, determining the quantization parameter adjustment value according to the motion information of the adjacent encoding cycle; if the average encoding bit rate of the adjacent encoding cycle is greater than the maximum value of the target bit rate interval, determining the quantization parameter adjustment value to be a first adjustment value; if the average encoding bit rate of the adjacent encoding cycle is less than the minimum value of the target bit rate interval, determining the quantization parameter adjustment value to be a second adjustment value; adjusting the basic quantization parameter based on the quantization parameter adjustment value to obtain the quantization parameter of the current encoding cycle.

[0013] In one embodiment, the coding control parameters also include the motion gain amplitude of the short cycle; based on the judgment result and the second coding feature parameter corresponding to the adjacent coding cycle, the coding control parameters of the current coding cycle are calculated, including: if the judgment result shows that the average coding bit rate of each previous coding cycle is greater than the expected coding bit rate of the long cycle, the motion gain amplitude of the current coding cycle is set to a first preset value; if the judgment result shows that the average coding bit rate of each previous coding cycle is not greater than the expected coding bit rate of the long cycle, based on the average coding bit rate of each previous coding cycle, the expected coding bit rate of the long cycle and the preset coding quality level, the motion gain amplitude of the current coding cycle is calculated.

[0014] In one embodiment, the encoding process includes a long cycle, the long cycle includes multiple short cycles, the short cycle includes multiple video frame cycles, the current encoding cycle belongs to the video frame cycle, each previous encoding cycle corresponding to the current encoding cycle and the current encoding cycle belong to the same short cycle, the first encoding feature parameter includes the encoded bits and the number of encoded frames of the previous encoding cycle set, the second encoding feature parameter includes the encoded bits and quantization parameters of the adjacent encoding cycle, and the encoding control parameter includes the quantization parameter of the video frame cycle; combining the first encoding feature parameter corresponding to the previous encoding cycle set and the second encoding feature parameter corresponding to the adjacent encoding cycle, the encoding control parameter of the current encoding cycle is calculated, including: based on the encoded bits and the number of encoded frames corresponding to the previous encoding cycle set, the maximum bit per frame is calculated; based on the encoded bits, quantization parameters and the maximum bit per frame of the adjacent coding cycle, the quantization parameter of the current encoding cycle is calculated.

[0015] In one embodiment, the quantization parameter of the current coding cycle is calculated based on the encoded bits of adjacent coding cycles, the quantization parameter and the maximum bits per frame, including: obtaining the motion gain amplitude corresponding to the short cycle to which the current coding cycle belongs; based on the motion gain amplitude, the encoded bits of adjacent coding cycles, the quantization parameter and the maximum bits per frame, the quantization parameter of the current coding cycle is calculated.

[0016] According to a second aspect of the present application, there is provided a video encoding device, wherein the encoding process includes multiple encoding cycles, and the device includes: a cycle determination module, which is used to determine the encoding cycle that has been encoded before the current encoding cycle, obtain a set of preceding encoding cycles corresponding to the current encoding cycle, and use the preceding encoding cycles in the preceding encoding cycle set that are adjacent to the current encoding cycle as adjacent encoding cycles; a coding feature extraction module, which is used to extract the first coding feature parameters of each preceding encoding cycle in the preceding encoding cycle set, and to extract the second coding feature parameters corresponding to the adjacent encoding cycle; wherein the first coding feature parameters and the second coding feature parameters are used to describe the execution status of the encoding cycle; a control parameter calculation module, which is used to calculate the encoding control parameters of the current encoding cycle by combining the first coding feature parameters corresponding to the preceding coding cycle set and the second coding feature parameters corresponding to the adjacent coding cycle; and a coding processing module, which is used to perform coding processing on the video data based on the coding control parameters to obtain the coding result corresponding to the video data.

[0017] A third aspect of the present application provides an electronic device, including a memory and a processor, wherein the processor is used to execute program instructions stored in the memory to implement the above-mentioned video encoding method.

[0018] A fourth aspect of the present application provides a computer-readable storage medium on which program instructions are stored, and when the program instructions are executed by a processor, the above-mentioned video encoding method is implemented.

[0019] The above scheme obtains a set of preceding coding cycles corresponding to the current coding cycle by determining the coding cycles that have completed coding before the current coding cycle, and takes the preceding coding cycles in the preceding coding cycle set that are adjacent to the current coding cycle as adjacent coding cycles; extracts the first coding feature parameters of each preceding coding cycle in the preceding coding cycle set, and extracts the second coding feature parameters corresponding to the adjacent coding cycle; wherein the first coding feature parameters and the second coding feature parameters are used to describe the execution status of the coding cycle; calculates the coding control parameters of the current coding cycle by combining the first coding feature parameters corresponding to the preceding coding cycle set and the second coding feature parameters corresponding to the adjacent coding cycle; encodes the video data based on the coding control parameters to obtain the coding result corresponding to the video data, which can comprehensively consider the coding status of all preceding coding cycles corresponding to the current coding cycle and the coding status of the adjacent coding cycles, so that the bit rate allocation is more reasonable, the flexibility and accuracy of the coding control parameter calculation are improved, and a bit stream with better image quality can be obtained with maximum efficiency in a storage space of a certain capacity.

[0020] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present application and are used together with the specification to illustrate the technical solution of the present application.

[0022] Figure 1 It is a schematic diagram of an implementation environment of a solution provided by an embodiment of the present application;

[0023] Figure 2 is a flowchart of a video encoding method shown in an exemplary embodiment of the present application;

[0024] Figure 3 is a flowchart of calculating a long-period encoding control parameter shown in an exemplary embodiment of the present application;

[0025] Figure 4 is a flowchart of calculating a short-cycle coding control parameter shown in an exemplary embodiment of the present application;

[0026] Figure 5 is a flowchart of calculating the encoding control parameters of the video frame period shown in an exemplary embodiment of the present application;

[0027] Figure 6 is a block diagram of a video encoding device shown in an exemplary embodiment of the present application;

[0028] Figure 7 is a schematic structural diagram of an electronic device shown in an exemplary embodiment of the present application;

[0029] Figure 8 It is a schematic diagram of the structure of a computer-readable storage medium shown in an exemplary embodiment of the present application. DETAILED DESCRIPTION

[0030] The scheme of the embodiment of the present application is described in detail below in conjunction with the drawings of the specification.

[0031] In the following description, for the purpose of explanation rather than limitation, specific details such as specific system structures, interfaces, and technologies are provided to facilitate a thorough understanding of the present application.

[0032] The term "and / or" in this article is only an association information describing the associated objects, indicating that there may be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the previous and next associated objects are in an "or" relationship. In addition, "many" in this article means two or more than two. In addition, the term "at least one" in this article means any combination of at least two of any one or more of a plurality of, for example, including at least one of A, B, and C, can mean including any one or more elements selected from the set consisting of A, B, and C.

[0033] The video encoding method provided in the embodiment of the present application is described below.

[0034] Please refer to Figure 1 , which shows a schematic diagram of a solution implementation environment provided by an embodiment of the present application. The solution implementation environment may include a terminal and a server 120, which are connected to each other in communication, wherein the terminal includes a sending end 111 and a receiving end 112.

[0035] The terminal may be a camera, a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, etc., but is not limited thereto.

[0036] Server 120 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), as well as big data and artificial intelligence platforms.

[0037] In one example, the transmitting end 111 obtains the video data to be encoded, and sends the video data to be encoded to the server 120. The server 120 encodes the video data to be encoded, obtains the encoding result corresponding to the video data, and sends the encoding result to the receiving end 112. The receiving end 112 decodes and displays the decoded video data. Currently, the server 120 can also store the encoding result locally, transmit it back to the transmitting end 111, or transmit it to other terminals.

[0038] In an example, the sending end 111 may also execute the video encoding method provided in the embodiment of the present application, and store or forward the encoding result corresponding to the video data.

[0039] See also Figure 2 , Figure 2 FIG. 1 is a flowchart of a video encoding method shown in an exemplary embodiment of the present application. When the method is applied to a computer device, the computer device may be Figure 1 The sending end 111 in Figure 1 It should be understood that the method may also be applicable to other exemplary implementation environments and may be specifically executed by devices in other implementation environments, and this embodiment does not limit the implementation environment to which the method is applicable.

[0040] like Figure 2 As shown, the video encoding method at least includes steps S210 to S240, which are described in detail as follows:

[0041] Step S210: determining a coding cycle that has completed encoding before the current coding cycle, obtaining a preceding coding cycle set corresponding to the current coding cycle, and taking a preceding coding cycle in the preceding coding cycle set that is adjacent to the current coding cycle as an adjacent coding cycle.

[0042] The encoding process of the video data is divided into a plurality of encoding cycles, and each encoding cycle is executed in sequence to realize the encoding of the video data.

[0043] For the current coding cycle, the coding cycles that have completed encoding before the current coding cycle are obtained, and these coding cycles are used as the previous coding cycles corresponding to the current coding cycle to obtain a previous coding cycle set.

[0044] Specifically, a previous coding cycle adjacent to the current coding cycle in the previous coding cycle set is used as an adjacent coding cycle corresponding to the current coding cycle.

[0045] Exemplarily, the preceding coding cycle adjacent to the current coding cycle is the previous coding cycle corresponding to the current coding cycle. For example, the coding process of video data includes cycles L1, L2, L3, L4, L5..., Lm, and the above coding cycles are executed in sequence. If the current coding cycle is L5, the preceding coding cycles corresponding to the current coding cycle include L1, L2, L3 and L4, and the preceding coding cycle corresponding to the current coding cycle in the preceding coding cycle set is L4, that is, the adjacent coding cycle corresponding to the current coding cycle is L4.

[0046] Exemplarily, the preceding coding cycle adjacent to the current coding cycle includes the first n coding cycles corresponding to the current coding cycle. For example, the encoding process of the video data includes cycles L1, L2, L3, L4, L5..., Lm, and the above coding cycles are executed in sequence. If the current coding cycle is L5, n is equal to 2, then the preceding coding cycle corresponding to the current coding cycle includes L1, L2, L3 and L4, and the preceding n coding cycles corresponding to the current coding cycle in the preceding coding cycle set include L3 and L4, that is, the adjacent coding cycle corresponding to the current coding cycle includes L3 and L4. Among them, the value of n can be pre-set or flexibly calculated according to actual conditions. For example, the value of n is determined according to the number of preceding coding cycles and / or the current remaining computing power resources and / or the motion information of the current coding cycle, such as the larger the number of preceding coding cycles and / or the more current remaining computing power resources and / or the more intense the motion corresponding to the current coding cycle, the larger the value of n, and vice versa, the smaller the value of n, and n is an integer greater than or equal to 1.

[0047] Step S220: extracting the first coding feature parameter of each preceding coding cycle in the preceding coding cycle set, and extracting the second coding feature parameter corresponding to the adjacent coding cycle; wherein the first coding feature parameter and the second coding feature parameter are used to describe the execution status of the coding cycle.

[0048] The first encoding feature parameter and the second encoding feature parameter refer to relevant parameters used to describe the execution status of the encoding cycle. The first encoding feature parameter and the second encoding feature parameter include but are not limited to average encoding bit rate, encoded bits, motion information of encoded video frames, etc.

[0049] The parameter types of the first coding characteristic parameter of each preceding coding cycle and the second coding characteristic parameter corresponding to the adjacent coding cycle may be the same or different. For example, the first coding characteristic parameter includes parameter 1 and parameter 2, and the second coding characteristic parameter includes parameter 3 and parameter 4, which is not limited in this application.

[0050] It should be noted that the parameter types of the first coding characteristic parameters of each preceding coding cycle and the second coding characteristic parameters corresponding to the adjacent coding cycle can be preset or flexibly determined according to actual application conditions.

[0051] For example, according to the number of preceding coding cycles and / or the motion information of preceding coding cycles and / or the motion information of adjacent coding cycles, etc., the parameter type contained in the first coding feature parameter and the parameter type contained in the second coding feature parameter are flexibly determined to improve the flexibility and accuracy of coding. Wherein, the above-mentioned implementation method of determining the parameter type contained in the first coding feature parameter and the second coding feature parameter according to the number of preceding coding cycles and / or the motion information of preceding coding cycles and / or the motion information of adjacent coding cycles, etc., can be implemented based on a pre-trained neural network, the input of the neural network is the number of preceding coding cycles and / or the motion information of preceding coding cycles and / or the motion information of adjacent coding cycles, etc., and the output is the parameter type contained in the first coding feature parameter and the second coding feature parameter; it can also be implemented by matching based on preset rules, and the preset rules are used to store the mapping relationship between the values ​​of the number of preceding coding cycles and / or the motion information of preceding coding cycles and / or the motion information of adjacent coding cycles and the corresponding parameter types contained in the first coding feature parameter and the second coding feature parameter.

[0052] For example, the encoding process includes multiple levels of encoding cycles, and according to the level to which the current encoding cycle belongs, the parameter type contained in the first encoding feature parameter and the parameter type contained in the second encoding feature parameter are determined, and then according to the determined parameter type of the encoding feature parameter to be extracted, the first encoding feature parameter of each preceding encoding cycle in the preceding encoding cycle set is extracted, and the second encoding feature parameter corresponding to the adjacent encoding cycle is extracted. It should be noted that when the encoding process includes multiple levels of encoding cycles, the current encoding cycle, the preceding encoding cycle and the adjacent encoding cycle in this application all belong to the encoding cycle of the same level.

[0053] Another example is given, after determining the parameter type contained in the first coding feature parameter, the parameter type contained in the second coding feature parameter can be determined based on the specific parameter value of the first coding feature parameter, such as determining the parameter type contained in the second coding feature parameter by judging the preset value interval in which the specific parameter value of the first coding feature parameter is located, and different preset value intervals are associated with different parameter types. Conversely, after determining the parameter type contained in the second coding feature parameter, the parameter type contained in the first coding feature parameter can be determined based on the specific parameter value of the second coding feature parameter.

[0054] Step S230: Calculate the coding control parameters of the current coding cycle by combining the first coding feature parameters corresponding to the previous coding cycle set and the second coding feature parameters corresponding to the adjacent coding cycle.

[0055] The first coding feature parameters corresponding to the previous coding cycle set and the second coding feature parameters corresponding to the adjacent coding cycle are comprehensively considered, and the coding control parameters of the current coding cycle are calculated according to the first coding feature parameters and the second coding feature parameters.

[0056] In actual video compression encoding, various algorithms are used to reduce the data capacity. The size of the compressed video is related to the encoding control parameters selected by the encoder during the encoding process. The encoding control parameters include but are not limited to encoding bit rate, quantization parameter (QP), frame type (I / P / B frame), motion information, etc.

[0057] It should be noted that if the parameter types contained in the first coding feature parameter and the second coding feature parameter are different, and the parameter types of the coding control parameter are different, then the calculation method used to calculate the coding control parameter based on the first coding feature parameter and the second coding feature parameter is also different.

[0058] For example, the first encoding characteristic parameter contains the average encoding bit rate of each preceding encoding cycle, the second encoding characteristic parameter contains the motion information of the adjacent encoding cycle, and the encoding control parameter includes the expected encoding bit rate of the current encoding cycle. The expected encoding bit rate of the current encoding cycle can be determined based on the average encoding bit rate of each preceding encoding cycle and the motion information of the adjacent encoding cycle. For example, the larger the average encoding bit rate of each preceding encoding cycle and / or the less intense the motion indicated by the motion information of the adjacent encoding cycle, the more further compression is required for the current encoding cycle, that is, the smaller the expected encoding bit rate of the current encoding cycle; conversely, the larger the expected encoding bit rate of the current encoding cycle.

[0059] For another example, according to the first coding feature parameter of each preceding coding cycle, the parameter type and the corresponding calculation strategy of the coding feature parameter of the adjacent coding cycle to be extracted are determined, so as to extract the coding feature parameter of the adjacent coding cycle to obtain the second coding feature parameter, and calculate the second coding feature parameter according to the calculation strategy to obtain the coding control parameter of the current coding cycle. Of course, it is also possible to determine the parameter type and the corresponding calculation strategy of the coding feature parameter of each preceding coding cycle to be extracted according to the second coding feature parameter of the adjacent coding cycle.

[0060] Step S240: encoding the video data based on the encoding control parameter to obtain an encoding result corresponding to the video data.

[0061] The video data is encoded according to the encoding control parameters calculated above to obtain an encoding result. For example, the encoding control parameters include an expected encoding bit rate and a quantization parameter, and the video frame is encoded according to the quantization parameter to ensure that the actual encoding bit rate is close to the expected encoding bit rate.

[0062] By considering the coding conditions of all previous coding cycles and the coding conditions of adjacent coding cycles corresponding to the current coding cycle respectively, the flexibility and accuracy of coding control parameter calculation are improved, and a code stream with better image quality can be obtained with maximum efficiency in a certain storage space.

[0063] Next, some embodiments of the present application are described by way of example.

[0064] In some implementations, in step S230, the coding control parameters of the current coding period are calculated by combining the first coding feature parameters corresponding to the previous coding period set and the second coding feature parameters corresponding to the adjacent coding period, including:

[0065] Step S2311: Determine whether the first coding feature parameter corresponding to the previous coding period set meets the preset conditions.

[0066] For example, the first encoding feature parameter includes an average encoding bit rate, and the relationship between the average encoding bit rate and a preset encoding bit rate is determined.

[0067] For another example, the first coding feature parameter includes motion information, and it is determined whether the motion information indicates whether a previous coding period contains violent motion.

[0068] Optionally, if the encoding process includes encoding cycles of multiple levels, the preset condition for judgment may be determined according to the level to which the current encoding cycle belongs.

[0069] Step S2312: Based on the judgment result and the second coding characteristic parameter corresponding to the adjacent coding period, the coding control parameter of the current coding period is calculated.

[0070] For example, a calculation strategy for the coding control parameter is determined according to the judgment result, and the second coding feature parameter is calculated based on the calculation strategy to obtain the coding control parameter of the current coding cycle.

[0071] For another example, the coding control parameter of the current coding period is obtained by combining the judgment result and the second coding characteristic parameter corresponding to the adjacent coding period. If the coding control parameter includes the expected coding rate, the basic coding rate matching the judgment result is obtained, the rate adjustment value is calculated according to the second coding characteristic parameter corresponding to the adjacent coding period, and the basic coding rate and the rate adjustment value are summed to obtain the expected coding rate.

[0072] It is understandable that the specific implementation method of calculating the coding control parameter based on the judgment result and the second coding feature parameter corresponding to the adjacent coding period can be flexibly determined according to the actual situation, and this application does not limit this.

[0073] For example, if the encoding process includes multiple levels of encoding cycles, the specific implementation method of calculating the encoding control parameters based on the judgment result and the second encoding feature parameters corresponding to the adjacent encoding cycles can be determined according to the level to which the current encoding cycle belongs.

[0074] Some embodiments of calculating coding control parameters are described in detail with examples.

[0075] In some embodiments, assuming that the current coding cycle belongs to a long cycle, the first coding characteristic parameter includes the average coding bit rate of each previous coding cycle, the second coding characteristic parameter includes the average coding bit rate of adjacent coding cycles, the expected coding bit rate, motion information and a preset coding quality level, and the coding control parameter includes the expected coding bit rate of the long cycle.

[0076] See also Figure 3 , Figure 3 A flowchart of calculating a long-period encoding control parameter is shown as an exemplary embodiment of the present application. Figure 3 As shown, the long cycle is divided into the first long cycle and the non-first long cycle, and the step of calculating the coding control parameter of the long cycle includes:

[0077] Step S310: Determine whether the current coding cycle is the first long cycle. If the current coding cycle is the first long cycle, execute step S320; otherwise, execute steps S330 to S350.

[0078] Step S320: Determine the expected encoding bit rate corresponding to the current encoding period according to preset parameters.

[0079] Since there is no previous coding cycle in which coding has been completed before the current coding cycle, the coding control parameters corresponding to the current coding cycle may be preset.

[0080] Specifically, the expected encoding bit rate of the first long period can be calculated according to the input preset parameters, wherein the preset parameters include a preset encoding quality level and a preset encoding bit rate. The relevant formula can refer to the following formula 1:

[0081]

[0082] in, is the expected encoding bit rate of the current long period, Level is the preset encoding quality level, is the preset encoding bit rate, For arrive The mapping function of It can be a linear relationship or a nonlinear relationship. Level is greater than or equal to 0. If the preset encoding quality level is not set, the preset encoding quality level is set to 0.

[0083] For example, The specific implementation method can be found in the following formula 2:

[0084]

[0085] in, is the maximum encoding quality level, k is a preset coefficient, and k can be 0.5, 0.6, 0.7, etc.

[0086] Step S330: Determine the magnitude relationship between the average encoding bit rate of each preceding encoding period and the preset encoding bit rate.

[0087] The relationship between the average encoding bit rate of each preceding encoding cycle and the preset encoding bit rate is determined.

[0088] The preset encoding bit rate may be pre-set.

[0089] The magnitude relationship between the average encoding bit rate of each preceding encoding cycle and the preset encoding bit rate is determined to obtain a determination result.

[0090] Step S340: Calculate the code rate difference between the average coding rate of adjacent coding periods and the expected coding rate of adjacent coding periods; and determine the feedback parameter calculation strategy based on the judgment result, and calculate the preamble coding feedback parameter according to the feedback parameter calculation strategy.

[0091] The expected encoding bit rates of adjacent encoding cycles are calculated according to the above steps when executing adjacent encoding cycles.

[0092] The actual average encoding bit rate when executing adjacent encoding cycles is obtained to calculate the bit rate difference between the average encoding bit rate of the adjacent encoding cycles and the expected encoding bit rate of the adjacent encoding cycles.

[0093] Specifically, the calculation formula of the bit rate difference can refer to the following formula 3:

[0094]

[0095] Among them, diff represents the bit rate difference, represents the expected encoding bit rate of adjacent coding periods, Indicates the average encoding bit rate of adjacent coding periods.

[0096] Furthermore, a feedback parameter calculation strategy is determined based on the judgment result, and the preamble coding feedback parameter is calculated according to the feedback parameter calculation strategy.

[0097] Exemplarily, a feedback parameter calculation strategy is determined based on a judgment result, and a preamble coding feedback parameter is calculated according to the feedback parameter calculation strategy, including: if the judgment result indicates that the average encoding bit rate of each preamble coding cycle is greater than a preset encoding bit rate, the preamble coding feedback parameter is calculated using the average encoding bit rate of each preamble coding cycle and the preset encoding bit rate; if the judgment result indicates that the average encoding bit rate of each preamble coding cycle is not greater than the preset encoding bit rate, the preamble coding feedback parameter is calculated using motion information of adjacent coding cycles, a preset encoding quality level, and a bit rate difference.

[0098] That is, it can be divided into two cases:

[0099] Case 1: Average encoding bit rate of each preceding encoding cycle Greater than the preset encoding bit rate , then the feedback parameter calculation strategy is: use the average encoding bit rate of each previous encoding cycle and the preset encoding bit rate to calculate the previous encoding feedback parameter.

[0100] Specifically, the relevant formula for calculating the preamble coding feedback parameter by using the average coding rate of each preamble coding cycle and the preset coding rate can be referred to the following formula 4:

[0101]

[0102] in, is the preamble encoding feedback parameter, For arrive The mapping function of It can be a linear relationship or a nonlinear relationship.

[0103] For example, The specific implementation method can be found in the following formula 5:

[0104]

[0105] Here, m is a preset coefficient, which can be 0.5, 0.4, 0.3, etc.

[0106] Case 2: Average encoding bit rate of each preceding encoding cycle Not greater than the preset encoding bit rate , the feedback parameter calculation strategy is: use the motion information of adjacent coding cycles, the preset coding quality level and the bit rate difference to calculate the pre-order coding feedback parameters, where the motion information is used to describe the motion between video frames.

[0107] Specifically, the relevant formula for calculating the preamble coding feedback parameter using the motion information of adjacent coding periods, the preset coding quality level and the bit rate difference can be referred to in the following formula 6:

[0108]

[0109] in, is the motion information of adjacent coding cycles, Level is the preset coding quality level, and diff represents the bit rate difference. For arrive The mapping function of It can be a linear relationship or a nonlinear relationship.

[0110] For example, The specific implementation method can be found in the following formula 7:

[0111]

[0112] in, is the maximum encoding quality level, n is the adjustment parameter, , It is the preset maximum value of movement.

[0113] Based on the bit rate difference diff and motion information , determine the value of n:

[0114] like , indicating that further compression is needed, let n be equal to 1;

[0115] like , indicating that the adjacent coding period is a large motion scene, and the video quality can be further improved in subsequent coding. Let n be equal to -1;

[0116] Otherwise, set n equal to 0.

[0117] It should be noted that the above method of calculating the preamble coding feedback parameter based on the judgment result is only an exemplary description, and can be flexibly adjusted according to specific circumstances in actual application scenarios, and this application does not limit this.

[0118] Step S350: based on the previous coding feedback parameter and the bit rate difference, the expected coding bit rate of the current coding period is calculated.

[0119] Exemplarily, based on the preamble coding feedback parameter and the code rate difference, the formula for calculating the expected coding rate of the current coding period can be referred to the following formula 8:

[0120]

[0121] in, is the expected encoding bit rate of the current long period, is the preamble encoding feedback parameter, For arrive The mapping function of It can be a linear relationship or a nonlinear relationship.

[0122] For example, The specific implementation method can be found in the following formula 9:

[0123]

[0124] It should be noted that the above examples are merely illustrative and can be flexibly adjusted according to specific circumstances in actual application scenarios, and this application does not limit this.

[0125] In some embodiments, the encoding process includes a long cycle, the long cycle includes multiple short cycles, the current encoding cycle belongs to the short cycle, each previous encoding cycle corresponding to the current encoding cycle and the current encoding cycle belong to the same long cycle, the first encoding feature parameter includes the average encoding bit rate of each previous encoding cycle, the second encoding feature parameter includes the average encoding bit rate and quantization parameter and motion information of adjacent encoding cycles, and the encoding control parameter includes the quantization parameter of the short cycle.

[0126] See also Figure 4 , Figure 4 A flowchart of calculating the encoding control parameters of a short period is shown as an exemplary embodiment of the present application. Figure 4 As shown, the short cycle is divided into the first short cycle and the non-first short cycle, and the step of calculating the coding control parameter of the short cycle includes:

[0127] The steps of calculating the long-period coding control parameters include:

[0128] Step S410: Calculate an initialization quantization parameter based on a preset encoding bit rate corresponding to a long period to which the current encoding period belongs.

[0129] Specifically, based on the preset encoding rate corresponding to the long period , the image width W of the video frame, the image height H of the video frame, the frame rate fps, calculate the pixel depth BPP, and the relevant formula can be found in Formula 10:

[0130]

[0131] Then, according to the calculated pixel depth BPP and the preset coding quality level Level, the quantization parameter of the current coding cycle is initialized. The relevant formulas can be found in Formula 11 and Formula 12:

[0132] Formula 11:

[0133] Formula 12:

[0134] in, is the minimum value of the basic quantization parameter, is the maximum value of the basic quantization parameter, It can be a linear relationship or a nonlinear relationship.

[0135] For example, The specific implementation method can refer to the following formula 13 and formula 14:

[0136] Formula 13:

[0137] Formula 14:

[0138] in, The maximum encoding quality level.

[0139] Step S420: Determine whether the current coding cycle is the first short cycle of the first long cycle. If the current coding cycle is the first short cycle of the first long cycle, execute step S430; otherwise, execute step S440.

[0140] Step S430: using the initialized quantization parameter as the quantization parameter of the current encoding cycle.

[0141] The quantization parameters of the current encoding cycle include the minimum quantization parameter and the maximum value of the quantization parameter ,but , .

[0142] Step S440: Obtain the expected encoding bit rate corresponding to the long period to which the current encoding period belongs.

[0143] Step S450: Determine whether the average encoding bit rate of each preceding encoding cycle is greater than the expected encoding bit rate of the long cycle; if the average encoding bit rate of each preceding encoding cycle is greater than the expected encoding bit rate of the long cycle, execute step S460; if the average encoding bit rate of each preceding encoding cycle is not greater than the expected encoding bit rate of the long cycle, execute step S470.

[0144] Exemplarily, the average encoding bit rate of each preceding encoding cycle is calculated The formula can be found in the following formula 15:

[0145]

[0146] Among them, is the total number of bits encoded in the long period , that is, the total number of bits encoded in each previous coding cycle corresponding to the current coding cycle, is the encoded time in the long cycle , that is, the encoded time of each previous encoding cycle corresponding to the current encoding cycle.

[0147] Determine the average encoding bit rate Expected encoding rate with long period The size relationship between them.

[0148] like , it indicates that the current encoding has a bit rate overflow, and step S460 is executed; if , it indicates that there is no bit rate overflow in the current encoding, and step S470 is executed.

[0149] Step S460: Calculate the quantization parameter of the current coding cycle using the average coding rate and quantization parameter of adjacent coding cycles.

[0150] When the current encoding has bit rate overflow, it is necessary to avoid the problem of poor video quality caused by excessive bit rate reduction, and it is also necessary to control the bit rate overflow.

[0151] The quantization parameter of the current coding cycle is calculated according to the average coding bit rate of the adjacent coding cycles and the quantization parameters of the adjacent coding cycles.

[0152] Of course, other information may be further comprehensively considered to calculate the quantization parameter of the current encoding cycle.

[0153] For example, first, according to the preset encoding quality level Level and the encoded time in the long period to which the current encoding period belongs, , calculate the downward adjustment ratio , the ratio can be adjusted down The calculation formula can be found in the following formula 16:

[0154]

[0155] in, It can be a linear relationship or a nonlinear relationship.

[0156] For example, The specific implementation method can be found in the following formula 17:

[0157]

[0158] in, Total encoding time for long period preset.

[0159] Get the adjustable ratio Then, the average coding rate of adjacent coding cycles is combined , quantization parameters of adjacent coding cycles And the ratio can be adjusted downward , calculate the minimum value of the quantization parameter of the current encoding cycle and the maximum value of the quantization parameter , the relevant formulas can be found in the following formulas 18 and 19:

[0160] Formula 18:

[0161] Formula 19:

[0162] in, It can be a linear relationship or a nonlinear relationship.

[0163] For example, The specific implementation method can refer to the following formula 20 and formula 21:

[0164] Formula 20:

[0165] Formula 21:

[0166] in, The calculation formula can be found in the following formula 22:

[0167]

[0168] Step S470: Calculate the quantization parameter of the current coding period using the average coding rate and motion information of adjacent coding periods.

[0169] When there is no code rate overflow in the current encoding, the quantization parameter of the current encoding period is calculated using the average encoding code rate and motion information of adjacent encoding periods.

[0170] Exemplarily, a target bit rate interval and a basic quantization parameter corresponding to a current coding cycle are obtained; if the average coding bit rate of adjacent coding cycles is within the target bit rate interval, a quantization parameter adjustment value is determined based on motion information of adjacent coding cycles; if the average coding bit rate of adjacent coding cycles is greater than the maximum value of the target bit rate interval, the quantization parameter adjustment value is determined to be a first adjustment value; if the average coding bit rate of adjacent coding cycles is less than the minimum value of the target bit rate interval, the quantization parameter adjustment value is determined to be a second adjustment value; and the basic quantization parameter is adjusted based on the quantization parameter adjustment value to obtain the quantization parameter of the current coding cycle.

[0171] Specifically, the upper and lower bit rate limits of the short period are calculated, and the target bit rate range corresponding to the current coding period is obtained based on the upper and lower bit rate limits.

[0172] For example, obtain the preamble coding feedback parameters of the long cycle to which the current coding cycle belongs , and obtain the preset short-period basic bit rate upper limit , to encode the feedback parameters according to the previous order and basic bitrate cap , the upper and lower limits of the bit rate of the short period are calculated. The calculation formulas can be found in the following formulas 23 and 24:

[0173] Formula 23:

[0174] Formula 24:

[0175] in, is the upper limit of the bit rate for a short period, is the lower limit of the code rate for a short period, It can be a linear relationship or a nonlinear relationship.

[0176] For example, The specific implementation method can refer to the following formula 25 and formula 26:

[0177] Formula 25:

[0178] Formula 26:

[0179] Then, based on the bit rate upper limit and bit rate lower limit, the target bit rate range corresponding to the current encoding period is obtained. For example, the target bit rate range is , and is a floating threshold, and are both greater than or equal to 0 and less than or equal to 1.

[0180] In addition, let the quantization parameters of adjacent coding cycles be The basic quantization parameter, of course, the basic quantization parameter may also be other values, such as the basic quantization parameter may also be an initialization quantization parameter, which is not limited in this application.

[0181] If the average encoding rate of adjacent encoding cycles is greater than the maximum value of the target rate interval, that is, , then determine that the quantization parameter adjustment value is the first adjustment value, and according to the first adjustment value and the quantization parameter of the adjacent coding cycle , get the quantization parameter of the current encoding cycle, the relevant formulas refer to Formula 27 and Formula 28:

[0182] Formula 27:

[0183] Formula 28:

[0184] in, is the preset first adjustment value, Both are greater than 0.

[0185] If the average encoding rate of adjacent encoding cycles is less than the minimum value of the target rate interval, that is, , then determine the quantization parameter adjustment value to be the second adjustment value, and according to the second adjustment value and the quantization parameter of the adjacent coding cycle , get the quantization parameter of the current encoding cycle, the relevant formulas refer to formula 29 and formula 30:

[0186] Formula 29:

[0187] Formula 30:

[0188] in, is the preset second adjustment value, Both are greater than 0.

[0189] If the average encoding bit rate of adjacent encoding cycles is within the target bit rate range, that is, , the quantization parameter adjustment value is determined according to the motion information of the adjacent coding periods.

[0190] For example, suppose the motion information of each video frame in adjacent coding cycles is , The larger the value, the more intense the motion of the video frame, and the motion information of adjacent coding cycles The calculation formula can be found in the following formula 31:

[0191]

[0192] in, Indicates the number of video frames in adjacent encoding cycles.

[0193] like If it is greater than the large motion threshold, it indicates that there is large motion, and the quantization parameter adjustment value is determined to be the third adjustment value. The formula of the quantization parameter of the current coding period can refer to the following formula 32 and formula 33:

[0194] Formula 32:

[0195] Formula 33:

[0196] in, is the preset third adjustment value, Both are greater than 0.

[0197] like is less than the small motion threshold, indicating that the current scene has small motion, the small motion threshold is less than the large motion threshold, and the quantization parameter adjustment value is determined to be the fourth adjustment value. The formula of the quantization parameter of the current coding period can refer to the following formula 34 and formula 35:

[0198] Formula 34:

[0199] Formula 35:

[0200] in, is the preset third adjustment value, Both are greater than 0.

[0201] Otherwise, the basic quantization parameter is not adjusted, that is, the basic quantization parameter is directly used as the quantization parameter of the current encoding cycle.

[0202] It should be noted that the above examples are merely illustrative and can be flexibly adjusted according to specific circumstances in actual application scenarios, and this application does not limit this.

[0203] In some embodiments, the coding control parameters also include a motion gain amplitude of a short period; based on the judgment result and the second coding feature parameter corresponding to the adjacent coding period, the coding control parameters of the current coding period are calculated, including: if the judgment result indicates that the average coding bit rate of each previous coding period is greater than the expected coding bit rate of the long period, the motion gain amplitude of the current coding period is set to a first preset value; if the judgment result indicates that the average coding bit rate of each previous coding period is not greater than the expected coding bit rate of the long period, based on the average coding bit rate of each previous coding period, the expected coding bit rate of the long period and the preset coding quality level, the motion gain amplitude of the current coding period is calculated.

[0204] Adjust the motion gain amplitude of the current encoding cycle according to the encoding situation of the previous encoding cycle , specifically including the following two situations:

[0205] Case 1: When the average encoding rate of each previous encoding cycle is greater than the expected encoding rate of the long cycle, that is, when there is a rate overflow in the encoded cycle, the motion gain amplitude of the current encoding cycle is increased. Set to 0.

[0206] Case 2: The average encoding bit rate of each previous encoding cycle is not greater than the expected encoding bit rate of the long cycle, that is, there is currently a bit rate surplus. Then, the motion gain amplitude of the current encoding cycle is calculated based on the average encoding bit rate of each previous encoding cycle, the expected encoding bit rate of the long cycle and the preset encoding quality level.

[0207] Example: Based on the average encoding rate of the previous encoding cycle Expected encoding rate with long period Calculate the current profit ratio , the calculation formula can be found in the following formula 36:

[0208]

[0209] Then, according to the profit ratio Calculate the motion gain amplitude of the current encoding cycle with the quality level Level , the calculation can refer to the following formula 37:

[0210]

[0211] in, It can be a linear relationship or a nonlinear relationship.

[0212] For example, The specific implementation method can be found in the following formula 38:

[0213]

[0214] The encoding control parameters such as the short-period quantization parameter, the bit rate upper limit, the bit rate lower limit, and the motion gain amplitude are calculated through the above-mentioned embodiments.

[0215] Of course, in addition to the coding control parameter calculation method exemplified in the above embodiment, other calculation methods can also be used to calculate the coding control parameters. For example, the first coding feature parameter and the second coding feature parameter are substituted into a preset calculation formula to obtain the coding control parameter of the current coding cycle.

[0216] In some embodiments, the encoding process includes a long cycle, the long cycle includes multiple short cycles, the short cycle includes multiple video frame cycles, the current encoding cycle belongs to the video frame cycle, each previous encoding cycle corresponding to the current encoding cycle and the current encoding cycle belong to the same short cycle, the first encoding feature parameter includes the encoded bits and the number of encoded frames of the previous encoding cycle set, the second encoding feature parameter includes the encoded bits and quantization parameters of adjacent encoding cycles, and the encoding control parameters include the quantization parameters of the video frame cycle.

[0217] Exemplarily, in step S230, the coding control parameters of the current coding period are calculated by combining the first coding feature parameters corresponding to the previous coding period set and the second coding feature parameters corresponding to the adjacent coding period, including:

[0218] Step S2321: Based on the coded bits and the number of coded frames corresponding to the previous coding period set, the maximum bit per frame is calculated.

[0219] The maximum bit per frame is calculated based on the coded bits and the number of coded frames corresponding to the preceding coding period set. Of course, other parameters may be further considered to calculate the maximum bit per frame.

[0220] For example, the coded bits corresponding to the previous coding period set are the coded bits in the current short period. , the number of encoded frames corresponding to the previous encoding period set is the number of encoded frames in the current short period , which can be combined with the coded bits , Number of encoded frames , adjacent video frame coding bits , short period maximum bit rate , short cycle encoded time , total number of frames in short period , calculate the maximum bit per frame , the calculation formula can be found in the following formula 39:

[0221]

[0222] It should be noted that the above examples are merely illustrative and can be flexibly adjusted according to specific circumstances in actual application scenarios, and this application does not limit this.

[0223] Step S2322: Based on the encoded bits of the adjacent coding periods, the quantization parameter and the maximum bits per frame, the quantization parameter of the current coding period is calculated.

[0224] The quantization parameter of the current coding period is calculated based on the encoded bits, quantization parameter and maximum bits per frame of the adjacent coding periods. Of course, the quantization parameter of the current coding period can be calculated by further comprehensively considering other parameters.

[0225] Exemplarily, based on the encoded bits of adjacent coding periods, the quantization parameter and the maximum bits per frame, the quantization parameter of the current coding period is calculated, including: obtaining the motion gain amplitude corresponding to the short period to which the current coding period belongs; based on the motion gain amplitude, the encoded bits of adjacent coding periods, the quantization parameter and the maximum bits per frame, the quantization parameter of the current coding period is calculated.

[0226] Specifically, see Figure 5 , Figure 5 A flowchart showing a method for calculating encoding control parameters of a video frame period according to an exemplary embodiment of the present application is shown as follows: Figure 5 As shown, including:

[0227] Step S510: Calculate the frame-level motion quality based on the motion gain amplitude corresponding to the short period to which the current encoding period belongs.

[0228] Step S520: Based on the second coding feature parameter of the adjacent coding period and the frame-level motion quality, a quantization parameter of the current coding period is calculated.

[0229] For example, based on the coded bits of adjacent coding periods , Maximum bits per frame , frame-level motion quality , calculate the basic quantization parameters of the video frame period and .

[0230] The frame-level motion quality is calculated based on the motion gain amplitude. The calculation formula can be found in the following formula 40:

[0231]

[0232] in, It can be a linear relationship or a nonlinear relationship.

[0233] For example, The specific implementation method can refer to the following formula 41:

[0234]

[0235] in, It is the frame-level motion quality of the previous cycle, and the frame-level motion quality is updated in real time according to the motion gain amplitude.

[0236] Further, the basic quantization parameters of the video frame period are calculated and , its calculation formula can be found in the following formula 42 and formula 43:

[0237] Formula 42:

[0238] Formula 43:

[0239] in, It can be a linear relationship or a nonlinear relationship.

[0240] For example, according to the coded bits of adjacent coding periods Maximum bits per frame The size relationship between them and the value of frame-level motion quality determine the calculation strategy of the basic quantization parameters.

[0241] For example, if , then set .

[0242] like ,and , the calculation method of the basic quantization parameter can refer to the following formula 44 and formula 45:

[0243] Formula 44:

[0244] Formula 45:

[0245] Among them, Quality is the preset motion quality.

[0246] like ,and , the calculation method of the basic quantization parameter can refer to the following formula 46 and formula 47:

[0247] Formula 46:

[0248] Formula 47:

[0249] Then, according to the basic quantization parameter, the quantization parameter of the adjacent coding cycle , calculate the quantization parameter of the current encoding cycle , the calculation formula can refer to the following formula 48 and formula 49:

[0250] Formula 48:

[0251] Formula 49:

[0252] in, It can be a linear relationship or a nonlinear relationship.

[0253] For example, The specific implementation method can refer to the following formula 50 and formula 51:

[0254] Formula 50:

[0255] Formula 51:

[0256] The quantization parameter of the video frame period is calculated through the above embodiment.

[0257] It should be noted that the above examples are merely illustrative and can be flexibly adjusted according to specific circumstances in actual application scenarios, and this application does not limit this.

[0258] In the above method, by dividing the coding cycle into multiple levels and calculating the coding control parameters layer by layer, the problem of poor video quality caused by excessive use of the early bit rate and insufficient subsequent bit rate can be effectively avoided. The coding control parameters are calculated based on motion information to ensure the video quality in motion scenes.

[0259] The encoding control parameters of each encoding period obtained by the above calculation are combined to encode the video data to obtain an encoding result corresponding to the video data.

[0260] The video encoding method provided by the present application determines the encoding cycle that has completed encoding before the current encoding cycle, obtains the previous encoding cycle set corresponding to the current encoding cycle, and takes the previous encoding cycle adjacent to the current encoding cycle in the previous encoding cycle set as the adjacent encoding cycle; extracts the first encoding feature parameter of each previous encoding cycle in the previous encoding cycle set, and extracts the second encoding feature parameter corresponding to the adjacent encoding cycle; wherein the first encoding feature parameter and the second encoding feature parameter are used to describe the execution status of the encoding cycle; combines the first encoding feature parameter corresponding to the previous encoding cycle set and the second encoding feature parameter corresponding to the adjacent encoding cycle to calculate the encoding control parameter of the current encoding cycle; encodes the video data based on the encoding control parameter to obtain the encoding result corresponding to the video data, which can comprehensively consider the encoding status of all previous encoding cycles corresponding to the current encoding cycle and the encoding status of the adjacent encoding cycles, so that the bit rate allocation is more reasonable, the flexibility and accuracy of the calculation of the encoding control parameter are improved, and the bit stream with better image quality can be obtained with the maximum efficiency in a storage space of a certain capacity.

[0261] Figure 6 FIG. 1 is a block diagram of a video encoding device shown in an exemplary embodiment of the present application. Figure 6 As shown, the exemplary video encoding device 600 includes: a period determination module 610, a coding feature extraction module 620, a control parameter calculation module 630 and a coding processing module 640. Specifically:

[0262] The cycle determination module 610 is used to determine the coding cycle that has completed encoding before the current coding cycle, obtain a set of preceding coding cycles corresponding to the current coding cycle, and take the preceding coding cycle in the preceding coding cycle set that is adjacent to the current coding cycle as an adjacent coding cycle;

[0263] A coding feature extraction module 620 is used to extract a first coding feature parameter of each preceding coding cycle in a preceding coding cycle set, and to extract a second coding feature parameter corresponding to an adjacent coding cycle; wherein the first coding feature parameter and the second coding feature parameter are used to describe the execution status of the coding cycle;

[0264] A control parameter calculation module 630 is used to calculate the coding control parameter of the current coding period by combining the first coding characteristic parameter corresponding to the previous coding period set and the second coding characteristic parameter corresponding to the adjacent coding period;

[0265] The encoding processing module 640 is used to perform encoding processing on the video data based on the encoding control parameters to obtain an encoding result corresponding to the video data.

[0266] It should be noted that the video encoding device provided in the above embodiment and the video encoding method provided in the above embodiment belong to the same concept, wherein the specific manner in which each module and unit performs the operation has been described in detail in the method embodiment, and will not be repeated here. In practical applications, the video encoding device provided in the above embodiment can distribute the above functions to different functional modules as needed, that is, divide the internal structure of the device into different functional modules to complete all or part of the functions described above, and this is not limited here.

[0267] See also Figure 7 , Figure 7 7 is a schematic diagram of the structure of an embodiment of an electronic device of the present application. The electronic device 700 includes a memory 701 and a processor 702, and the processor 702 is used to execute program instructions stored in the memory 701 to implement the steps in any of the above-mentioned video encoding method embodiments. In a specific implementation scenario, the electronic device 700 may include but is not limited to: a microcomputer, a server, and in addition, the electronic device 700 may also include a mobile device such as a laptop computer and a tablet computer, which is not limited here.

[0268] Specifically, the processor 702 is used to control itself and the memory 701 to implement the steps in any of the above-mentioned video encoding method embodiments. The processor 702 can also be called a central processing unit (CPU). The processor 702 may be an integrated circuit chip with signal processing capabilities. The processor 702 can also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. In addition, the processor 702 can be implemented by an integrated circuit chip.

[0269] See also Figure 8 , Figure 8 The computer-readable storage medium 800 stores program instructions 810 that can be executed by a processor, and the program instructions 810 are used to implement the steps in any of the above-mentioned video encoding method embodiments.

[0270] In some embodiments, the functions or modules included in the device provided by the embodiments of the present disclosure can be used to execute the method described in the above method embodiments. The specific implementation can refer to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.

[0271] The above description of various embodiments tends to emphasize the differences between the various embodiments. The same or similar aspects can be referenced to each other, and for the sake of brevity, they will not be repeated herein.

[0272] In the several embodiments provided in the present application, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device implementation described above is only schematic. For example, the division of modules or units is only a logical function division. There may be other division methods in actual implementation, such as units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.

[0273] In addition, each functional unit in each embodiment of the present application can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of a software functional unit. If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or part of the contribution to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (processor) to perform all or part of the steps of each implementation method of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), disk or optical disk and other media that can store program code.

Claims

1. A video encoding method, characterized in that: The encoding process includes multiple encoding cycles, and the method includes: Determine a coding cycle that has completed encoding before a current coding cycle, obtain a preceding coding cycle set corresponding to the current coding cycle, and use a preceding coding cycle in the preceding coding cycle set that is adjacent to the current coding cycle as an adjacent coding cycle; Extracting a first coding feature parameter of each preceding coding cycle in the preceding coding cycle set; determining a parameter type of a coding feature parameter of an adjacent coding cycle to be extracted according to a parameter value of the first coding feature parameter of each preceding coding cycle in the preceding coding cycle set, so as to extract a second coding feature parameter from the adjacent coding cycle; wherein the first coding feature parameter and the second coding feature parameter are used to describe the execution status of the coding cycle; Combining the first coding characteristic parameter of each preceding coding period in the preceding coding period set and the second coding characteristic parameter corresponding to the adjacent coding period, the coding control parameter of the current coding period is calculated; The video data is encoded based on the encoding control parameters to obtain an encoding result corresponding to the video data.

2. The method according to claim 1, characterized in that The encoding process includes multiple levels of encoding cycles; the extracting the first encoding feature parameter of each preceding encoding cycle in the preceding encoding cycle set includes: Based on the level to which the current coding cycle belongs, a first coding feature parameter of each preceding coding cycle in the preceding coding cycle set is extracted.

3. The method according to claim 1, characterized in that The step of calculating the coding control parameter of the current coding period by combining the first coding feature parameter corresponding to the previous coding period set and the second coding feature parameter corresponding to the adjacent coding period comprises: Determining whether the first coding feature parameter corresponding to the preceding coding period set meets a preset condition; Based on the judgment result and the second coding characteristic parameter corresponding to the adjacent coding period, the coding control parameter of the current coding period is calculated.

4. The method according to claim 3, characterized in that The current coding cycle belongs to a long cycle, the first coding characteristic parameter includes the average coding rate of each previous coding cycle, the second coding characteristic parameter includes the average coding rate and the expected coding rate of the adjacent coding cycles, and the coding control parameter includes the expected coding rate of the long cycle; The determining whether the first coding feature parameter corresponding to the preceding coding period set meets a preset condition includes: Determine the magnitude relationship between the average encoding bit rate of each preceding encoding period and a preset encoding bit rate; The calculating and obtaining the coding control parameter of the current coding period based on the judgment result and the second coding characteristic parameter corresponding to the adjacent coding period includes: Calculating a code rate difference between an average coding code rate of the adjacent coding periods and an expected coding code rate of the adjacent coding periods; and determining a feedback parameter calculation strategy based on the judgment result, and calculating a preamble coding feedback parameter according to the feedback parameter calculation strategy; Based on the preamble coding feedback parameter and the code rate difference, an expected coding code rate of the current coding period is calculated.

5. The method according to claim 4, characterized in that The second coding feature parameter also includes motion information of the adjacent coding period; the feedback parameter calculation strategy is determined based on the judgment result, and the preamble coding feedback parameter is calculated according to the feedback parameter calculation strategy, including: If the judgment result indicates that the average encoding bit rate of each preceding encoding cycle is greater than the preset encoding bit rate, the preceding encoding feedback parameter is calculated using the average encoding bit rate of each preceding encoding cycle and the preset encoding bit rate; If the judgment result indicates that the average encoding bit rate of each preceding encoding period is not greater than the preset encoding bit rate, the preceding encoding feedback parameter is calculated using the motion information of adjacent encoding periods and the bit rate difference.

6. The method according to claim 3, characterized in that The encoding process includes a long cycle, the long cycle includes multiple short cycles, the current encoding cycle belongs to a short cycle, each previous encoding cycle corresponding to the current encoding cycle and the current encoding cycle belong to the same long cycle, the first encoding feature parameter includes an average encoding bit rate of each previous encoding cycle, the second encoding feature parameter includes an average encoding bit rate and a quantization parameter and motion information of adjacent encoding cycles, and the encoding control parameter includes a quantization parameter of the short cycle; The determining whether the first coding feature parameter corresponding to the preceding coding period set meets a preset condition includes: Obtaining an expected encoding bit rate corresponding to the long period to which the current encoding period belongs; Determine the magnitude relationship between the average encoding bit rate of each preceding encoding period and the expected encoding bit rate of the long period; The calculating and obtaining the coding control parameter of the current coding period based on the judgment result and the second coding characteristic parameter corresponding to the adjacent coding period includes: If the judgment result indicates that the average encoding bit rate of each preceding encoding cycle is greater than the expected encoding bit rate of the long cycle, the quantization parameter of the current encoding cycle is calculated using the average encoding bit rate and quantization parameter of the adjacent encoding cycles; If the judgment result indicates that the average encoding bit rate of each preceding encoding cycle is not greater than the expected encoding bit rate of the long cycle, the quantization parameter of the current encoding cycle is calculated using the average encoding bit rate and motion information of the adjacent encoding cycles.

7. The method according to claim 6, characterized in that If the judgment result indicates that the average encoding rate of each preceding encoding cycle is greater than the expected encoding rate of the long cycle, the quantization parameter of the current encoding cycle is calculated by using the average encoding rate and quantization parameter of the adjacent encoding cycles, including: Detecting the encoded time and the preset encoding quality level corresponding to the long period to which the current encoding period belongs; Based on the encoded time and the preset encoding quality level, a down-adjustable ratio is calculated; The quantization parameter of the current coding cycle is calculated by combining the average coding rate and quantization parameter of the adjacent coding cycles and the adjustable down ratio.

8. The method according to claim 6, characterized in that If the judgment result indicates that the average encoding bit rate of each preceding encoding cycle is not greater than the expected encoding bit rate of the long cycle, the average encoding bit rate and motion information of the adjacent encoding cycles are used to calculate the quantization parameter of the current encoding cycle, including: Obtaining a target bit rate interval and a basic quantization parameter corresponding to the current encoding period; If the average encoding bit rate of the adjacent encoding periods is within the target bit rate range, determining a quantization parameter adjustment value according to motion information of the adjacent encoding periods; If the average encoding bit rate of the adjacent encoding periods is greater than the maximum value of the target bit rate interval, determining the quantization parameter adjustment value to be a first adjustment value; If the average encoding bit rate of the adjacent encoding periods is less than the minimum value of the target bit rate interval, determining the quantization parameter adjustment value to be a second adjustment value; The basic quantization parameter is adjusted based on the quantization parameter adjustment value to obtain the quantization parameter of the current encoding cycle.

9. The method according to claim 6, characterized in that The coding control parameter also includes the motion gain amplitude of the short cycle; the coding control parameter of the current coding cycle is calculated based on the judgment result and the second coding feature parameter corresponding to the adjacent coding cycle, including: If the judgment result indicates that the average encoding bit rate of each preceding encoding cycle is greater than the expected encoding bit rate of the long cycle, setting the motion gain amplitude of the current encoding cycle to a first preset value; If the judgment result indicates that the average encoding bit rate of each previous encoding cycle is not greater than the expected encoding bit rate of the long cycle, the motion gain amplitude of the current encoding cycle is calculated based on the average encoding bit rate of each previous encoding cycle, the expected encoding bit rate of the long cycle and the preset encoding quality level.

10. The method according to claim 1, characterized in that The encoding process includes a long cycle, the long cycle includes multiple short cycles, the short cycle includes multiple video frame cycles, the current encoding cycle belongs to the video frame cycle, each previous encoding cycle corresponding to the current encoding cycle and the current encoding cycle belong to the same short cycle, the first encoding feature parameter includes the encoded bits and the number of encoded frames of the previous encoding cycle set, the second encoding feature parameter includes the encoded bits and quantization parameters of the adjacent encoding cycle, and the encoding control parameter includes the quantization parameter of the video frame cycle; the encoding control parameter of the current encoding cycle is calculated by combining the first encoding feature parameter corresponding to the previous encoding cycle set and the second encoding feature parameter corresponding to the adjacent encoding cycle, including: Calculate the maximum bit per frame based on the encoded bits and the number of encoded frames corresponding to the preceding encoding period set; The quantization parameter of the current coding period is calculated based on the encoded bits of the adjacent coding period, the quantization parameter and the maximum bits per frame.

11. The method according to claim 10, characterized in that The calculating the quantization parameter of the current coding period based on the encoded bits of the adjacent coding period, the quantization parameter and the maximum bit per frame includes: Obtaining a motion gain amplitude corresponding to a short period to which the current encoding period belongs; The quantization parameter of the current coding period is calculated based on the motion gain amplitude, the encoded bits of the adjacent coding period, the quantization parameter and the maximum bit per frame.

Citation Information

Patent Citations

  • Code stream control method and device

    CN102724490A

  • Video code rate control method and video coding device

    CN106331704A

  • Video data storage method and system and video access method and node

    CN108076317A

  • Code rate control method and code rate control device

    CN108235016A

  • Mobile terminal video stream code rate self-adaptive adjustment method based on variable period sampling

    CN112532985A