Code rate adjustment method and device, equipment and storage medium

By adaptively adjusting the frame rate and code rate of the video acquisition system, the problem of degradation of video transmission quality and storage efficiency in low-illumination scenarios is solved, and the effect of stable code rate and picture quality is achieved, reducing the cost of code maintenance.

CN120111286APending Publication Date: 2025-06-06AXERA SEMICON (SHANGHAI) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510256229.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-05
Publication Date
2025-06-06

AI Technical Summary

Technical Problem

In low-illumination scenarios, the video acquisition system improves the brightness of the picture by reducing the frame rate of the image sensor, but the video encoder fails to adjust the code rate simultaneously, resulting in a decrease in video transmission quality and storage efficiency. The prior art requires applications to actively monitor frame rates and frequently call the interface of video encoder, which increases the cost of code maintenance and debugging.

Method used

A code rate adjustment method is provided. By obtaining the encoding parameters of the image to be compressed, including the frame rate and the length of the GOP. If the frame rate does not match, the new code rate is determined based on the new frame rate, the old frame rate and the old code rate, and the GOP length is updated to achieve adaptive adjustment of the frame rate and the code rate.

Benefits of technology

It achieves stable code rate and picture quality, reduces code maintenance and debugging costs, avoids resource competition and thread blockage, and improves system performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120111286A_ABST
    Figure CN120111286A_ABST
Patent Text Reader

Abstract

The invention provides a code rate adjustment method and device, equipment and a storage medium. The method comprises the following steps: acquiring a coding parameter of a (t + 1) th frame of to-be-compressed image; the coding parameters comprise the (t + 1) th frame rate and the length of the (t + 1) th GOP; t is an integer greater than or equal to 1; if the (t + 1) th frame rate is not matched with the tth frame rate, determining the (t + 1) th code rate based on the (t + 1) th frame rate, the tth frame rate and the tth code rate; and taking the (t + 1) th code rate as a coding code rate, and taking the length of the (t + 1) th GOP as the length of the coded GOP. According to the technical scheme provided by the invention, the frame rate can be adaptively adjusted, so that the code maintenance and debugging cost is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of video processing technology, and in particular to a bit rate adjustment method, device, equipment and storage medium. Background Art

[0002] Currently, in low-light scenes, video acquisition systems often reduce the frame rate of the image sensor to increase the exposure time of a single frame, thereby enhancing the brightness of the picture and reducing noise. For example, when the illumination is lower than 0.5 Lux, the image signal processor (ISP) will dynamically adjust the frame rate to a lower level, while the video encoder (VENC) still defaults to the initially configured high frame rate for bit rate allocation, thus affecting video transmission quality and storage efficiency.

[0003] To solve the above-mentioned bit rate mismatch problem, in the related art, the client application actively monitors the real-time frame rate of the image sensor and frequently calls the frame rate modification interface of the video encoder to synchronously adjust the encoding parameters.

[0004] However, the above method additionally implements the logic of image sensor frame rate monitoring and video encoder interface calling in the application, which increases code maintenance and debugging costs. Summary of the invention

[0005] The embodiments of the present application provide a method, apparatus, device and storage medium for adjusting the bit rate, which can adaptively adjust the frame rate, thereby reducing the cost of code maintenance and debugging. The technical solution is as follows:

[0006] According to a first aspect of an embodiment of the present application, a bit rate adjustment method is provided, the method comprising:

[0007] Obtaining encoding parameters of the (t+1)th frame of the image to be compressed; the encoding parameters include the (t+1)th frame rate and the length of the (t+1)th GOP; t is an integer greater than or equal to 1;

[0008] If the (t+1)th frame rate does not match the tth frame rate, determining the (t+1)th bit rate based on the (t+1)th frame rate, the tth frame rate and the tth bit rate;

[0009] The (t+1)th code rate is used as the encoding code rate, and the (t+1)th GOP length is used as the encoding GOP length.

[0010] In a possible implementation manner, determining the (t+1)th bit rate based on the (t+1)th frame rate, the tth frame rate, and the tth bit rate includes:

[0011] Obtaining a ratio between the (t+1)th frame rate and the tth frame rate;

[0012] Based on the ratio and the tth code rate, a (t+1)th code rate is determined.

[0013] In a possible implementation manner, determining the (t+1)th code rate based on the ratio and the tth code rate includes:

[0014] The product of the ratio and the t-th code rate is used as the (t+1)-th code rate.

[0015] In a possible implementation, the method further includes:

[0016] Based on the number of frames and a preset statistical period, the (t+1)th frame rate is determined; the number of frames is the number of the images to be compressed acquired within the preset statistical period.

[0017] In a possible implementation, the method further includes: if the (t+1)th frame rate does not match the tth frame rate, adjusting the preset statistical period to obtain an updated statistical period.

[0018] In a possible implementation, the method further includes:

[0019] The initial flag of the coding channel is adjusted to the target flag; the target flag indicates adjusting the code rate; the initial flag indicates not adjusting the target flag.

[0020] In a possible implementation, the method further includes:

[0021] If the (t+1)th frame rate matches the tth frame rate, the (t+1)th frame of the image to be compressed is encoded based on the tth bit rate and the length of the tth GOP to obtain an encoding result.

[0022] In a possible implementation, the method further includes: encoding the (t+1)th frame of the image to be compressed based on the encoding bit rate and the length of the encoding GOP to obtain an encoding result.

[0023] According to a second aspect of an embodiment of the present application, a bit rate adjustment device is provided, wherein the device comprises:

[0024] An acquisition module, used for acquiring encoding parameters of the (t+1)th frame to be compressed; the encoding parameters include the (t+1)th frame rate and the length of the (t+1)th GOP; t is an integer greater than or equal to 1;

[0025] an adjusting module, configured to determine the (t+1)th bit rate based on the (t+1)th frame rate, the tth frame rate and the tth bit rate if the (t+1)th frame rate does not match the tth frame rate;

[0026] The determination module is used to use the (t+1)th bit rate as the encoding bit rate and the (t+1)th GOP length as the encoding GOP length.

[0027] According to a third aspect of an embodiment of the present application, a computer device is provided, comprising a processor and a memory, wherein the memory is used to store at least one program, and the at least one program is loaded by the processor and executes the bit rate adjustment method.

[0028] According to a fourth aspect of an embodiment of the present application, a computer-readable storage medium is provided, in which at least one program is stored. The at least one program is loaded and executed by a processor to implement the bit rate adjustment method.

[0029] In an embodiment of the present application, a code rate adjustment method is provided to obtain the encoding parameters of the (t+1)th frame to be compressed; the encoding parameters include the (t+1)th frame rate and the length of the (t+1)th GOP; if the (t+1)th frame rate does not match the tth frame rate, then based on the (t+1)th frame rate, the tth frame rate and the tth code rate, the (t+1)th code rate is determined; the (t+1)th code rate is used as the encoding code rate, and the length of the (t+1)th GOP is used as the length of the encoding GOP. The above technical scheme realizes adaptive adjustment of the frame rate and the length of the GOP, and adaptively adjusts the code rate according to the adjusted frame rate, thereby achieving a stable code rate effect. In addition, the image to be compressed is encoded based on the adjusted code rate and the length of the GOP, thereby achieving a stable image quality effect. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0031] Figure 1 is a schematic diagram of an implementation environment provided according to an embodiment of the present application;

[0032] Figure 2 It is a flowchart of a bit rate adjustment method provided according to an embodiment of the present application;

[0033] Figure 3 It is a flowchart provided according to an embodiment of the present application;

[0034] Figure 4 is a flow chart of step 202 provided according to an embodiment of the present application;

[0035] Figure 5 is a structural schematic diagram of a bit rate adjustment device provided according to an embodiment of the present application;

[0036] Figure 6 is a schematic diagram of the structure of a terminal provided according to an embodiment of the present application;

[0037] Figure 7 It is a structural diagram of a server provided according to an embodiment of the present application. DETAILED DESCRIPTION

[0038] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.

[0039] Here, exemplary embodiments will be described in detail, and examples thereof are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application.

[0040] In this application, the terms "first", "second", etc. are used to distinguish between identical or similar items with substantially the same effects and functions. It should be understood that there is no logical or temporal dependency between "first", "second", and "nth", nor is there a limitation on the quantity and execution order. It should also be understood that although the following description uses the terms first, second, etc. to describe various elements, these elements should not be limited by the terms.

[0041] These terms are only used to distinguish one element from another element. For example, without departing from the scope of various examples, a first action can be referred to as a second action, and similarly, a second action can also be referred to as a first action. Both the first action and the second action can be actions, and in some cases, can be separate and different actions.

[0042] Here, at least one means one or more than one, for example, at least one action can be one action, two actions, three actions, or any other action that is an integer greater than or equal to one. And multiple means two or more than two, for example, multiple actions can be two actions, three actions, or any other action that is an integer greater than or equal to two.

[0043] Figure 1It is a schematic diagram of an implementation environment provided according to an embodiment of the present application, and the implementation environment may include a terminal 101 and a server 102.

[0044] The terminal 101 is provided with a video encoder and a software development kit (SDK).

[0045] In some embodiments, the video encoder implements independent processing and transmission management of multiple video streams by creating encoding channels. Each encoding channel corresponds to an independent video input source (such as a camera), supporting simultaneous processing of multiple video streams and compression encoding. Encoding parameters such as resolution, frame rate, bit rate, etc. can be set separately in the encoding channel to meet the needs of different scenarios. For example, low latency live broadcast and high-quality storage.

[0046] In some embodiments, the software development kit obtains the actual encoded frame rate per second and the length of the group of pictures (GOP) in real time by calling the application programming interface (API) corresponding to the encoding channel.

[0047] The terminal 101 may be a smart phone with a video encoder and a software development kit, a wearable device, a personal computer, a laptop, a tablet computer, a smart TV, a car terminal, etc.

[0048] The server 102 may be a single server, a server cluster consisting of multiple servers, or a cloud processing center.

[0049] The terminal 101 is connected to the server 102 via a wired or wireless network.

[0050] In some embodiments, the wireless network or wired network uses standard communication technology and / or protocol. The network is usually the Internet, but it can also be any network, including but not limited to any combination of local area network (LAN), metropolitan area network (MAN), wide area network (WAN), mobile, wired or wireless network, private network or virtual private network. In some embodiments, the data exchanged through the network is represented by technology and / or format including HyperText Mark-up Language (HTML), Extensible Markup Language (XML), etc. In addition, conventional encryption technologies such as Secure Socket Layer (SSL), Transport Layer Security (TLS), Virtual Private Network (VPN), Internet Protocol Security (IPsec) can also be used to encrypt all or some links. In other embodiments, customized and / or dedicated data communication technology can also be used to replace or supplement the above data communication technology.

[0051] At present, in low-light scenes, video acquisition systems often reduce the frame rate of the image sensor to increase the exposure time of a single frame, thereby enhancing the brightness of the picture and reducing noise. For example, when the illumination is lower than 0.5 Lux, the image signal processor will dynamically adjust the frame rate to a lower level, while the video encoder (VENC) still defaults to the initially configured high frame rate for bit rate allocation. Since the video encoder does not perceive the frame rate change, its code control algorithm still allocates the single-frame target bit rate according to the original frame rate, resulting in the overall output bit rate being significantly lower than the expected value, which in turn affects the video transmission quality and storage efficiency.

[0052] To solve the above-mentioned bit rate mismatch problem, in the related art, the application actively monitors the real-time frame rate of the image sensor and frequently calls the frame rate modification interface of the video encoder to synchronously adjust the encoding parameters.

[0053] However, the above method has the following technical defects:

[0054] 1. High development complexity: Users need to implement the image sensor frame rate monitoring and video encoder API call logic in the application, which increases code maintenance and debugging costs;

[0055] 2. System performance burden: Frequent calls to the video encoding API may cause resource competition or thread blocking, especially in multi-channel video encoding scenarios, which may easily lead to encoding delays or frame drops.

[0056] 3. The coordinated optimization of image sensors and video encoders in low-light environments is also limited by the heterogeneity of hardware architecture. For example, although large-area image sensors can increase the amount of light entering, their real-time data interaction with video encoders still relies on software-layer relay control, further increasing system overhead.

[0057] In order to solve the above technical problems, an embodiment of the present application provides a bit rate adjustment method, which adaptively adjusts the frame rate and the length of the GOP, and adaptively updates the bit rate, so as to provide an efficient, low-coupled frame rate adaptive encoding mechanism, thereby eliminating the need for manual intervention and improving the bit rate stability.

[0058] Figure 2 is a flow chart of a bit rate adjustment method provided according to an embodiment of the present application, such as Figure 2 As shown, in the embodiment of the present application, the application is described by taking the application on a terminal having a video encoder and a software development kit as an example. The method comprises the following steps:

[0059] In step 201, the terminal obtains encoding parameters of the (t+1)th frame of the image to be compressed; the encoding parameters include the (t+1)th frame rate and the (t+1)th GOP length; t is an integer greater than or equal to 1. The image to be compressed is a part of the video to be compressed.

[0060] For ease of understanding, the frame rate and GOP frame rate are explained: Frame rate refers to the number of frames transmitted or displayed per second (fps), which directly affects the smoothness of the video. For example, 30fps means that 30 continuous frames are processed per second. The higher the value, the smoother the action. GOP is a continuous frame sequence consisting of I frames (key frames), P frames (forward prediction frames) and B frames (bidirectional prediction frames), and is also the basic unit of video encoding and decoding. A GOP usually starts with an I frame and contains several P / B frames until the next I frame appears. The frame rate determines the amount of data required per unit time. A high frame rate requires a higher bit rate support, otherwise the image quality may be reduced due to the reduction of the bit rate allocated to a single frame. For example, the high frame rate is set to 60fps. The length of the GOP affects the compression efficiency; a larger GOP length improves the compression rate by increasing the proportion of P / B frames, but a too large GOP length will lead to the risk of error propagation, especially when the scene changes suddenly, the original GOP in the I frame must be forcibly inserted. For example, the length of the GOP is 300.

[0061] The following further explains the frame rate and GOP length in combination with different scenarios. Optionally, under the condition of constant bit rate, increasing the length of GOP can improve the quality of a single frame. Optionally, in low frame rate scenarios, setting the length of GOP too long may cause the picture to jump, so the length of GO P needs to be shortened to increase the density of I frames to maintain visual continuity. For example, the low frame rate is set to 24fps. Optionally, dynamic content uses a smaller GOP length and a higher frame rate to ensure the detail capture and instant error correction capabilities of fast-moving pictures. For example, the dynamic content is a sports event, the length of GOP is set to 30 to 60, and the frame rate is set to 60fps. Among them, high dynamic scenes need to reserve a higher bit rate for I frames to prevent the insufficient quality of key frames from affecting subsequent frame decoding. For example, the bit rate of I frames is 2 to 3 times that of P frames. Optionally, static content can increase the length of GOP and reduce the frame rate to improve compression efficiency. For example, the static content is a conference recording, the length of GOP is set to 120, and the frame rate is set to 30fps. Optionally, since the I frame interval is strongly related to the GOP length, it is recommended that the GOP value be an integer multiple of the frame rate to avoid I frame misalignment due to non-integer multiples. For example, 30fps corresponds to a GOP length of any one of 30, 60, and 90.

[0062] In some embodiments, before step 201, it also includes: adjusting the initial flag of the encoding channel to the target flag; the target flag indicates adjusting the bit rate; the initial flag indicates not adjusting the target flag. Optionally, the initial flag is adjusted to the target flag through a software development kit. For example, the initial flag is represented by "0". The target flag is represented by "1". That is, when the flag position is "0", the bit rate adjustment algorithm of the present application is not called. When the flag position is "1", the bit rate adjustment algorithm of the present application is automatically called. When the bit rate adjustment algorithm is automatically called, there is no need to frequently call the video encoding API, which may cause resource competition or thread blocking, especially in multi-channel video encoding scenarios, thereby solving problems such as encoding delay or frame loss. In addition, in low-light environments, the real-time data interaction between the image sensor and the video encoder does not need to rely on the transit control of the software layer, thereby reducing system overhead.

[0063] In some embodiments, the video encoder creates at least one encoding channel, each encoding channel is provided with an API interface, and the software development kit configures and adjusts the operating parameters of each encoding channel through the API interface. For example, the operating parameters include an initial flag. The initial flag is used to adjust the encoding algorithm.

[0064] In some embodiments, the terminal determines the (t+1)th frame rate based on the number of frames and a preset statistical period; the number of frames is the number of images to be compressed acquired within the preset statistical period.

[0065] It should be understood that the preset statistical period is a time window for the video encoder to perform bit rate allocation, motion prediction or quality assessment, which is usually directly related to the frame rate. Optionally, if the preset statistical period is a fixed time, for example, 1s, when the frame rate increases, the number of frames processed within the preset statistical period increases, and the single frame bit rate needs to be reallocated to avoid image quality degradation. Optionally, in a dynamic scene, when the frame rate increases, the number of frames acquired per unit time doubles. The video encoder needs to shorten the preset statistical period, for example, from 1 second to 0.5 seconds, to adapt to more intensive motion changes, so as to avoid dynamic area blur or residual information loss due to insufficient single frame bit rate allocation. Optionally, in a static scene, when the frame rate decreases, the preset statistical period time is extended, for example, from 1 second to 2 seconds, and the video encoder needs to extend the prediction reference interval to avoid a decrease in motion compensation accuracy and the problem of smearing or tearing in the dynamic area.

[0066] In the first example, in order to solve the above problem caused by the preset statistical period being a fixed time, if the (t+1)th frame rate does not match the tth frame rate, the terminal adjusts the preset statistical period to obtain an updated statistical period. The (t+1)th frame rate is the frame rate obtained in the (t+1)th preset statistical period.

[0067] In the second example, in order to solve the above-mentioned problem caused by the preset statistical period being a fixed time, the terminal determines the (t+1)th frame rate based on the (t+1)th time difference and the preset value; the (t+1)th time difference is obtained based on the timestamp of the (t+1)th frame of the image to be compressed and the timestamp of the tth frame of the image to be compressed. Optionally, the terminal determines the (t+1)th frame rate based on the (t+1)th time difference and the preset value. For example, the preset value is 1s, the (t+1)th frame rate = 1 / (t+1)th time difference, then the (t+1)th time difference = the timestamp of the (t+1)th frame of the image to be compressed - the timestamp of the tth frame of the image to be compressed.

[0068] Figure 3 It is a flow chart provided according to an embodiment of the present application.

[0069] Combine the following Figure 3 An exemplary description is given of the adaptive adjustment of the frame rate and the length of the GOP.

[0070] In step 202, if the (t+1)th frame rate does not match the tth frame rate, the terminal determines the (t+1)th bit rate based on the (t+1)th frame rate, the tth frame rate and the tth bit rate. The tth bit rate is the encoding bit rate for encoding the tth frame of the image to be compressed.

[0071] In some embodiments, for the (t+1)th frame rate, if the (t+1)th frame rate does not match the tth frame rate, that is, the (t+1)th frame rate has changed relative to the tth frame rate, then it is necessary to update the tth frame rate to the (t+1)th frame rate, so that after obtaining the (t+2)th frame rate, the (t+2)th frame rate is compared with the (t+1)th frame rate, thereby updating the frame rate according to the change in the frame rate. Optionally, if the (t+1)th frame rate matches the tth frame rate, that is, the (t+1)th frame rate has not changed relative to the tth frame rate, then it is not necessary to update the tth frame rate to the (t+1)th frame rate, so that after obtaining the (t+2)th frame rate, the (t+2)th frame rate is compared with the tth frame rate. From the above analysis, it can be seen that in the embodiment of the present application, since the encoding bit rate and the frame rate are in one-to-one correspondence, whether the bit rate needs to be adjusted is determined by comparing whether the (t+1)th frame rate has changed relative to the tth frame rate.

[0072] In some embodiments, the terminal obtains the (t+1)th frame rate and the length of the (t+1)th GOP, compares the (t+1)th frame rate with the tth frame rate, and compares the length of the (t+1)th GOP with the length of the tth GOP. If the (t+1)th frame rate is consistent with the tth frame rate, and the length of the (t+1)th GOP is consistent with the length of the tth GOP, then the (t+1)th frame rate matches the tth frame rate, and the length of the (t+1)th GOP matches the length of the tth GOP. Or if the (t+1)th frame rate is inconsistent with the tth frame rate, and the length of the (t+1)th GOP is inconsistent with the length of the tth GOP, then the (t+1)th frame rate does not match the tth frame rate, and the length of the (t+1)th GOP does not match the length of the tth GOP. In this case, if the (t+1)th frame to be compressed is still encoded with the tth bit rate and the tth GOP length, the tth bit rate and the tth GOP length will not match the (t+1)th frame to be compressed, thus affecting the image quality.

[0073] In some embodiments, if the (t+1)th frame rate matches the tth frame rate, the terminal does not need to adjust the bit rate and uses the tth bit rate as the encoding bit rate of the (t+1)th frame of the image to be compressed.

[0074] It should be understood that when the frame rate changes, if the video encoder does not adjust the parameters and still processes according to the previous single frame bit rate, but the actual number of input frames decreases, the actual output bit rate per frame will be insufficient, thereby causing compression distortion. Among them, single frame bit rate = initial bit rate / frame rate. In addition, the length of the GOP corresponds to the extension of time, and the key frame interval is too long, which will cause the dynamic scene residual error to accumulate, and the picture will be partially blurred or torn. Optionally, when the frame rate is reduced, the video encoder still allocates the single frame bit rate according to the tth frame rate, but the actual number of input frames is reduced, which will cause the actual output bit rate to decrease. For example, assuming that the initial bit rate remains unchanged, when the initial bit rate is 1280kbps, the length of the GOP is 30, the tth frame rate is 15fps, and the (t+1)th frame rate is 4fps. If the single frame bit rate is still allocated at 15fps, the actual output bit rate is 247.34kbps, then the actual output bit rate is only 19.3% of the initial bit rate. In this case, problems such as coding mosaics and coding block effects will occur. The actual output bit rate is calculated based on the product of the single frame bit rate and the actual number of frames. Optionally, if the video encoder does not adjust the parameters and still processes at the previous single frame bit rate, but the actual number of input frames increases, the actual output bit rate will double, thereby wasting bandwidth resources. For example, assuming that the initial bit rate remains unchanged, when the initial bit rate is 1280kbps, the length of the GOP is 30, the tth frame rate is 4fps, and the (t+1)th frame rate is 15fps, if the single frame bit rate is still allocated at 4fps, referring to the above calculation method, the actual output bit rate is much greater than the initial bit rate.

[0075] Through the above analysis, it can be known that when the frame rate changes, if the video encoder does not synchronously adjust the encoding bit rate and the single frame rate, the bit rate allocation logic is mismatched with the actual data requirements, resulting in the "encoding bit rate-frame rate-image quality" balance being destroyed. Combined with the above analysis content, the software development kit of the present application automatically adjusts the tth frame rate to the (t+1)th frame rate and the length of the (t+1)th GOP to the length of the (t+1)th GOP when determining that the (t+1)th frame rate and the length of the (t+1)th GOP are inconsistent with the tth frame rate and the length of the tth GOP. That is, in the embodiment of the present application, it is not necessary to update the encoding frame rate according to the frame rate of different image sensors, but only to adjust the initial flag bit to the target flag bit, and the software development kit automatically determines the bit rate and GOP length required for encoding according to the (t+1)th frame rate and the length of the (t+1)th GOP. The software development kit automatically updates the frame rate and GOP length required for encoding according to the (t+1)th frame rate and the (t+1)th GOP length, that is, the frame rate and GOP length of the t-th frame to be compressed are updated to the (t+1)th frame rate and the (t+1)th GOP length, respectively. In other words, the embodiment of the present application does not require the application to additionally implement the logic of image sensor frame rate monitoring and video encoder interface call, and can realize adaptive adjustment of frame rate and bit rate, thereby reducing code maintenance and debugging costs, and also reducing the probability of error.

[0076] Figure 4 It is a flowchart of step 202 provided according to an embodiment of the present application.

[0077] Combine the following Figure 4 Step 202 is exemplarily described.

[0078] In some embodiments, step 202 includes the following steps 2021 and 2022:

[0079] In step 2021, the terminal obtains the ratio between the (t+1)th frame rate and the tth frame rate.

[0080] In step 2022, the terminal determines the (t+1)th code rate based on the ratio and the tth code rate.

[0081] Optionally, ratio=(t+1)th frame rate÷tth frame rate.

[0082] In some embodiments, the (t+1)th code rate 2022 in the above step may be implemented as follows: the product of the ratio and the tth code rate is used as the (t+1)th code rate.

[0083] Optionally, the (t+1)th bit rate=(t+1)th frame rate÷tth frame rate×tth bit rate.

[0084] For example, the initial bit rate is 1280kbps, the GOP length is 30, the tth frame rate is 15fps, and the (t+1)th frame rate is 4fps. After adjusting the bit rate, the actual output bit rate is 1059.83kbps, which is close to the initial bit rate. This solves the coding mosaic, coding block effect, etc., thereby stabilizing the image quality.

[0085] In addition, the embodiments of the present application are applicable to various scenarios, such as indoors or outdoors, etc., and can quickly respond to changes in video content and adjust the bit rate in real time.

[0086] Through the above analysis, it can be known that after the frame rate is automatically adjusted, the encoding rate required for encoding the (t+1)th frame to be compressed image, that is, the (t+1)th rate, can be directly calculated based on the previous encoding rate and the adjusted frame rate. The calculation method of the encoding rate of the present application is simple and easy to implement.

[0087] In step 203, the terminal uses the (t+1)th code rate as the encoding code rate, and uses the length of the (t+1)th GOP as the length of the encoded GOP.

[0088] In some embodiments, based on the (t+1)th bit rate and the length of the (t+1)th GOP, the (t+1)th frame of the image to be compressed is encoded to obtain an encoding result.

[0089] In some embodiments, if the (t+1)th frame rate matches the tth frame rate, the encoding bit rate of the tth frame to be compressed is directly used as the encoding bit rate of the (t+1)th frame to be compressed. That is, the (t+1)th frame to be compressed is encoded based on the tth bit rate and the length of the tth GOP to obtain an encoding result.

[0090] It should be noted that the encoding process can be obtained from the relevant technology and will not be described in detail in the embodiments of the present application.

[0091] In an embodiment of the present application, the encoding parameters of the (t+1)th frame of the image to be compressed are obtained; the encoding parameters include the (t+1)th frame rate and the length of the (t+1)th GOP; if the (t+1)th frame rate does not match the tth frame rate, the (t+1)th bit rate is determined based on the (t+1)th frame rate, the tth frame rate and the tth bit rate; the (t+1)th bit rate is used as the encoding bit rate, and the length of the (t+1)th GOP is used as the length of the encoding GOP. The above technical scheme realizes adaptive adjustment of the frame rate and the length of the GOP, and adaptively adjusts the bit rate according to the adjusted frame rate, thereby achieving a stable bit rate effect. In addition, the image to be compressed is encoded based on the adjusted bit rate and the length of the GOP, thereby achieving a stable image quality effect.

[0092] Figure 5 is a structural diagram of a bit rate adjustment device 500 provided according to an embodiment of the present application, the device comprising:

[0093] The acquisition module 501 is used to acquire the encoding parameters of the (t+1)th frame to be compressed; the encoding parameters include the (t+1)th frame rate and the length of the (t+1)th GOP; t is an integer greater than or equal to 1;

[0094] an adjustment module 502 for determining a (t+1)th bit rate based on the (t+1)th frame rate, the tth frame rate and the tth bit rate if the (t+1)th frame rate does not match the tth frame rate;

[0095] The determination module 503 is configured to use the (t+1)th bit rate as the encoding bit rate, and use the (t+1)th GOP length as the encoding GOP length.

[0096] In a possible implementation, determining the (t+1)th bit rate based on the (t+1)th frame rate, the tth frame rate, and the tth bit rate includes:

[0097] Get the ratio between the (t+1)th frame rate and the tth frame rate;

[0098] Based on the ratio and the tth code rate, a (t+1)th code rate is determined.

[0099] In a possible implementation, determining the (t+1)th code rate based on the ratio and the tth code rate includes:

[0100] The product of the ratio and the t-th code rate is taken as the (t+1)-th code rate.

[0101] In a possible implementation, the method further includes:

[0102] Based on the number of frames and a preset statistical period, the (t+1)th frame rate is determined; the number of frames is the number of images to be compressed obtained within the preset statistical period.

[0103] In a possible implementation, the method further includes: if the (t+1)th frame rate does not match the tth frame rate, adjusting the preset statistical period to obtain an updated statistical period.

[0104] In a possible implementation, the method further includes:

[0105] Adjust the initial flag of the encoding channel to the target flag; the target flag indicates adjusting the bit rate; the initial flag indicates not adjusting the target flag.

[0106] In a possible implementation, the method further includes:

[0107] If the (t+1)th frame rate matches the tth frame rate, the (t+1)th frame of the image to be compressed is encoded based on the tth bit rate and the length of the tth GOP to obtain an encoding result.

[0108] In a possible implementation, the method further includes: encoding the (t+1)th frame of the image to be compressed based on the encoding bit rate and the length of the encoding GOP to obtain an encoding result.

[0109] It should be noted that: when the bit rate adjustment device provided in the above embodiment performs the corresponding steps, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the bit rate adjustment device provided in the above embodiment and the bit rate adjustment method embodiment belong to the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.

[0110] In an embodiment of the present application, the encoding parameters of the (t+1)th frame of the image to be compressed are obtained; the encoding parameters include the (t+1)th frame rate and the length of the (t+1)th GOP; if the (t+1)th frame rate does not match the tth frame rate, the (t+1)th bit rate is determined based on the (t+1)th frame rate, the tth frame rate and the tth bit rate; the (t+1)th bit rate is used as the encoding bit rate, and the length of the (t+1)th GOP is used as the length of the encoding GOP. The above technical scheme realizes adaptive adjustment of the frame rate and the length of the GOP, and adaptively adjusts the bit rate according to the adjusted frame rate, thereby achieving a stable bit rate effect. In addition, the image to be compressed is encoded based on the adjusted bit rate and the length of the GOP, thereby achieving a stable image quality effect.

[0111] An embodiment of the present application further provides a computer device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, and the processor implements the above method when executing the computer program.

[0112] Taking computer equipment as the terminal as an example, Figure 6 This is a schematic diagram of the structure of a terminal provided in an embodiment of the present application, see Figure 6 The terminal 600 may be a smart phone, a tablet computer, an MP3 player (Moving Picture Experts Group Audio Layer III), an MP4 player (Moving Picture Experts Group Audio Layer IV), a laptop computer or a desktop computer. The terminal 600 may also be called a user device, a portable terminal, a laptop terminal, a desktop terminal or other names.

[0113] Typically, the terminal 600 includes a processor 601 and a memory 602 .

[0114] The processor 601 may include one or more processing cores, such as a 4-core processor, a 5-core processor, etc. The processor 601 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 601 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 601 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 601 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.

[0115] The memory 602 may include one or more computer-readable storage media, which may be non-transitory. The memory 602 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 602 is used to store at least one program code, which is used to be executed by the processor 601 to implement the process provided by the method embodiment of the present application for the terminal execution in the above method.

[0116] In some embodiments, the terminal 600 may further optionally include: a peripheral device interface 603 and at least one peripheral device. The processor 601, the memory 602 and the peripheral device interface 603 may be connected via a bus or a signal line. Each peripheral device may be connected to the peripheral device interface 603 via a bus, a signal line or a circuit board. Specifically, the peripheral device includes: at least one of a display screen 604, a camera assembly 605, an audio circuit 606 and a power supply 607.

[0117] The peripheral device interface 603 can be used to connect at least one peripheral device related to I / O (Input / Output) to the processor 601 and the memory 602. In some embodiments, the processor 601, the memory 602, and the peripheral device interface 603 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 601, the memory 602, and the peripheral device interface 603 can be implemented on a separate chip or circuit board, which is not limited in the embodiments of the present application.

[0118] The display screen 604 is used to display the UI (User Interface). The UI may include graphics, text, icons, videos, and any combination thereof. When the display screen 604 is a touch display screen, the display screen 604 also has the ability to collect touch signals on the surface or above the surface of the display screen 604. The touch signal can be input to the processor 601 as a control signal for processing. At this time, the display screen 604 can also be used to provide virtual buttons and / or virtual keyboards, also known as soft buttons and / or soft keyboards. In some embodiments, the display screen 604 can be one, set on the front panel of the terminal 600; in other embodiments, the display screen 604 can be at least two, respectively set on different surfaces of the terminal 600 or in a folding design; in other embodiments, the display screen 604 can be a flexible display screen, set on the curved surface or folding surface of the terminal 600. Even, the display screen 604 can also be set to a non-rectangular irregular shape, that is, a special-shaped screen. The display screen 604 can be made of materials such as LCD (Liquid Crystal Display), OLED (Organic Light-Emitting Diode, organic light-emitting diode).

[0119] The camera assembly 605 is used to capture images or videos. In some embodiments, the camera assembly 605 includes a front camera and a rear camera. Typically, the front camera is disposed on the front panel of the terminal, and the rear camera is disposed on the back of the terminal. In some embodiments, there are at least two rear cameras, which are any one of a main camera, a depth of field camera, a wide-angle camera, and a telephoto camera, so as to realize the fusion of the main camera and the depth of field camera to realize the background blur function, the fusion of the main camera and the wide-angle camera to realize panoramic shooting and VR (Virtual Reality) shooting function or other fusion shooting functions. In some embodiments, the camera assembly 605 may also include a flash. The flash may be a monochrome temperature flash or a dual-color temperature flash. A dual-color temperature flash refers to a combination of a warm light flash and a cold light flash, which can be used for light compensation at different color temperatures.

[0120] The audio circuit 606 may include a microphone and a speaker. The microphone is used to collect sound waves from the user and the environment, and convert the sound waves into electrical signals and input them into the processor 601 for processing. For the purpose of stereo acquisition or noise reduction, there may be multiple microphones, which are respectively arranged at different parts of the terminal 600. The microphone may also be an array microphone or an omnidirectional acquisition microphone. The speaker is used to convert the electrical signal from the processor 601 into sound waves. The speaker may be a traditional film speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can not only convert the electrical signal into sound waves audible to humans, but also convert the electrical signal into sound waves inaudible to humans for purposes such as ranging. In some embodiments, the audio circuit 606 may also include a headphone jack.

[0121] The power supply 607 is used to power various components in the terminal 600. The power supply 607 can be an alternating current, a direct current, a disposable battery, or a rechargeable battery. When the power supply 607 includes a rechargeable battery, the rechargeable battery can support wired charging or wireless charging. The rechargeable battery can also be used to support fast charging technology.

[0122] Those skilled in the art will understand that Figure 5 The structure shown in the figure does not constitute a limitation on the terminal 600, and the terminal 600 may include more or less components than those shown in the figure, or combine some components, or adopt a different component arrangement.

[0123] Take the computer device as a server as an example. Figure 7 It is a structural diagram of a server provided in an embodiment of the present application. The server 700 may have relatively large differences due to different configurations or performances, and may include one or more processors (Central Processing Units, CPU) 701 and one or more memories 702, wherein the one or more memories 702 store at least one computer program, and the at least one computer program is loaded and executed by the one or more processors 701 to implement the above-mentioned bit rate adjustment method. Of course, the server 700 may also have components such as a wired or wireless network interface, a keyboard, and an input and output interface for input and output. The server 700 may also include other components for implementing device functions, which will not be described in detail here.

[0124] The embodiment of the present application also provides a computer-readable storage medium, the computer-readable storage medium includes a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute the above method. Optionally, the computer-readable storage medium can be a read-only memory (ROM), a random access memory (RAM), a compact disc (CD-ROM), a magnetic tape, a floppy disk, an optical data storage device, etc.

[0125] A person skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.

[0126] The above description is only an optional embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.

Claims

1. A bit rate adjustment method, characterized in that: include: Obtaining encoding parameters of the (t+1)th frame of the image to be compressed; the encoding parameters include the (t+1)th frame rate and the length of the (t+1)th GOP; t is an integer greater than or equal to 1; If the (t+1)th frame rate does not match the tth frame rate, determining the (t+1)th bit rate based on the (t+1)th frame rate, the tth frame rate and the tth bit rate; The (t+1)th code rate is used as the encoding code rate, and the (t+1)th GOP length is used as the encoding GOP length.

2. The method according to claim 1, characterized in that The determining the (t+1)th bit rate based on the (t+1)th frame rate, the tth frame rate, and the tth bit rate comprises: Obtaining a ratio between the (t+1)th frame rate and the tth frame rate; Based on the ratio and the tth code rate, a (t+1)th code rate is determined.

3. The method according to claim 2, characterized in that The determining the (t+1)th code rate based on the ratio and the tth code rate includes: The product of the ratio and the t-th code rate is used as the (t+1)-th code rate.

4. The method according to claim 1, characterized in that: The method further comprises: Based on a preset number of frames and a preset statistical period, the (t+1)th frame rate is determined; the number of frames is the number of the images to be compressed acquired within the preset statistical period.

5. The method according to claim 4, characterized in that The method further comprises: If the (t+1)th frame rate does not match the tth frame rate, the preset statistical period is adjusted to obtain an updated statistical period.

6. The method according to claim 1, characterized in that The method further comprises: The initial flag of the coding channel is adjusted to the target flag; the target flag indicates adjusting the code rate; the initial flag indicates not adjusting the target flag.

7. The method according to claim 1, characterized in that The method further comprises: If the (t+1)th frame rate matches the tth frame rate, the (t+1)th frame of the image to be compressed is encoded based on the tth bit rate and the length of the tth GOP to obtain an encoding result.

8. The method according to claim 1, characterized in that: The method further comprises: Based on the encoding bit rate and the length of the encoding GOP, the (t+1)th frame of the image to be compressed is encoded to obtain an encoding result.

9. A bit rate adjustment device, characterized in that: include: An acquisition module, used for acquiring encoding parameters of the (t+1)th frame of the image to be compressed; The encoding parameters include the (t+1)th frame rate and the length of the (t+1)th GOP; t is an integer greater than or equal to 1; an adjusting module, configured to determine the (t+1)th bit rate based on the (t+1)th frame rate, the tth frame rate and the tth bit rate if the (t+1)th frame rate does not match the tth frame rate; The determination module is used to use the (t+1)th bit rate as the encoding bit rate and the (t+1)th GOP length as the encoding GOP length.

10. A computer device, characterized in that: The computer device includes a processor and a memory, wherein the memory is used to store at least one program, and the at least one program is loaded by the processor and executes the bit rate adjustment method according to any one of claims 1 to 8.

11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores at least one program, and the at least one program is loaded and executed by the processor to implement the bit rate adjustment method according to any one of claims 1 to 8.