Video bitrate adjustment method, apparatus and device

By dynamically adjusting the average quantization parameter of the video encoding window and adjusting the bitrate according to the video scene, the problems of unclear image quality and wasted bandwidth resources caused by fixed bitrate are solved, achieving efficient bandwidth utilization and improved user experience in different scenarios.

CN116208771BActive Publication Date: 2026-03-24ALIBABA (CHINA) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-28
Publication Date
2026-03-24

AI Technical Summary

Technical Problem

The use of fixed bitrates in existing video encoding technologies results in insufficient image quality and poor user experience when video scenes are complex, while it leads to wasted bandwidth resources and increased bandwidth costs when video scenes are simple.

Method used

By dynamically adjusting the average quantization parameter of the video encoding window, the bitrate is dynamically adjusted according to the complexity of the video scene. The bitrate is increased when the scene is complex and decreased when the scene is simple, so as to ensure image quality and save bandwidth.

Benefits of technology

It enables dynamic bitrate adjustment in different video scenarios, improving the user viewing experience and saving bandwidth resources, thus reducing bandwidth costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116208771B_ABST
    Figure CN116208771B_ABST
Patent Text Reader

Abstract

The embodiment of the application provides a video code rate adjustment method, device and equipment, the method comprises the following steps: an electronic device determines an average quantization parameter corresponding to a preset coding window; when the average quantization parameter of the preset coding window is greater than a first threshold value, the electronic device determines that the current video scene is relatively complex, the coding code rate of the preset coding window is relatively low, the video quality is poor, and the target frame is directly encoded according to a higher preset initial code rate, which can quickly adapt to the change of the video scene, quickly improve the video quality, and improve the video watching experience of the user; when the average quantization parameter of each preset coding window in the first number of continuous preset coding windows is less than a second threshold value, the electronic device can determine that the current video scene is relatively simple, the coding code rate of the preset coding window is relatively high, the overall quality is relatively high, and there is waste of code rate, and the target frame can be encoded according to a lower target code rate, which can save bandwidth resources and reduce bandwidth cost.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer, in particular to a video code rate adjusting method, device and equipment. BACKGROUND

[0002] With the continuous development of Internet technology, multimedia technology has been widely applied in various fields, such as video playing, network live streaming, etc. In the process of video stream generation and transmission, video encoding processing is usually required.

[0003] In the related art, when encoding a video, an electronic device usually adopts a fixed code rate for encoding. Such an encoding manner is prone to cause waste of bandwidth resources, increase bandwidth cost when the video scene is relatively simple, and cause unclear video quality, and poor user viewing experience when the video scene is relatively complex. SUMMARY

[0004] Aspects of the present application provide a video code rate adjusting method, device and equipment to save bandwidth resources, reduce bandwidth cost, ensure clear video quality, and improve user viewing experience.

[0005] In a first aspect, an embodiment of the present application provides a video code rate adjusting method, comprising:

[0006] determining an average quantization parameter corresponding to a preset encoding window;

[0007] if the average quantization parameter is greater than a first threshold, encoding a target frame according to a preset initial code rate;

[0008] if the average quantization parameter of each of the preset encoding windows is less than a second threshold in a continuous first number of preset encoding windows, obtaining a target code rate by reducing the preset initial code rate, and encoding the target frame according to the target code rate.

[0009] In a possible implementation, the determining of the average quantization parameter corresponding to the preset encoding window comprises:

[0010] determining a frame quantization parameter of each historical frame in the preset encoding window; each of the preset encoding windows includes a second number of historical frames;

[0011] determining the average quantization parameter corresponding to the preset encoding window according to the frame quantization parameter of each historical frame.

[0012] In a possible implementation, the determining of the frame quantization parameter of each historical frame in the preset encoding window comprises:

[0013] For each historical frame, after encoding the historical frame, the bitstream of a preset length in the historical frame is decoded to obtain the frame quantization parameters corresponding to the historical frame.

[0014] In one possible implementation, the step of encoding the target frame according to a preset initial bitrate if the average quantization parameter is greater than a first threshold includes:

[0015] If the average quantization parameter of the preset encoding window is greater than the first threshold, it is determined that the historical encoding bitrate of the preset encoding window is lower than the preset initial bitrate.

[0016] The target frame is encoded according to the preset initial bitrate.

[0017] In one possible implementation, reducing the preset initial bitrate to obtain the target bitrate includes:

[0018] The target bitrate is determined based on the preset initial bitrate, the preset change amount, and the preset minimum bitrate value.

[0019] In one possible implementation, determining the target bitrate based on the preset initial bitrate, the preset change amount, and the preset minimum bitrate value includes:

[0020] The preset initial bitrate is reduced by a preset change amount to obtain the alternative bitrate;

[0021] If the candidate bitrate is less than the preset minimum bitrate value, then the preset minimum bitrate value is used as the target bitrate.

[0022] If the candidate bitrate is greater than or equal to the preset minimum bitrate value, then the candidate bitrate is used as the target bitrate.

[0023] In one possible implementation, the step of reducing the preset initial bitrate to obtain the target bitrate if the average quantization parameter of each of the first number of consecutive preset encoding windows is less than a second threshold includes:

[0024] For a first consecutive number of preset coding windows, if the average quantization parameter of each preset coding window is less than a second threshold, it is determined that the historical coding bitrate of the first consecutive number of preset coding windows is higher than a preset minimum bitrate value.

[0025] The target bitrate is obtained by reducing the initial bitrate.

[0026] In one possible implementation, the step of reducing the preset initial bitrate to obtain the target bitrate if the average quantization parameter of each of the first number of consecutive preset encoding windows is less than a second threshold includes:

[0027] determining a maximum quantization parameter corresponding to the preset coding window;

[0028] if the average quantization parameter of each of the preset coding windows in the first number of continuous preset coding windows is less than the second threshold value, and the maximum quantization parameter of each of the preset coding windows is less than the third threshold value, reducing the preset initial code rate to obtain a target code rate.

[0029] In a possible implementation, the third threshold value is determined according to the second threshold value and a preset offset.

[0030] In a second aspect, an embodiment of the present application provides a video code rate adjustment method, comprising:

[0031] in response to an input operation of a user on a preset control, determining a picture quality level corresponding to the input operation, and determining a picture quality parameter according to the picture quality level; the picture quality parameter comprises a first number of preset coding windows, a preset initial code rate, a first threshold value corresponding to an average quantization parameter, and a second threshold value corresponding to the average quantization parameter;

[0032] In a video encoding process, determining an average quantization parameter corresponding to a preset coding window;

[0033] if the average quantization parameter is greater than the first threshold value, encoding a target frame according to a preset initial code rate;

[0034] if the average quantization parameter of each of the preset coding windows in the first number of continuous preset coding windows is less than the second threshold value, reducing the preset initial code rate to obtain a target code rate, and encoding the target frame according to the target code rate.

[0035] In a third aspect, an embodiment of the present application provides a video code rate adjustment device, comprising:

[0036] a determining module configured to determine an average quantization parameter corresponding to a preset coding window;

[0037] a first encoding module configured to, if the average quantization parameter is greater than the first threshold value, encode a target frame according to a preset initial code rate;

[0038] a second encoding module configured to, if the average quantization parameter of each of the preset coding windows in the first number of continuous preset coding windows is less than the second threshold value, reduce the preset initial code rate to obtain a target code rate, and encode the target frame according to the target code rate.

[0039] In a possible implementation, the determining module is specifically configured to:

[0040] determining a frame quantization parameter of each historical frame in the preset coding window; each of the preset coding windows includes a second number of historical frames;

[0041] determining an average quantization parameter corresponding to the preset coding window according to the frame quantization parameters of the historical frames.

[0042] In a possible implementation, the determining module is specifically configured to:

[0043] decoding a preset length of code stream in each historical frame to obtain a frame quantization parameter corresponding to the historical frame after encoding of the historical frame is completed.

[0044] In a possible implementation, the first encoding module is specifically configured to:

[0045] if the average quantization parameter of the preset coding window is greater than a first threshold value, determining that a historical coding rate of the preset coding window is lower than the preset initial rate;

[0046] encoding the target frame according to the preset initial rate.

[0047] In a possible implementation, the second encoding module is specifically configured to:

[0048] determining the target rate according to the preset initial rate, a preset variation and a preset minimum rate value.

[0049] In a possible implementation, the second encoding module is specifically configured to:

[0050] reducing the preset initial rate by a preset variation to obtain an alternative rate;

[0051] if the alternative rate is less than a preset minimum rate value, taking the preset minimum rate value as the target rate;

[0052] if the alternative rate is greater than or equal to the preset minimum rate value, taking the alternative rate as the target rate.

[0053] In a possible implementation, the second encoding module is specifically configured to:

[0054] for a first number of continuous preset coding windows, if the average quantization parameter of each of the preset coding windows is less than a second threshold value, determining that a historical coding rate of the first number of continuous preset coding windows is higher than a preset minimum rate value;

[0055] reducing the initial rate to obtain the target rate.

[0056] In a possible implementation, the second encoding module is specifically configured to:

[0057] determine the maximum quantization parameter corresponding to the preset encoding window;

[0058] if the average quantization parameter of each of the preset encoding windows is less than the second threshold value and the maximum quantization parameter of each of the preset encoding windows is less than the third threshold value in the first number of continuous preset encoding windows, reduce the preset initial code rate to obtain a target code rate.

[0059] In a possible implementation, the third threshold value is determined according to the second threshold value and a preset offset.

[0060] In a fourth aspect, an embodiment of the present application provides a video code rate adjustment apparatus, comprising:

[0061] a first determination module configured to determine a picture quality level corresponding to an input operation of a user on a preset control and determine a picture quality parameter according to the picture quality level in response to the input operation; the picture quality parameter comprises a first number of preset encoding windows, a preset initial code rate, a first threshold value corresponding to an average quantization parameter, and a second threshold value corresponding to the average quantization parameter;

[0062] a second determination module configured to determine an average quantization parameter corresponding to a preset encoding window in a video encoding process;

[0063] a first encoding module configured to encode a target frame according to the preset initial code rate if the average quantization parameter is greater than the first threshold value;

[0064] a second encoding module configured to reduce the preset initial code rate to obtain a target code rate and encode the target frame according to the target code rate if the average quantization parameter of each of the preset encoding windows is less than the second threshold value in the first number of continuous preset encoding windows.

[0065] In a fifth aspect, an embodiment of the present application provides an electronic device, comprising a memory and a processor.

[0066] The memory stores computer execution instructions.

[0067] The processor executes the computer execution instructions stored in the memory, so that the processor executes the video code rate adjustment method in any one of the first aspect or the second aspect.

[0068] In a sixth aspect, an embodiment of the present application provides a computer readable storage medium, wherein the computer readable storage medium stores computer execution instructions, and the computer execution instructions are used to implement the video code rate adjustment method in any one of the first aspect or the second aspect when executed by a processor.

[0069] In a seventh aspect, an embodiment of the present application provides a computer program product, comprising a computer program which, when executed by a processor, implements the video code rate adjustment method shown in any one of the first aspect or the second aspect.

[0070] In the embodiment of the present application, the electronic device determines the average quantization parameter corresponding to the preset coding window; when the average quantization parameter of the preset coding window is greater than the first threshold value, the electronic device determines that the current video scene is relatively complex, and the coding code rate of the preset coding window is relatively low, resulting in relatively poor video quality. At this time, the electronic device directly encodes the target frame according to a relatively high preset initial code rate, which can quickly adapt to the change of the video scene, quickly improve the video quality, and improve the user's video watching experience; when the average quantization parameter of each preset coding window in the first number of continuous preset coding windows is less than the second threshold value, the electronic device can determine that the current video scene is relatively simple, the coding code rate of the preset coding window is relatively high, the overall quality is relatively high, and there is a waste of code rate. At this time, the electronic device can reduce the video coding code rate and encode the target frame according to a relatively low target code rate, which can save bandwidth resources and reduce bandwidth cost. BRIEF DESCRIPTION OF DRAWINGS

[0071] The accompanying drawings, which are included to provide a further understanding of the present application, form a part of the present application and illustrate the illustrative embodiments of the present application and the explanation of the present application, and do not constitute improper limitations on the present application. In the drawings:

[0072] Figure 1 A schematic diagram of an application scenario provided for the exemplary embodiments of the present application;

[0073] Figure 2 A flowchart of a video code rate adjustment method provided for the exemplary embodiments of the present application;

[0074] Figure 3 A flowchart of another video code rate adjustment method provided for the exemplary embodiments of the present application;

[0075] Figure 4 A flowchart of another video code rate adjustment method provided for the exemplary embodiments of the present application;

[0076] Figure 5 A logic diagram of a video code rate adjustment provided for the exemplary embodiments of the present application;

[0077] Figure 6 A structural diagram of a video code rate adjustment device provided for the exemplary embodiments of the present application;

[0078] Figure 7 A structural diagram of another video code rate adjustment device provided for the exemplary embodiments of the present application;

[0079] Figure 8 A structural schematic diagram of an electronic device is provided for an exemplary embodiment of the present application. DETAILED DESCRIPTION

[0080] In order to make the purposes, technical solutions, and advantages of the present application clearer, the technical solutions of the present application will be described below in connection with specific embodiments of the present application and corresponding drawings. Obviously, the described embodiments are only some of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without any creative work fall within the scope of protection of the present application.

[0081] With the continuous development of Internet technology, multimedia technologies such as network live broadcast and video playback are also gradually maturing. In the process of video stream generation and transmission, video encoding is usually required. In the video encoding process, code rate and picture quality are core indicators in video encoding. Reducing the code rate can reduce the bandwidth cost, and the picture quality represents the user experience. Generally speaking, a higher code rate corresponds to higher picture quality, and a lower code rate corresponds to lower picture quality. The code rate, which can also be referred to as the bit rate, refers to the number of bits of the video played per unit time, and the unit of the code rate can be bits per second (bps) and the like.

[0082] However, when the video scene complexity is different, the corresponding relationship between the code rate and the picture quality will also have some other cases. The video scene complexity can refer to the complexity of the video in the spatial domain and the time domain. In the spatial domain, the spatial complexity is represented by the image texture details, and the spatial simplicity is represented by the image flatness. In the time domain, the time complexity is represented by the motion amplitude and the motion irregularity, and the time complexity is represented by the small video motion amplitude. For some simple scenes, the electronic device can use a lower code rate in the video encoding process to achieve a very high picture quality, at which time increasing the code rate will not improve the user experience. For some complex scenes, a higher code rate is required in the video encoding process to maintain a high picture quality.

[0083] In the related art, common code control modes for video encoding include average bit rate mode, constant quantization parameter mode (CQP) or constant quality factor mode (CRF), etc. Among them, the average bit rate mode (ABR) meets or approaches a fixed bit rate within a time window. Exemplarily, the Video Tool Box is a framework of hardware encoding and decoding in the iOS system, and a hardware encoder can be called through an application interface in the Video Tool Box, and the hardware encoder supports ABR mode encoding. In some network live streaming scenarios, the electronic device usually pushes a stream based on the hardware decoder of the iOS system.

[0084] In the related art, the electronic device encodes according to a fixed bit rate regardless of whether the video scene is simple or complex. In this way, when the video scene is relatively complex, this encoding mode can easily lead to unclear video quality, and the user's viewing experience is poor. When the video scene is relatively simple, this encoding mode can easily cause waste of bandwidth resources and increase bandwidth costs.

[0085] Figure 1 A schematic diagram of an application scenario provided for an exemplary embodiment of the present application is shown. As shown in the figure, an electronic device 101 is included. The electronic device 101 can be a mobile phone, a computer, a wearable device, etc., and the specific type of the electronic device is not limited in the embodiments of the present application. Figure 1

[0086] In the related art, the electronic device 101 usually encodes video according to a fixed bit rate mode. This encoding mode can easily cause waste of bandwidth and increase bandwidth costs on the one hand, and cannot ensure clear video quality, leading to poor user viewing experience on the other hand. In the embodiments of the present application, the electronic device encodes according to a dynamic bit rate adjustment mode. When the scene is relatively simple, the bit rate can be appropriately reduced to save bandwidth resources. When the scene is complex, the bit rate can be increased to ensure clear video quality and improve the user's viewing experience.

[0087] ​In the embodiment of the present application, the electronic device determines the average quantization parameter corresponding to the preset encoding window; when the average quantization parameter of the preset encoding window is greater than the first threshold value, the electronic device determines that the current video scene is relatively complex, and the encoding code rate of the preset encoding window is relatively low, resulting in poor video quality. At this time, the electronic device directly encodes the target frame according to a higher preset initial code rate, which can quickly adapt to the change of the video scene, quickly improve the video quality, and improve the user's video watching experience; when the average quantization parameter of each preset encoding window in the first number of continuous preset encoding windows is less than the second threshold value, the electronic device can determine that the current video scene is relatively simple, the encoding code rate of the preset encoding window is relatively high, the overall quality is relatively high, and there is a waste of code rate. At this time, the electronic device can reduce the video encoding code rate and encode the target frame according to a lower target code rate, which can save bandwidth resources and reduce bandwidth cost.

[0088] The technical solutions shown in the present application will be described in detail below through specific embodiments. It should be noted that the following embodiments can exist independently or in combination. For the same or similar content, it will not be repeated in different embodiments.

[0089] Figure 2 A flowchart of a video code rate adjustment method provided by an exemplary embodiment of the present application is shown. Please refer to Figure 2 The method can include:

[0090] S201, determining the average quantization parameter corresponding to the preset encoding window.

[0091] The execution subject of the embodiment of the present application can be an electronic device, or a video code rate adjustment device provided in the electronic device. The video code rate adjustment device can be realized by software, or by the combination of software and hardware. For ease of understanding, the execution subject will be taken as an electronic device in the following description.

[0092] In the embodiment of the present application, the preset encoding window can refer to an encoded video window, and each preset encoding window can include a second number of historical frames, which can refer to the video frames that have been encoded by the electronic device. The second number can be a pre-set value, for example, 5 or 6, and can be set based on actual needs. The embodiment of the present application does not limit this.

[0093] The average quantization parameter can refer to the average value of the frame quantization parameters of all historical frames in the preset encoding window. The quantization parameter (QP) can refer to a parameter index in video encoding. The quantization parameter is inversely proportional to the code rate, that is, the larger the quantization parameter, the lower the code rate, and the poorer the quality; the smaller the quantization parameter, the higher the code rate, and the better the quality.

[0094] In this step, in the video encoding process, the electronic device can obtain the frame quantization parameter of each historical frame that has been encoded for each historical frame. When the number of consecutive historical frames reaches the second number, the electronic device can calculate the average quantization parameter of the second number of consecutive historical frames, that is, the average quantization parameter of the preset encoding window, and the average quantization parameter can be used to determine whether the encoding code rate needs to be dynamically adjusted.

[0095] S202, if the average quantization parameter is greater than the first threshold, encoding the target frame according to the preset initial code rate.

[0096] In the embodiment of the application, the first threshold can be the maximum value of the average quantization parameter corresponding to the preset encoding window. When the average quantization parameter is greater than the first threshold, it indicates that the current video scene is complex, the preset encoding window video encoding code rate is low, and the picture quality is poor, and the encoding code rate needs to be increased to improve the video picture quality. The first threshold can be pre-set based on actual demand, and the specific value of the first threshold is not limited in the embodiment of the application. The preset initial code rate can be a pre-set code rate initial value (Bitrate Original). The preset numerical code rate can correspond to a picture quality that is better for user viewing experience, and the specific value can be set based on actual demand, which is not limited in the embodiment of the application. The target frame can be a frame to be encoded, which can be the next video frame to be encoded in the preset encoding window.

[0097] In this step, after determining the average quantization parameter of the preset encoding window, the electronic device can compare the average quantization parameter with the first threshold. If the average quantization parameter of the preset encoding window is greater than the first threshold, the electronic device can determine that the current video scene is complex, the video segment code rate corresponding to the preset encoding window is low, and the picture quality is poor, and the code rate needs to be increased to improve the picture quality in the subsequent encoding process. When encoding the next frame, i.e., the target frame, the electronic device can directly set the encoding code rate to the preset initial code rate, which can quickly increase the code rate, quickly adapt to the change of the video scene, improve the video picture quality, and improve the user's video viewing experience.

[0098] S203, if the average quantization parameter of each preset encoding window in the first number of consecutive preset encoding windows is less than the second threshold, the target code rate is obtained by reducing the preset initial code rate, and the target frame is encoded according to the target code rate.

[0099] In the embodiments of the present application, the first quantity can refer to a number of continuous preset encoding windows that meet the code rate adjustment condition and is pre-set, for example, can be 5, 6, etc. The specific value of the first quantity is not limited in the embodiments of the present application. The second threshold can refer to a minimum value of the average quantization parameter. When the average quantization parameter is lower than the second threshold, it indicates that the code rate of the video coding is higher and the picture quality is better. The second threshold can be pre-set by a user based on actual needs. The specific value of the second threshold is not limited in the embodiments of the present application. The target code rate can refer to the encoding code rate of the target frame.

[0100] In the human eye vision model, when the picture quality of the video is good to a certain extent, the user is not subjectively aware of the distortion when the code rate is further reduced. Correspondingly, in this range, the code rate is further increased in the video coding process, which wastes the code rate and the bandwidth resource. In the embodiments of the present application, if the average quantization parameter of each preset encoding window in the continuous first quantity of preset encoding windows is less than the second threshold, the electronic device can determine that the current video scene is relatively simple, the code rate of the coded video segment is higher, and the picture quality is better. In the subsequent coding process, the code rate can be appropriately reduced to save the bandwidth resource. When the target frame is encoded, the electronic device can reduce the preset initial code rate to obtain the target code rate, and encode the target frame according to the target code rate after the code rate is appropriately reduced. In this way, the subjective viewing experience of the user can be ensured to be not affected, the bandwidth resource can be saved, and the bandwidth cost can be reduced. The specific reduction value of the code rate can be flexibly set based on actual needs, which is not limited in the embodiments of the present application.

[0101] In the embodiments of the present application, the electronic device determines the average quantization parameter corresponding to the preset encoding window. When the average quantization parameter of the preset encoding window is greater than the first threshold, the electronic device determines that the current video scene is relatively complex, the encoding code rate of the preset encoding window is relatively low, and the video picture quality is relatively poor. At this time, the electronic device directly encodes the target frame according to the higher preset initial code rate, which can quickly adapt to the change of the video scene, quickly improve the video picture quality, and improve the video viewing experience of the user. When the average quantization parameter of each preset encoding window in the continuous first quantity of preset encoding windows is less than the second threshold, the electronic device can determine that the current video scene is relatively simple, the encoding code rate of the preset encoding window is relatively high, the overall picture quality is relatively high, and the code rate is wasted. At this time, the electronic device can reduce the video encoding code rate and encode the target frame according to the lower target code rate, which can save the bandwidth resource and reduce the bandwidth cost.

[0102] On the basis of the above embodiments, Figure 3 The flowchart of another video code rate adjustment method provided by the exemplary embodiments of the present application is shown. Please refer to Figure 3 The method can include:

[0103] S301, determine a frame quantization parameter of each historical frame in a preset encoding window; each preset encoding window includes a second number of historical frames; determine an average quantization parameter corresponding to the preset encoding window according to the frame quantization parameter of each historical frame.

[0104] In the embodiment of the application, the frame quantization parameter can be a frame-level QP of the historical frame, which can be used to represent the picture quality information of the encoded historical frame. Specifically, the electronic device can determine the frame quantization parameter of each historical frame in the preset encoding window, and then calculate the average of the frame quantization parameters of each historical frame, that is, the average quantization parameter corresponding to the preset encoding window.

[0105] In a possible implementation, the frame quantization parameter of each historical frame can be determined in the following manner:

[0106] For each historical frame, after the encoding of the historical frame is completed, the preset length of the code stream in the historical frame is decoded to obtain the frame quantization parameter corresponding to the historical frame.

[0107] In the embodiment of the application, the preset length can be a pre-set decoding length. After the encoding of a historical frame is completed, the electronic device can decode part of the code stream of the historical frame, that is, the code stream of the preset length, and then obtain the frame quantization parameter corresponding to the historical frame.

[0108] In the embodiment of the application, the electronic device obtains the frame quantization parameter by decoding part of the code stream of the encoded historical frame, and then calculates the average quantization parameter of the preset encoding window, which can accurately reflect the picture quality information and scene complexity of the historical frame in the preset encoding window, and provides an accurate data basis for the subsequent dynamic adjustment of the code rate, and improves the rationality of the subsequent code rate adjustment.

[0109] S302, if the average quantization parameter of the preset encoding window is greater than a first threshold, determine that the historical encoding code rate of the preset encoding window is lower than a preset initial code rate; encode the target frame according to the preset initial code rate.

[0110] In the embodiment of the application, the historical encoding code rate can be a video encoding code rate corresponding to the preset encoding window, for example, can be an average value of the encoding code rates of the second number of historical frames in the preset encoding window. The average quantization parameter is inversely proportional to the historical encoding code rate, that is, the higher the average quantization parameter, the lower the historical encoding code rate, and the worse the picture quality.

[0111] The first threshold value can be a maximum value of the average quantization parameter, and the encoding code rate corresponding to the first threshold value is low and the picture quality is poor. The preset initial code rate can be greater than the encoding code rate corresponding to the first threshold value. When the average quantization parameter is greater than the first threshold value, the historical encoding code rate of the video segment corresponding to the preset encoding window is lower than the encoding code rate corresponding to the first threshold value, and is obviously lower than the preset initial code rate. At this time, the picture quality is low, and the user experience is poor.

[0112] In this step, when the average quantization parameter of the preset encoding window is greater than the first threshold value, the electronic device can determine that the historical encoding code rate of the preset encoding window is low. At this time, the video scene is complex, the video encoding code rate is low, the picture quality is poor, and the user experience is poor. The electronic device can then encode the target frame according to the preset initial code rate with a higher code rate. In this way, the electronic device can quickly adapt to changes in the video scene by directly adjusting the encoding code rate of the next frame to the preset initial code rate when the average quantization parameter of the preset encoding window is greater than the first threshold value. This can achieve rapid improvement of the encoding code rate, rapid improvement of the picture quality, and improvement of the user's video viewing experience.

[0113] In step S303, for the first number of continuous preset encoding windows, if the average quantization parameter of each preset encoding window is less than the second threshold value, it is determined that the historical encoding code rate of the first number of continuous preset encoding windows is higher than the preset minimum code rate value.

[0114] In the embodiments of the present application, the second threshold value can be a minimum value of the average quantization parameter. The preset minimum code rate value can represent the encoding code rate corresponding to the lowest picture quality that the user can subjectively accept. The specific value can be flexibly set based on actual needs, and the embodiments of the present application do not limit this. The encoding code rate corresponding to the second threshold value can be higher than the preset minimum code rate value, that is, the encoding code rate corresponding to the second threshold value can be the encoding code rate when the picture quality is better and the user experience is better.

[0115] Specifically, when the average quantization parameter corresponding to each of the first number of continuous preset encoding windows is less than the second threshold value, the electronic device can determine that the current video scene is simple, the code rate of the video segment corresponding to the first number of continuous preset encoding windows is high, and the picture quality is good. The electronic device can subsequently appropriately reduce the encoding code rate to encode the target frame. In this way, the user's video viewing experience is not affected, and bandwidth resources can be saved, and bandwidth costs can be reduced.

[0116] In a possible implementation, step S303 can also be implemented through the following steps (1) to (2):

[0117] In step (1), the maximum quantization parameter corresponding to the preset encoding window is determined.

[0118] In the embodiments of the present application, the maximum quantization parameter can refer to the maximum frame quantization parameter in each historical frame in the preset encoding window. After obtaining the frame quantization parameters of each historical frame in the preset encoding window, the electronic device can compare the frame quantization parameters of each historical frame, and then determine the maximum quantization parameter corresponding to the preset encoding window.

[0119] In step (2), if the average quantization parameter of each preset encoding window is less than the second threshold value, and the maximum quantization parameter of each preset encoding window is less than the third threshold value in the first number of continuous preset encoding windows, the preset initial code rate is reduced to obtain a target code rate; the third threshold value is determined according to the second threshold value and a preset offset.

[0120] In the embodiments of the present application, the third threshold value can refer to a critical value of the maximum quantization parameter of the preset encoding window, which is set in advance. When the maximum quantization parameter is greater than or equal to the third threshold value, it indicates that there is a video frame with a lower code rate and a poorer picture quality in the preset encoding window, and at this time, it is not suitable to adjust the encoding code rate downward. When the maximum quantization parameter is less than the third threshold value, it indicates that the code rate of each historical frame in the preset encoding window is relatively high, and the overall picture quality is good, and at this time, the code rate can be appropriately reduced to save bandwidth resources. The specific value of the third threshold value can be flexibly set based on actual needs, and the embodiments of the present application do not limit this.

[0121] The preset offset can refer to a preset offset value, for example, it can be 3, 4, 5, etc., and the embodiments of the present application do not limit this. The third threshold value can refer to the sum of the second threshold value and the preset offset. In this way, the second threshold value and the third threshold value can share a base, which can improve the flexibility of parameter setting.

[0122] Specifically, in the first number of continuous preset encoding windows, if the average quantization parameter of each preset encoding window is less than the second threshold value, and the maximum quantization parameter of each preset encoding window is less than the third threshold value, the electronic device can determine that the overall picture quality of the video segment of the first number of continuous preset encoding windows is high, there is no historical frame with a lower picture quality, and the current video scene is relatively simple. In the subsequent encoding process, the encoding code rate can be appropriately reduced to save bandwidth resources. In this way, by introducing the maximum quantization parameter and the average quantization parameter as the judgment condition for dynamic adjustment of the code rate, the picture quality information of the encoded video segment can be better represented, the code rate can be avoided to be adjusted incorrectly when the scene fluctuates, the rationality of the dynamic adjustment of the code rate can be ensured, and the video watching experience of the user can be ensured.

[0123] It should be understood that in various embodiments of the present application, the size of the serial number of each process does not mean the order of execution, and the execution order of each process should be determined according to its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0124] S304, determine the target code rate according to the preset initial code rate, the preset change amount and the preset minimum code rate value.

[0125] In the embodiments of the present application, the preset change amount can refer to a preset code rate adjustment range, for example, the preset change amount can be 500, etc., which can be set based on actual needs, and the embodiments of the present application do not limit this. Specifically, the electronic device can reduce the preset initial code rate by the preset change amount, and compare the result with the preset minimum code rate value, and then the target code rate can be determined. Of course, the target code rate can also be determined in other ways, and the embodiments of the present application do not limit this.

[0126] In a possible implementation, step S304 can be implemented by the following steps:

[0127] The preset initial code rate is reduced by the preset change amount to obtain a candidate code rate; if the candidate code rate is less than the preset minimum code rate value, the preset minimum code rate value is taken as the target code rate; if the candidate code rate is greater than or equal to the preset minimum code rate value, the candidate code rate is taken as the target code rate.

[0128] In the embodiments of the present application, the candidate code rate can refer to the difference between the preset initial code rate and the preset change amount. When the candidate code rate is less than the preset minimum code rate value, it indicates that if the encoding is performed according to the candidate code rate, the picture quality will be lower than the lowest picture quality that the user can subjectively accept, reducing the user's viewing experience, at this time the electronic device can take the preset minimum code rate value as the target code rate, appropriately reduce the encoding code rate and ensure the user's viewing experience.

[0129] When the candidate code rate value is greater than or equal to the preset minimum code rate value, it indicates that reducing the picture quality will not affect the user's viewing experience, at this time the electronic device can take the candidate code rate as the target code rate, and the target frame can be encoded according to the target code rate subsequently. In this way, the user's viewing experience can be ensured, and the code rate can be reduced, saving bandwidth resources and reducing bandwidth cost.

[0130] S305, encode the target frame according to the target code rate.

[0131] In the embodiments of this application, when the average quantization parameter of each preset encoding window in the first number of continuous preset encoding windows is less than the second threshold value, the electronic device can reduce the preset initial code rate to obtain a target code rate, and encode the target frame according to the target code rate. When the average quantization parameter of the preset encoding window is greater than or equal to the second threshold value, the preset encoding window does not meet the condition of dynamic adjustment of the code rate, and the electronic device does not adjust the encoding code rate, and judges the next preset encoding window, until there are the first number of continuous preset encoding windows that meet the condition of dynamic adjustment of the code rate, and then the encoding code rate is adjusted. In this way, the dynamic adjustment of the video encoding code rate can be realized, which can not only ensure the video quality and improve the user's video viewing experience, but also avoid the waste of bandwidth resources and reduce the bandwidth cost.

[0132] On the basis of the above-mentioned embodiments, Figure 4 Another flowchart of a video code rate adjustment method provided by an exemplary embodiment of this application is shown in FIG. 4. As shown in FIG. 4, the video code rate adjustment method can include the following steps. Figure 4

[0133] S401, in response to the input operation of the user on the preset control, determining the quality level corresponding to the input operation, and determining the quality parameter according to the quality level; the quality parameter includes the first number of preset encoding windows, the preset initial code rate, the first threshold value corresponding to the average quantization parameter, and the second threshold value corresponding to the average quantization parameter.

[0134] In the embodiments of this application, the preset control can refer to a pre-set parameter setting control. The quality level can refer to different quality levels of video encoding provided by the electronic device, for example, including standard definition, high definition, ultra definition, etc., of course, other quality levels can also be included, which are not limited in this embodiment of this application. Each quality level can correspond to a set of quality parameters, which include the first number of preset encoding windows, the preset initial code rate, the first threshold value corresponding to the average quantization parameter, and the second threshold value corresponding to the average quantization parameter, etc. It should be noted that the quality parameters in each quality level can be pre-configured by the user, or can be the default setting of the electronic device, and the specific value and setting method of the quality parameter are not limited in this embodiment of this application.

[0135] In this step, the user can select the quality level by inputting the preset control in the electronic device; correspondingly, the electronic device can determine the quality level based on the input operation, and obtain the quality parameter corresponding to the quality level, which can be used for dynamic adjustment of the video code rate in the subsequent process. S402, in the video encoding process, determining the average quantization parameter corresponding to the preset encoding window; each preset encoding window includes a second number of historical frames.

[0136] ​S403, if the average quantization parameter is greater than the first threshold, encoding the target frame according to the preset initial code rate.

[0137] S404, if the average quantization parameter of each preset encoding window in the continuous first number of preset encoding windows is less than the second threshold, reducing the preset initial code rate to obtain a target code rate, and encoding the target frame according to the target code rate.

[0138] In the embodiments of the present application, the electronic device determines the picture quality level corresponding to the input operation of the user for the preset control and determines the picture quality parameter corresponding to the picture quality level in response to the input operation of the user for the preset control, the picture quality parameter includes the first number of preset encoding windows, the preset initial code rate, the first threshold corresponding to the average quantization parameter, and the second threshold corresponding to the average quantization parameter. Then in the video encoding process, the average quantization parameter corresponding to the preset encoding window is determined. When the average quantization parameter of the preset encoding window is greater than the first threshold, the electronic device determines that the current video scene is relatively complex, and the encoding code rate of the preset encoding window is relatively low, which leads to poor video quality. At this time, the electronic device directly encodes the target frame according to the higher preset initial code rate, which can quickly adapt to the change of the video scene, quickly improve the video quality, and improve the user's video watching experience. When the average quantization parameter of each preset encoding window in the continuous first number of preset encoding windows is less than the second threshold, the electronic device can determine that the current video scene is relatively simple, the encoding code rate of the preset encoding window is relatively high, the overall picture quality is relatively high, and there is a waste of code rate. At this time, the electronic device can reduce the video encoding code rate, encode the target frame according to the lower target code rate, which can save bandwidth resources and reduce bandwidth cost.

[0139] On the basis of any one of the above embodiments, Figure 5 A logic diagram for adjusting the video code rate is provided for the exemplary embodiments of the present application. As shown in the figure, Figure 5 The electronic device can first set the code rate to the preset initial code rate, set the number of preset encoding windows that meet the code rate reduction condition to 0, and set the number of history frames to 0. The electronic device encodes the current frame, and after the encoding is completed, the number of history frames that have been encoded is incremented by 1. The electronic device can decode the preset length code stream of the history frame that has been encoded to determine the frame quantization parameter of the history frame. The electronic device judges the size of the number of history frames and the second number. When the number of history frames is less than the second number, a preset encoding window cannot be formed at this time, and the electronic device continues to encode the current frame, so that the number of history frames continues to increase. When the number of history frames is greater than or equal to the second number, the electronic device can determine the average quantization parameter and the maximum quantization parameter of the preset encoding window.

[0140] When the average quantization parameter of the preset coding window is greater than the first threshold value, the electronic device can determine that the current video scene is relatively complex, the coding rate of the preset coding window is relatively low, and the picture quality is relatively poor. The electronic device can directly set the coding rate to the preset initial coding rate, encode the next frame (target frame) according to the preset initial coding rate, set the historical frame number to 0, and re-determine the next preset coding window.

[0141] When the average quantization parameter of the preset coding window is less than or equal to the first threshold value, if the preset coding window satisfies the condition for reducing the coding rate, that is, the average quantization parameter of the preset coding window is less than the second threshold value and the maximum quantization parameter of the preset coding window is less than the third threshold value, the electronic device can add 1 to the number of preset coding windows that satisfy the condition for reducing the coding rate. If the preset coding window does not satisfy the condition for reducing the coding rate, that is, the average quantization parameter of the preset coding window is greater than or equal to the second threshold value, or the maximum quantization parameter of the preset coding window is greater than or equal to the third threshold value, the preset coding window does not satisfy the condition for reducing the coding rate, the electronic device can reset the number of preset coding windows that satisfy the condition for reducing the coding rate to 0, and set the historical frame number to 0. The electronic device continues to judge the next preset coding window.

[0142] When the number of preset coding windows that satisfy the condition for reducing the coding rate is greater than or equal to the first number, that is, the first number of consecutive preset coding windows satisfy the condition for reducing the coding rate, the electronic device can determine that the current video scene is relatively simple, the overall picture quality is relatively high, and the coding rate can be appropriately reduced to save bandwidth resources. The electronic device appropriately reduces the preset initial coding rate to obtain a target coding rate, encodes the next frame according to the target coding rate, sets the number of preset coding windows that satisfy the condition for reducing the coding rate to 0, sets the historical frame number to 0, and continues to dynamically adjust the subsequent coding rate. Specifically, the target coding rate can be represented as: target coding rate = max (preset minimum coding rate value, preset initial coding rate - preset change amount). When the number of preset coding windows that satisfy the condition for reducing the coding rate is less than the first number, the electronic device continues to encode the next frame and judges the next preset coding window.

[0143] In the embodiments of the present application, the electronic device determines the rate adjustment direction based on the picture quality information of the encoded historical frames, for example, the average quantization parameter of the preset encoding window determined based on the frame-level QP, and specifically can be divided into upward adjustment of the code rate and downward adjustment of the code rate. When the average quantization parameter of the preset encoding window is high, the video scene is complex, the video quality is poor, and the code rate needs to be adjusted upward to improve the picture quality and enhance the user's video viewing experience. When the first number of preset encoding windows meet the code rate lowering condition, the overall picture quality of the past coded video segment is good, and the video scene is simple. At this time, increasing the code rate cannot improve the user's subjective experience, and the electronic device can downward adjust the code rate to save bandwidth resources and reduce bandwidth cost while keeping the picture quality almost unchanged.

[0144] Exemplarily, the specific effect of the video code rate adjustment method of the embodiments of the present application can be determined based on the configuration parameters. Specifically, 5M corresponds to a high-definition picture quality scene, and 3M corresponds to a medium picture quality scene. The electronic device can determine the second number as 5, the first number as 6, the first threshold as 35, the second threshold as 26, the preset offset as 3, the preset change as 500, and the minimum code rate value as 1000 based on the input operation of the user, and the preset initial code rate is set to 1500.

[0145] Based on the above parameters, the dynamic adjustment of the video code rate saves 17% of the 5M code rate, and the subjective evaluation result does not decrease the picture quality. For the 3M code rate, 6.5% is saved, and the subjective evaluation result does not decrease the picture quality. It can be seen that the picture quality of the encoded video segment can be well reflected based on the picture quality information of the encoded frame in the embodiments of the present application. Then, the code rate can be dynamically adjusted according to the scene. When the scene is simple, the code rate is low and the picture quality is good, and the code rate is saved. When the scene is complex, the code rate is still sufficient. In this way, the code rate can be effectively saved, the subjective experience does not decrease, and the bandwidth cost can be effectively reduced. Moreover, the code rate is adjusted upward very quickly in the embodiments of the present application, which can quickly adapt to the change of the scene and ensure the user's video viewing experience.

[0146] It should be noted that the video code rate adjustment method in the embodiments of the present application can be applied to the hard encoder of the iOS system, can be applied to the hard encoder of other operating systems, and can be applied to various software video encoders under various operating systems, and the embodiments of the present application do not limit this.

[0147] Figure 6 A structural schematic diagram of a video code rate adjustment device provided for the exemplary embodiments of the present application is shown in FIG. 6. Figure 6 The video code rate adjustment device 60 includes:

[0148] The determination module 61 is configured to determine the average quantization parameter corresponding to the preset encoding window.

[0149] The first encoding module 62 is configured to encode the target frame according to a preset initial code rate if the average quantization parameter is greater than a first threshold value.

[0150] The second encoding module 63 is configured to reduce the preset initial code rate to obtain a target code rate, and encode the target frame according to the target code rate if the average quantization parameter of each preset encoding window in the first number of continuous preset encoding windows is less than a second threshold value.

[0151] In a possible implementation, the determining module is specifically configured to:

[0152] determine frame quantization parameters of each historical frame in the preset encoding window; and each preset encoding window includes the second number of historical frames;

[0153] determine the average quantization parameter corresponding to the preset encoding window according to the frame quantization parameters of each historical frame.

[0154] In a possible implementation, the determining module is specifically configured to:

[0155] for each historical frame, decode a preset length of code stream in the historical frame after the encoding of the historical frame is completed, to obtain the frame quantization parameter corresponding to the historical frame.

[0156] In a possible implementation, the first encoding module is specifically configured to:

[0157] if the average quantization parameter of the preset encoding window is greater than the first threshold value, determine that the historical encoding code rate of the preset encoding window is lower than the preset initial code rate;

[0158] encode the target frame according to the preset initial code rate.

[0159] In a possible implementation, the second encoding module is specifically configured to:

[0160] determine the target code rate according to the preset initial code rate, a preset change amount and a preset minimum code rate value.

[0161] In a possible implementation, the second encoding module is specifically configured to:

[0162] reduce the preset initial code rate by the preset change amount to obtain a candidate code rate;

[0163] if the candidate code rate is less than the preset minimum code rate value, take the preset minimum code rate value as the target code rate;

[0164] if the candidate code rate is greater than or equal to the preset minimum code rate value, take the candidate code rate as the target code rate.

[0165] In a possible implementation, the second encoding module is specifically configured to:

[0166] If the average quantization parameter of each preset encoding window is less than the second threshold value, it is determined that the history coding rate of the continuous first number of preset encoding windows is higher than the preset minimum code rate value.

[0167] The initial code rate is reduced to obtain the target code rate.

[0168] In a possible implementation, the second encoding module is specifically configured to:

[0169] The maximum quantization parameter corresponding to the preset encoding window is determined.

[0170] If the average quantization parameter of each preset encoding window is less than the second threshold value, and the maximum quantization parameter of each preset encoding window is less than the third threshold value, the preset initial code rate is reduced to obtain the target code rate.

[0171] In a possible implementation, the third threshold value is determined according to the second threshold value and a preset offset.

[0172] The video code rate adjustment apparatus 60 provided by the embodiments of the present application can perform the technical solutions shown in the method embodiments, and the implementation principles and beneficial effects are similar, which will not be repeated here.

[0173] Figure 7 A structural schematic diagram of a video code rate adjustment apparatus provided by an exemplary embodiment of the present application is shown in FIG. 7. Figure 7 The video code rate adjustment apparatus 70 includes:

[0174] The first determination module 71 is configured to determine the picture quality level corresponding to the input operation of the user on the preset control, and determine the picture quality parameter according to the picture quality level. The picture quality parameter includes the first number of preset encoding windows, the preset initial code rate, the first threshold value corresponding to the average quantization parameter, and the second threshold value corresponding to the average quantization parameter.

[0175] The second determination module 72 is configured to determine the average quantization parameter corresponding to the preset encoding window in the video coding process.

[0176] The first encoding module 73 is configured to encode the target frame according to the preset initial code rate if the average quantization parameter is greater than the first threshold value.

[0177] The second encoding module 74 is configured to reduce the preset initial code rate to obtain the target code rate if the average quantization parameter of each preset encoding window is less than the second threshold value in the continuous first number of preset encoding windows, and encode the target frame according to the target code rate.

[0178] The video code rate adjustment device 70 provided by the embodiments of the present application can execute the technical solutions shown in the method embodiments, and the implementation principles and beneficial effects are similar, which will not be repeated here.

[0179] Figure 8 A structural schematic diagram of an electronic device provided by the exemplary embodiments of the present application is shown in FIG. 8. Figure 8 The electronic device 80 can include a processor 81 and a memory 82. Exemplarily, the processor 81, the memory 82, and each part are connected with each other through a bus 83.

[0180] The memory 82 stores computer execution instructions.

[0181] The processor 81 executes the computer execution instructions stored in the memory 82, so that the processor 81 executes the video code rate adjustment method shown in the above method embodiments.

[0182] Correspondingly, the embodiments of the present application provide a computer readable storage medium, and the computer readable storage medium stores computer execution instructions. When the computer execution instructions are executed by a processor, the computer execution instructions are used to implement the video code rate adjustment method of the above method embodiments.

[0183] Correspondingly, the embodiments of the present application can also provide a computer program product, which includes a computer program. When the computer program is executed by a processor, the computer program can implement the video code rate adjustment method shown in the above method embodiments.

[0184] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can adopt a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can adopt a computer program product implemented on one or more computer usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer usable program codes.

[0185] The present application is described with reference to flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and the combination of the flows and / or blocks in the flowcharts and / or block diagrams can be implemented by computer program instructions. These computer program instructions can be provided to a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to produce a machine, so that the instructions executed by the computer or other programmable data processing devices produce a device for implementing the functions specified in the flowcharts and / or block diagrams. Figure 1 The device for implementing the functions specified in one flow or multiple flows and / or blocks. Figure 1 The device for implementing the functions specified in one flow or multiple flows and / or blocks.

[0186] These computer program instructions can also be stored in a computer- readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instructions which implement the Figure 1 function specified in the flow or flows and / or blocks Figure 1 of the block or blocks.

[0187] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions that are executed on the computer or other programmable apparatus provide steps for implementing the Figure 1 function specified in the flow or flows and / or blocks Figure 1 of the block or blocks.

[0188] In a typical configuration, a computing device includes one or more processors, input / output interfaces, network interfaces, and memory.

[0189] The memory can include non-persistent memory and / or volatile memory, such as random access memory (RAM) and / or cache memory, non-volatile memory, such as read-only memory (ROM), EPROM, and / or flash memory, etc. The memory is an example of computer readable media.

[0190] Computer readable media includes permanent and non-permanent, moveable and non- moveable media that can be implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile discs (DVDs) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that is accessible to a computing device. According to the definition provided herein, computer readable media does not include transitory media, such as modulated data signals and carrier waves.

[0191] It should also be noted that the terms "comprising," "including," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can also include other elements not expressly listed or inherent to such process, method, article, or apparatus. An element proceeded by "comprises a... " does not, without more constraints, exclude the existence of additional identical elements in the process, method, article, or apparatus that comprises the element.

[0192] The above description is merely illustrative of the application, and not restrictive. Various modifications and changes can become apparent to those skilled in the art. Incorporating any modification, equivalent substitution, improvement, etc. within the spirit and principle of the application, shall be included in the scope of the claims of the application.

Claims

1. A method for video bitrate adjustment, the method comprising: The method comprises the steps of: determining an average quantization parameter corresponding to a preset encoding window; wherein the preset encoding window refers to an already encoded video window, each of the preset encoding windows comprises a second number of historical frames, the historical frame refers to an already encoded video frame, and the second number is a preset value; if the average quantization parameter is greater than a first threshold, encoding a target frame according to a preset initial code rate; if the average quantization parameter of each of the preset encoding windows in a continuous first number of preset encoding windows is less than a second threshold, reducing the preset initial code rate to obtain a target code rate, and encoding the target frame according to the target code rate.

2. The method of claim 1, wherein, The method further comprises the steps of: determining a frame quantization parameter of each historical frame in the preset encoding window; determining the average quantization parameter corresponding to the preset encoding window according to the frame quantization parameters of the historical frames.

3. The method of claim 2, wherein, The method further comprises the steps of: for each historical frame, decoding a preset length of code stream in the historical frame after the encoding of the historical frame is completed to obtain a frame quantization parameter corresponding to the historical frame.

4. The method of claim 1, wherein, The method further comprises the steps of: if the average quantization parameter of the preset encoding window is greater than the first threshold, determining that a historical encoding code rate of the preset encoding window is lower than the preset initial code rate; encoding the target frame according to the preset initial code rate.

5. The method of claim 1, wherein, The method further comprises the steps of: determining the target code rate according to the preset initial code rate, a preset change amount and a preset minimum code rate value.

6. The method of claim 5, wherein, The method further comprises the steps of: reducing the preset initial code rate by the preset change amount to obtain a candidate code rate; if the candidate code rate is less than the preset minimum code rate value, taking the preset minimum code rate value as the target code rate; if the candidate code rate is greater than or equal to the preset minimum code rate value, taking the candidate code rate as the target code rate.

7. The method of claim 1, wherein, The method further comprises the steps of: for the continuous first number of preset encoding windows, if the average quantization parameter of each of the preset encoding windows is less than the second threshold, determining that the historical encoding code rates of the continuous first number of preset encoding windows are higher than the preset minimum code rate value; reducing the preset initial code rate to obtain the target code rate.

8. The method according to any one of claims 1 to 7, characterized in that, The method further comprises the steps of: determining a maximum quantization parameter corresponding to the preset encoding window; If the average quantization parameter of each of the preset coding windows in the first number of continuous preset coding windows is less than the second threshold value, and the maximum quantization parameter of each of the preset coding windows is less than the third threshold value, the preset initial code rate is reduced to obtain a target code rate.

9. The method of claim 8, wherein, The third threshold value is determined according to the second threshold value and a preset offset.

10. A method of video bitrate adjustment, the method comprising: The method comprises: In response to a user input operation on a preset control, determining a picture quality level corresponding to the input operation, and determining a picture quality parameter according to the picture quality level; The picture quality parameter comprises a first number of preset coding windows, a preset initial code rate, a first threshold value corresponding to an average quantization parameter, and a second threshold value corresponding to the average quantization parameter; wherein the preset coding window refers to a coded video window, each of the preset coding windows comprises a second number of historical frames, the historical frame refers to a video frame that has been encoded, and the second number is a preset value; In a video encoding process, determining an average quantization parameter corresponding to a preset coding window; If the average quantization parameter is greater than the first threshold value, encoding a target frame according to a preset initial code rate; If the average quantization parameter of each of the preset coding windows in the first number of continuous preset coding windows is less than the second threshold value, the preset initial code rate is reduced to obtain a target code rate, and the target frame is encoded according to the target code rate.

11. A video bitrate adjustment apparatus, characterized by comprising: The method comprises: A determining module is configured to determine an average quantization parameter corresponding to a preset coding window; wherein the preset coding window refers to a coded video window, each of the preset coding windows comprises a second number of historical frames, the historical frame refers to a video frame that has been encoded, and the second number is a preset value; A first encoding module is configured to, if the average quantization parameter is greater than the first threshold value, encode a target frame according to a preset initial code rate; A second encoding module is configured to, if the average quantization parameter of each of the preset coding windows in the first number of continuous preset coding windows is less than the second threshold value, reduce the preset initial code rate to obtain a target code rate, and encode the target frame according to the target code rate.

12. An electronic device, comprising: The method comprises: A memory and a processor; The memory stores computer execution instructions; The processor executes the computer execution instructions stored in the memory, so that the processor executes the video code rate adjustment method according to any one of claims 1 to 10.

13. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer execution instructions, and when the computer execution instructions are executed by the processor, the video code rate adjustment method according to any one of claims 1 to 10 is implemented.

14. A computer program product, characterised in that, The computer program is executed by the processor to implement the video code rate adjustment method according to any one of claims 1 to 10.

Citation Information

Patent Citations

  • Video coding method, network live streaming method, video coding device, network live streaming device and terminal equipment

    CN113301342A

  • Code rate control method for real-time monitoring scene

    CN115550655A