Code rate adjustment method
By dynamically adjusting the bit rate to match the network environment, the lag and delay problems caused by network damage in the wide area network are solved, and the video fluency is automatically adjusted and real-time playback is realized.
Patent Information
- Application Number
- CN202311738488.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-15
- Publication Date
- 2025-06-17
AI Technical Summary
In WAN interaction, network damage such as delay, packet loss and bandwidth limitations lead to lag or delay in live video broadcasting, and the prior art cannot achieve automatic adjustment of video fluency.
Provide a bit rate adjustment method, which dynamically obtains the sending data rate and cache duration of the receiving device, and dynamically adjusts the bit rate to match the network environment to ensure video fluency.
It realizes automatic adjustment of video fluency, ensures that the receiver device can play video in real time, and improves the matching of video fluency and network environment.
Smart Images

Figure CN120166243A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of video technology, and in particular to a bit rate adjustment method. Background Art
[0002] In wide area network interactions, various network impairments exist, such as network latency, network packet loss, or bandwidth limitations, etc. These network impairments will lead to a decline in data transmission capabilities. Especially in the monitoring video service, insufficient data transmission capabilities will cause the live video to freeze or the latency to increase.
[0003] In the related art, when the video freezes or the latency increases, usually the user manually modifies the video clarity, such as switching from ultra-high definition to high definition, or from high definition to standard definition, and uses a lower quality level to try to restore the smooth playback of the video.
[0004] However, in the above-mentioned related art, it is necessary for the user to manually modify the video clarity to adjust the video smoothness, and the automatic adjustment of the video smoothness cannot be achieved. Summary of the Invention
[0005] Aiming at the problems existing in the prior art, the present invention provides a bit rate adjustment method.
[0006] The present invention provides a bit rate adjustment method, including:
[0007] In the case of a dynamic picture, obtain the first transmission data rate sent by the receiving end device; the first transmission data rate is determined by the receiving end device based on the data volume of the current dynamic picture I frame received and the first receiving duration corresponding to the current dynamic picture I frame;
[0008] Based on the data volume of the dynamic picture I frame and the data volumes of the first preset number of dynamic picture P frames after the current dynamic picture I frame, determine the dynamic average generated data rate;
[0009] In the case where the dynamic average generated data rate is less than or equal to the first transmission data rate multiplied by a second preset number, determine the first target bit rate based on the first buffer duration; the first buffer duration is the difference between the first current moment and the moment when the first current buffer data is written into the buffer area; the first current buffer data is the remaining live data when sending the first live data generated based on the current bit rate to the receiving end device based on the first transmission data rate; the first target bit rate is used to generate new live data.
[0010] According to a bit rate adjustment method provided by the present invention, the determining the first target bit rate based on the first buffer duration includes:
[0011] When the first preset condition is satisfied, increase the current code rate to obtain the first target code rate;
[0012] The first preset condition includes any one of the following:
[0013] After the first live data of the first preset duration is generated, the first buffer duration is less than the first delay threshold;
[0014] After the first live data of the first preset duration is generated, the first buffer duration is less than the first delay threshold, and the difference between the current time and the time of the last code rate reduction is greater than the first preset threshold; the first preset threshold is used to represent the duration for suppressing the oscillation switching of the gear;
[0015] After the first live data of the first preset duration is generated, the first buffer duration is greater than or equal to the first delay threshold, and after the second live data of the second preset duration is continuously generated, the second buffer duration is less than the second delay threshold; the first delay threshold is less than the second delay threshold, the second buffer duration is the difference between the second current time and the time when the second current buffer data is written into the buffer area, and the second current buffer data is the remaining live data when the third live data is sent to the receiving end device based on the first transmission data rate, and the third live data includes the second live data and the first current buffer data;
[0016] After the first live data of the first preset duration is generated, the first buffer duration is greater than or equal to the first delay threshold, and after the second live data of the second preset duration is continuously generated, the second buffer duration is less than the second delay threshold, and the difference between the current time and the time of the last code rate reduction is greater than the first preset threshold.
[0017] According to a code rate adjustment method provided by the present invention, the method further includes:
[0018] After the second live data of the second preset duration is continuously generated, when the second buffer duration is greater than or equal to the second delay threshold, reduce the current code rate to obtain the first target code rate.
[0019] According to a code rate adjustment method provided by the present invention, after reducing the current code rate to obtain the first target code rate, the method further includes:
[0020] When the second preset condition is satisfied, reduce the first target code rate to obtain the second target code rate;
[0021] The second preset condition includes any one of the following:
[0022] The third buffer duration is greater than or equal to a second preset threshold; the second preset threshold is used to represent the duration of severe network congestion, and the third buffer duration is the difference between a third current moment and the moment when third current buffer data is written into the buffer area, and the third current buffer data is the live data remaining when sending second current buffer data to the receiving end device based on the first transmission data rate;
[0023] When the third buffer duration is less than the second preset threshold, the third buffer duration is greater than or equal to the second delay threshold, and after continuously generating fourth live data for a third preset duration, the consumption speed of the remaining buffer data in the buffer area is less than a preset speed; the remaining buffer data is the live data remaining when sending the fourth live data and historical buffered live data in the buffer area to the receiving end device; the second target bitrate is used to generate new live data.
[0024] According to a bitrate adjustment method provided by the present invention, the method further includes:
[0025] When the dynamic average generated data rate is greater than a second preset multiple of the first transmission data rate, reduce the current bitrate to obtain a third target bitrate; the third target bitrate is used to generate new live data.
[0026] According to a bitrate adjustment method provided by the present invention, the method further includes:
[0027] In the case of a static picture, obtain a second transmission data rate sent by the receiving end device; the second transmission data rate is determined by the receiving end device based on the data volume of the received current static picture I-frame and the second receiving duration corresponding to the current static picture I-frame;
[0028] Based on the data volume of the static picture I-frame and the data volume of the static picture P-frame, determine the static average generated data rate;
[0029] Based on the second transmission data rate and the static average generated data rate, determine a fourth target bitrate; the fourth target bitrate is used to generate new live data.
[0030] According to a bitrate adjustment method provided by the present invention, the determining the fourth target bitrate based on the second transmission data rate and the static average generated data rate includes:
[0031] When the static average generated data rate is greater than the second transmission data rate, reduce the current bitrate to obtain the fourth target bitrate.
[0032] According to a bitrate adjustment method provided by the present invention, the method further includes:
[0033] When the static average generated data rate is less than or equal to the second transmission data rate and the static picture I-frame generated data rate is greater than the second transmission data rate, determine a target buffer duration based on the static picture I-frame generated data rate, the static picture P-frame generated data rate, and the second transmission data rate;
[0034] Send the target buffer duration to the receiving end device; the target buffer duration is used to indicate that the receiving end device caches the live data within the target buffer duration.
[0035] According to a bitrate adjustment method provided by the present invention, the method further includes:
[0036] When a third preset condition is satisfied, increase the current bitrate to obtain the fourth target bitrate;
[0037] The third preset condition includes any one of the following:
[0038] The static picture I-frame generated data rate is less than or equal to the second transmission data rate;
[0039] The static picture I-frame generated data rate is less than or equal to the second transmission data rate, and the difference between the current moment and the moment of the last bitrate reduction is greater than the first preset threshold.
[0040] According to a bitrate adjustment method provided by the present invention, the method further includes:
[0041] When the difference between the current flow start moment and the last flow stop moment is less than the effective duration of the historical record, determine the bitrate corresponding to the last flow stop moment as the current bitrate.
[0042] The present invention also provides a bitrate adjustment device, including:
[0043] A first acquisition unit, configured to, in the case of a dynamic picture, acquire a first transmission data rate sent by a receiving end device; the first transmission data rate is determined by the receiving end device based on the data volume of the currently received dynamic picture I-frame and the first reception duration corresponding to the current dynamic picture I-frame;
[0044] A first determination unit, configured to determine a dynamic average generated data rate based on the data volume of the dynamic picture I-frame and the data volumes of the first preset number of dynamic picture P-frames after the current dynamic picture I-frame;
[0045] A second determination unit, configured to determine a first target bitrate based on a first buffer duration when the dynamically averaged generated data rate is less than or equal to a second preset multiple of the first transmission data rate; the first buffer duration is the difference between the first current moment and the moment when the first current buffered data is written into the buffer; the first current buffered data is the remaining live data when transmitting first live data generated based on the current bitrate to the receiving end device based on the first transmission data rate; the first target bitrate is used to generate new live data.
[0046] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, the method for adjusting the bitrate as described in any one of the above is implemented.
[0047] The present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the method for adjusting the bitrate as described in any one of the above is implemented.
[0048] The present invention also provides a computer program product, including a computer program. When the computer program is executed by a processor, the method for adjusting the bitrate as described in any one of the above is implemented.
[0049] The bitrate adjustment method provided by the present invention, in the case where the video picture is a dynamic picture, determines the dynamically averaged generated data rate based on the data amounts of the first preset number of dynamic picture P frames after the dynamic picture I frame and the data amount of the dynamic picture I frame. When the dynamically averaged generated data rate is less than or equal to a second preset multiple of the first transmission data rate, the first target bitrate is determined based on the first buffer duration, and the newly determined first target bitrate is used to generate new live data, so that the generation rate of the new live data matches the current network environment of the receiving end device. In this way, the receiving end device can play the new live data in real time when receiving the new live data, thereby improving the smoothness of playing the new live data by the receiving end device and realizing the automatic adjustment of the video smoothness. Description of the Drawings
[0050] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0051] Figure 1 is one of the flowcharts of the bitrate adjustment method provided by the embodiments of the present invention;
[0052] Figure 2It is the second schematic flowchart of the bit rate adjustment method provided by the embodiment of the present invention;
[0053] Figure 3 It is the third schematic flowchart of the bit rate adjustment method provided by the embodiment of the present invention;
[0054] Figure 4 It is the overall schematic flowchart of the bit rate adjustment method for dynamic pictures provided by the embodiment of the present invention;
[0055] Figure 5 It is the overall schematic flowchart of the bit rate adjustment method for static pictures provided by the embodiment of the present invention;
[0056] Figure 6 It is the schematic structural diagram of the bit rate adjustment device provided by the embodiment of the present invention;
[0057] Figure 7 It is the schematic physical structure diagram of the electronic device provided by the embodiment of the present invention. Detailed implementation manners
[0058] To make the objectives, technical solutions and advantages of the present invention clearer, the technical solutions in the present invention will be clearly and completely described below with reference to the accompanying drawings in the present invention. Apparently, the described embodiments are some but not all of the embodiments of the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present invention without creative efforts shall fall within the protection scope of the present invention.
[0059] The following combines Figures 1 - 5 to describe the bit rate adjustment method of the present invention. The execution subject of the bit rate adjustment method can be an electronic device such as a camera device for monitoring a live environment, or a bit rate adjustment device provided in the electronic device, and the bit rate adjustment device can be implemented by software, hardware or a combination of both.
[0060] Figure 1 It is the first schematic flowchart of the bit rate adjustment method provided by the embodiment of the present invention. As Figure 1 shown, the bit rate adjustment method includes the following steps:
[0061] Step 101, in the case of a dynamic picture, obtain the first transmission data rate sent by the receiving end device; the first transmission data rate is determined by the receiving end device based on the data volume of the current dynamic picture I frame and the first receiving duration corresponding to the current dynamic picture I frame.
[0062] Among them, a dynamic picture refers to a picture containing dynamic elements. A dynamic picture is composed of multiple static pictures. The current dynamic picture I-frame refers to the complete dynamic picture I-frame currently received by the receiving device. The data volume of the current dynamic picture I-frame refers to the number of bytes occupied by the encoding of the current dynamic picture I-frame. The first reception duration is the duration required for the receiving device to start receiving the current dynamic picture I-frame until it finishes receiving the current dynamic picture I-frame.
[0063] Exemplarily, for a dynamic picture, the receiving device divides the data volume of the complete current dynamic picture I-frame received by the first reception duration to calculate the first transmission data rate. The first transmission data rate is used to characterize the transmission capacity of the current link and is fed back to the camera device so that the camera device can obtain the first transmission data rate. For example, the data volume of the complete current dynamic picture I-frame is represented by Data DynamicI and the first reception duration is represented by Δt 1接收帧 , then the first transmission data rate
[0064] Step 102: Determine the dynamic average generated data rate based on the data volume of the dynamic picture I-frame and the data volumes of the first preset number of dynamic picture P-frames after the current dynamic picture I-frame.
[0065] Exemplarily, the dynamic picture uses the current dynamic picture I-frame and the first X dynamic picture P-frames after the current dynamic picture I-frame as representatives, where X is the first preset number, to predict the subsequent data accumulation situation. For example, the average data volume of the first X dynamic picture P-frames is used to represent the data volume of the dynamic picture P-frame Data DynamicP , then Data DynamicP =(Data DynamicP1 +…+Data DynamicPx ) / X, where Data DynamicP1 represents the first dynamic picture P-frame among the X dynamic picture P-frames, and Data DynamicPX represents the Xth dynamic picture P-frame among the X dynamic picture P-frames. The data volume of the dynamic picture I-frame can be the number of bytes occupied by the encoding of the first dynamic picture I-frame. The data volume of the dynamic picture I-frame can be represented by Data DynamicI , then the dynamic average generated data rate where GOP represents the I-frame interval and Frame represents the frame rate.
[0066] Step 103: When the dynamic average generated data rate is less than or equal to the first transmission data rate multiplied by a second preset quantity, determine a first target code rate based on a first buffer duration; the first buffer duration is the difference between a first current moment and the moment when the first current buffer data is written into the buffer; the first current buffer data is the remaining live data when transmitting first live data generated based on the current code rate to the receiving end device based on the first transmission data rate; the first target code rate is used to generate new live data.
[0067] Exemplarily, when obtaining the dynamic average generated data rate V Dynamic and the first transmission data rate V Send1 , assuming that the second preset quantity is N, N ∈ (1, +∞), compare VD vnamic with N * VS end1 . When V Dynamic ≤ N * V Send1 , it indicates that the current data accumulation speed is still within the short-term allowable range, and there is no need to adjust the current code rate. However, since it is uncertain how long the dynamic picture will last, it is necessary to continue observing for a longer time. During the continuous observation period, both the duration of the dynamic picture and V Dynamic are variable factors, but these variable factors will all be reflected in the buffer duration of the buffer data in the buffer. Therefore, the buffer duration is used to detect the accumulation of the buffer data in the buffer.
[0068] After the imaging device generates the first live data based on the current code rate, it needs to transmit the first live data to the receiving end device based on the first transmission data rate. During the transmission of the first live data, if the receiving end device does not return a successful reception response for the transmission of some live data, it is considered that this part of the live data has not been successfully received by the receiving end device. At this time, this part of the live data needs to be buffered in the buffer. If this part of the live data is the first current buffer data, the difference between the first current moment and the moment when the first current buffer data is written into the buffer is determined as the first buffer duration, and then the current code rate is adjusted based on the size of the first buffer duration to obtain the first target code rate, and the first target code rate is used to generate new live data.
[0069] The bitrate adjustment method provided by the present invention, in the case where the video picture is a dynamic picture, determines the dynamic average generated data rate based on the data amount of the first preset number of dynamic picture P frames after the dynamic picture I frame and the data amount of the dynamic picture I frame. When the dynamic average generated data rate is less than or equal to the second preset number times the first transmission data rate, the first target bitrate is determined based on the first buffer duration, and the newly determined first target bitrate is used to generate new live data, so that the generation rate of the new live data matches the current network environment of the receiving device. In this way, the receiving device can play the new live data in real time when receiving it, thereby improving the smoothness of the receiving device in playing the new live data and realizing the automatic adjustment of the video smoothness. In addition, since the generation rate of the new live data matches the current network environment of the receiving device, it is possible to ensure that no live data is lost during the transmission process and the integrity of the live data can be guaranteed.
[0070] In one embodiment, the above step 103 determines the first target bitrate based on the first buffer duration, and can be specifically implemented in the following manner:
[0071] When the first preset condition is satisfied, increase the current bitrate to obtain the first target bitrate;
[0072] Among them, the first preset condition includes any one of the following:
[0073] Condition 11: After generating the first live data for the first preset duration, the first buffer duration is less than the first delay threshold.
[0074] Condition 12: After generating the first live data for the first preset duration, the first buffer duration is less than the first delay threshold, and the difference between the current time and the time of the last bitrate reduction is greater than the first preset threshold, and the first preset threshold is used to represent the duration for suppressing the oscillation switching of the gear.
[0075] Condition 13: After generating the first live data for the first preset duration, the first buffer duration is greater than or equal to the first delay threshold, and after continuing to generate the second live data for the second preset duration, the second buffer duration is less than the second delay threshold; the first delay threshold is less than the second delay threshold, and the second buffer duration is the difference between the second current time and the time when the second current buffer data is written into the buffer area, and the second current buffer data is the remaining live data when sending the third live data to the receiving device based on the first transmission data rate, and the third live data includes the second live data and the first current buffer data.
[0076] Condition 14: After generating the first live data for the first preset duration, the first buffer duration is greater than or equal to the first delay threshold. After continuing to generate the second live data for the second preset duration, the second buffer duration is less than the second delay threshold, and the difference between the current moment and the moment of the last bitrate reduction is greater than the first preset threshold.
[0077] Exemplarily, for Condition 11, when the dynamically averaged generated data rate is less than or equal to the first transmission data rate multiplied by the second preset quantity, the first live data for the first preset duration T1 is generated. Assuming T1 is 1 s, that is, 1 s of the first live data is generated. When sending the first live data to the receiving device, if only 950 ms of the live data in the first live data is sent, the first buffer duration corresponding to the first current buffer data is 50 ms, and the first delay threshold t 低延时 is used to represent the duration allowed for buffering in a low-latency network. Assuming the first delay threshold t 低延时 is 100 ms, then the first buffer duration of 50 ms is less than the first delay threshold of 100 ms, indicating that the amount of buffered data is small, and the current bitrate can be increased. Specifically, one bitrate level can be increased, that is, upshifting based on the current bitrate to obtain the first target bitrate.
[0078] Exemplarily, for Condition 12, on the basis of Condition 11, that is, after generating the first live data for the first preset duration and the first buffer duration is less than the first delay threshold, in order to avoid the oscillating switching of bitrate levels, it is necessary to compare the difference between the current moment and the moment of the last bitrate reduction with the first preset threshold t 抑制 This first preset threshold t 抑制 is used to represent the duration for suppressing the oscillating switching of levels. When the difference between the current moment and the moment of the last bitrate reduction is greater than the first preset threshold t 抑制 , it indicates that a long time has passed since the downshift, and at this time, one bitrate level can be increased, that is, upshifting based on the current bitrate to obtain the first target bitrate; when the difference between the current moment and the moment of the last bitrate reduction is less than or equal to the first preset threshold t 抑制 , it indicates that the time of the downshift is not long, and at this time, upshifting based on the current bitrate is not allowed to avoid the oscillating switching of levels.
[0079] Exemplarily, for condition 13, after generating the first live data for the first preset duration, when the first cache duration is greater than or equal to the first delay threshold, it is necessary to continue observing, that is, it is necessary to continue generating the second live data for the second preset duration T2. Assuming T2 is 2s, that is, generating 2s of the second live data. When sending the third live data (2s of the second live data and the previously cached first current cache data of 50ms) to the receiving device, if only 1900ms of the live data in the 2050ms of the third live data is sent, then the second cache duration corresponding to the second current cache data is 150ms, and the second delay threshold t 高延时 Used to represent the duration allowed for caching in a high-delay network. Assuming the second delay threshold t 高延时 is 200ms, then the second cache duration of 150ms is less than the second delay threshold of 200ms, indicating that the amount of cached data is small, and the current bitrate can be increased. Specifically, one bitrate level can be increased, that is, shifting up a gear based on the current bitrate to obtain the first target bitrate.
[0080] It should be noted that in actual applications, multiple different first delay thresholds and second delay thresholds can be set based on network requirements to make the adjustment of the bitrate level more in line with the current network environment. The present invention does not limit this.
[0081] Exemplarily, for condition 14, based on condition 13, that is, after generating the first live data for the first preset duration, when the first cache duration is greater than or equal to the first delay threshold, and after continuing to generate the second live data for the second preset duration, when the second cache duration is less than the second delay threshold, in order to avoid the oscillating switching of the bitrate level, it is necessary to compare the difference between the current moment and the moment when the bitrate was last decreased with the first preset threshold t 抑制 When the difference between the current moment and the moment when the bitrate was last decreased is greater than the first preset threshold t 抑制 it indicates that a long time has passed since the downshift. At this time, one bitrate level can be increased, that is, shifting up a gear based on the current bitrate to obtain the first target bitrate; when the difference between the current moment and the moment when the bitrate was last decreased is less than or equal to the first preset threshold t 抑制 it indicates that the time of the downshift is not long, and at this time, it is not allowed to shift up a gear based on the current bitrate to avoid the oscillating switching of the level.
[0082] In this embodiment, when the first preset condition is met, it indicates that the current network condition is good, and the current bitrate can be rapidly increased. New live data is generated based on the first target bitrate obtained after increasing the bitrate, so that the generation rate of the new live data matches the current network environment of the receiving device. In this way, when the receiving device receives the new live data, it can play it in real time, thereby improving the smoothness of the receiving device in playing the new live data and achieving automatic adjustment of video smoothness. Additionally, in the case of dynamic pictures, multiple thresholds such as the first preset threshold, the first delay threshold, and the second delay threshold are set in the upshift stage, which can be compatible with both low-delay and high-delay network environments. Moreover, in the case of dynamic pictures, only time is used to measure the accumulation of buffered data, which is closer to the user's judgment of picture delay and can be compatible with constant-bitrate videos and variable-bitrate videos.
[0083] In one embodiment, step 103 above determines the first target bitrate based on the first buffer duration, and specifically, it can also be implemented through the following method:
[0084] After continuing to generate the second live data for the second preset duration, when the second buffer duration is greater than or equal to the second delay threshold, the current bitrate is decreased to obtain the first target bitrate.
[0085] Exemplarily, after continuing to generate the second live data for the second preset duration T2, assuming T2 is 2s, that is, generating 2s of the second live data. When sending the third live data (2s of the second live data and the previously buffered first current buffered data of 50ms) to the receiving device, if only 1800ms of the live data in the 2050ms of the third live data is sent, then the second buffer duration corresponding to the second current buffered data is 250ms, and the second delay threshold t 高延时 used to represent the duration allowed for buffering in a high-delay network. Assuming the second delay threshold t 高延时 is 200ms, then the second buffer duration of 250ms is greater than the second delay threshold of 200ms, which indicates that the amount of buffered data is relatively large, and the current bitrate can be decreased. Specifically, one bitrate level can be decreased, that is, downshifted based on the current bitrate to obtain the first target bitrate.
[0086] In this embodiment, after continuing to generate the second live data for the second preset duration, when the second buffer duration is greater than or equal to the second delay threshold, it indicates that the current network condition is poor, and the current bitrate can be rapidly decreased. New live data is generated based on the first target bitrate obtained after decreasing the bitrate, so that the generation rate of the new live data matches the current network environment of the receiving device. In this way, when the receiving device receives the new live data, it can play it in real time, thereby improving the smoothness of the receiving device in playing the new live data and achieving automatic adjustment of video smoothness.
[0087] In one embodiment, after reducing the current code rate to obtain the first target code rate, the code rate adjustment method further includes the following steps:
[0088] When a second preset condition is satisfied, reduce the first target code rate to obtain a second target code rate.
[0089] Wherein, the second preset condition includes any one of the following:
[0090] Condition 21: The third buffer duration is greater than or equal to a second preset threshold; the second preset threshold is used to represent the duration of severe network congestion, the third buffer duration is the difference between the third current moment and the moment when the third current buffer data is written into the buffer, and the third current buffer data is the live data remaining when the second current buffer data is sent to the receiving end device based on the first transmission data rate.
[0091] Condition 22: The third buffer duration is less than the second preset threshold, the third buffer duration is greater than or equal to the second delay threshold, and after continuously generating the fourth live data for a third preset duration, the consumption speed of the remaining buffer data in the buffer is less than the preset speed; the remaining buffer data is the live data remaining when the fourth live data and the historical buffer live data in the buffer are sent to the receiving end device; the second target code rate is used to generate new live data.
[0092] Wherein, the preset speed can be represented by V 下降 to represent, the preset speed V 下降 is an adjustable parameter, the larger V 下降 is, the higher the sensitivity of downshifting is.
[0093] Exemplarily, for Condition 21, when reducing the current code rate to obtain the first target code rate, the data cached in the buffer is the second current buffer data. When sending the second current buffer data in the buffer to the receiving end device, if only part of the live data in the second current buffer data is sent, for example, the second buffer duration corresponding to the second current buffer data is 3500 ms, and only 100 ms of live data in the second current buffer data is sent, then the third buffer duration corresponding to the third current buffer data is 3400 ms, and the second delay threshold t 严重阻塞 is used to represent the duration of severe network congestion. Assume that the second delay threshold t 严重阻塞 is 3000 ms. Then the third buffer duration of 3400 ms is greater than the second delay threshold of 3000 ms, which indicates that the buffer data in the buffer is severely piled up and the current network environment suddenly becomes very poor. Then the logic of downshifting one gear at a time is not suitable for the current video or network change. At this time, reduce the first target code rate, specifically, it can be reduced from the first target code rate to the lowest gear code rate to obtain the second target code rate.
[0094] Exemplarily, for condition 22, for example, the second cache duration corresponding to the second current cache data is 3500 ms, and 2500 ms of live data in the second current cache data is sent. Then the third cache duration corresponding to the third current cache data is 1000 ms. Assume that the second delay threshold t 严重阻塞 is 3000 ms. Then the third cache duration of 1000 ms is less than the second delay threshold of 3000 ms. At this time, compare the third cache duration with the second delay threshold t 高延时 When the third cache duration is greater than or equal to the second delay threshold t 高延时 it indicates that there is a backlog of cache data in the buffer area and it is necessary to continue observing to determine whether the cache data in the buffer area can be consumed in time at the current bitrate level, that is, continue to generate the fourth live data for the third preset duration. Obtain the remaining cache data in the buffer area once in each I-frame interval duration period, and determine the consumption speed corresponding to the buffer area based on the remaining cache data obtained multiple times. When the consumption speed is less than the preset speed, it means that the data in the buffer area cannot be consumed in time. At this time, reduce the first target bitrate, specifically, it can be reduced by one bitrate level, that is, downshift based on the first target bitrate to obtain the second target bitrate. When the consumption speed is greater than or equal to the preset speed, it means that the data in the buffer area can be consumed in time. At this time, do not adjust the first target bitrate.
[0095] In this embodiment, after downshifting, continue to judge the downward trend of the backlogged cache data in the buffer area. If the preset downward trend is not met, it means that the cache data is still backlogged or consumed very slowly, and it is necessary to downshift again. That is, when the second preset condition is met, it means that the current network condition is poor, and the bitrate can be reduced again based on the first target bitrate. Generate new live data based on the obtained second target bitrate, so that the generation rate of the new live data matches the current network environment of the receiving end device. In this way, when the receiving end device receives the new live data, it can play in real time, thereby improving the smoothness of the receiving end device playing the new live data and realizing the automatic adjustment of the video smoothness.
[0096] In one embodiment, Figure 2 is the second flowchart of the bitrate adjustment method provided by the embodiment of the present invention. As Figure 2 shown, the bitrate adjustment method further includes the following steps:
[0097] Step 104, when the dynamic average data generation rate is greater than the second preset multiple of the first transmission data rate, reduce the current bitrate to obtain a third target bitrate; the third target bitrate is used to generate new live data.
[0098] Exemplarily, when the dynamic average generated data rate is greater than the first transmission data rate by a multiple of a second preset quantity, i.e., V Dynamic >N*V send1 it indicates that the current data accumulation speed is relatively fast and the current network environment is poor. The current code rate can be reduced. Specifically, one gear of the code rate can be reduced, that is, the gear is lowered based on the current code rate to obtain a third target code rate. N is a constant, and the smaller the value of N, the higher the sensitivity of lowering the gear.
[0099] In this embodiment, when the dynamic average generated data rate is greater than the first transmission data rate by a multiple of a second preset quantity, the current code rate is quickly reduced, and new live data is generated based on the obtained third target code rate, so that the generation rate of the new live data matches the current network environment of the receiving end device. In this way, the receiving end device can play the new live data in real time when receiving the new live data, thereby improving the smoothness of playing the new live data by the receiving end device and realizing automatic adjustment of video smoothness.
[0100] In one embodiment, Figure 3 is the third flowchart of the code rate adjustment method provided by the embodiment of the present invention. As Figure 3 shown, the code rate adjustment method further includes the following steps:
[0101] Step 301, in the case of a static picture, obtain the second transmission data rate sent by the receiving end device; the second transmission data rate is determined by the receiving end device based on the data volume of the current static picture I frame received and the second receiving duration corresponding to the current static picture I frame.
[0102] Among them, a static picture refers to an image without dynamic elements. The current static picture I frame refers to the complete static picture I frame currently received by the receiving end device. The data volume of the current static picture I frame refers to the number of bytes occupied by encoding the current static picture I frame. The second receiving duration is the duration required for the receiving end device to start receiving the current static picture I frame until it finishes receiving the current static picture I frame.
[0103] Exemplarily, for a static picture, the receiving end device can calculate the second transmission data rate by dividing the data volume of the complete current static picture I frame received by the second receiving duration. The second transmission data rate is used to characterize the transmission ability of the current link and is fed back to the camera device so that the camera device can obtain the second transmission data rate. For example, the data volume of the complete current static picture I frame is represented by Data StaticI and the first receiving duration is represented by Δt 2接收I帧 then the second transmission data rate
[0104] Step 302: Determine the static average data generation rate based on the static picture I-frame data volume and the static picture P-frame data volume.
[0105] Exemplarily, the data volume of each static picture I-frame and each static picture P-frame of the static picture remains stable. Therefore, the subsequent packet sending situation can be predicted through the previous samplings. The static picture I-frame data volume can be the data volume of the first static picture I-frame or the average of the data volumes of the previous several static picture I-frames. The static picture I-frame data volume can be represented by Data staticI and the static picture P-frame data volume can be the data volume of the first static picture P-frame or the average of the data volumes of the previous several static picture P-frames. The static picture P-frame data volume can be represented by Data staticP Then the static average data generation rate
[0106] Step 303: Determine the fourth target bitrate based on the second transmission data rate and the static average data generation rate; the fourth target bitrate is used to generate new live data.
[0107] Exemplarily, when obtaining the static average data generation rate V Static and the second transmission data rate V Send2 , by comparing the static average data generation rate V Static and the second transmission data rate V Send2 , it can be determined whether it is necessary to adjust the current bitrate. When it is determined that the current bitrate needs to be adjusted, the fourth target bitrate is obtained by upshifting or downshifting the current bitrate; when it is determined that the current bitrate does not need to be adjusted, the fourth target bitrate is the current bitrate.
[0108] In this embodiment, for the static picture, the fourth target bitrate is automatically determined based on the second transmission data rate and the static average data generation rate, and new live data is generated based on the obtained fourth target bitrate, so that the generation rate of the new live data matches the current network environment of the receiving device. In this way, the receiving device can play the new live data in real time when receiving it, thereby improving the smoothness of the receiving device in playing the new live data and realizing the automatic adjustment of the video smoothness.
[0109] In one embodiment, step 107 above determines the fourth target bitrate based on the second transmission data rate and the static average data generation rate, and can be specifically implemented in the following manner:
[0110] In the case where the static average data generation rate is greater than the second transmission data rate, reduce the current bitrate to obtain the fourth target bitrate.
[0111] Exemplarily, when the static average data generation rate is VStatic Greater than the second transmission data rate V Send2 , that is, V Static > V Send2 When it is, it indicates that data will continue to accumulate at the current code rate, the current network environment is poor, and it is necessary to reduce the gear in time, that is, reduce the current code rate. Specifically, the code rate can be reduced by one gear, that is, the gear is reduced on the basis of the current code rate to obtain the fourth target code rate.
[0112] In this embodiment, when the static average generated data rate is greater than the second transmission data rate, it indicates that data will continue to accumulate at the current code rate, and it is necessary to reduce the current code rate in time to achieve a rapid reduction of the current code rate to adapt to the poor current network environment.
[0113] In one embodiment, the above step 107 determines the fourth target code rate based on the second transmission data rate and the static average generated data rate. Specifically, it can also be implemented in the following manner:
[0114] When the static average generated data rate is less than or equal to the second transmission data rate and the static picture I-frame generated data rate is greater than the second transmission data rate, based on the static picture I-frame generated data rate, the static picture P-frame generated data rate and the second transmission data rate, determine the target cache duration; send the target cache duration to the receiving end device; the target cache duration is used to instruct the receiving end device to cache the live data within the target cache duration.
[0115] Exemplarily, when the static average generated data rate V Static is less than or equal to the second transmission data rate V Send2 , that is, V Static ≤V Send2 When it is, calculate the static picture I-frame generated data rate And the static picture I-frame generated data rate V StaticI is compared with the second transmission data rate V Send2 . When V StaticI > V Send2 When it is, it indicates that the overall generated data matches the sending ability of the link, but there will be a stuttering phenomenon on the receiving end device during the transmission of the static picture I-frame. Therefore, at this time, the receiving end device can be allowed to cache the data for a period of time to ensure the overall smoothness of the live broadcast. The target cache duration And the calculated target cache duration t 客户端缓存 is sent to the receiving end device, and the receiving end device caches the live data for the corresponding duration according to the received target cache duration t 客户端缓存 .
[0116] In this embodiment, when the static average generated data rate is less than or equal to the second transmission data rate and the static picture I-frame generated data rate is greater than the second transmission data rate, the receiving end device is controlled to cache data for the target cache duration to ensure the overall smoothness of the live broadcast. At the same time, each bitrate level has a corresponding clarity, so that the clarity of the live broadcast can also be ensured.
[0117] In one embodiment, step 107 above determines the fourth target bitrate based on the second transmission data rate and the static average generated data rate, and can specifically be implemented in the following manner:
[0118] When the third preset condition is satisfied, increase the current bitrate to obtain the fourth target bitrate.
[0119] The third preset condition includes any one of the following:
[0120] Condition 31: The static picture I-frame generated data rate is less than or equal to the second transmission data rate.
[0121] Condition 32: The static picture I-frame generated data rate is less than or equal to the second transmission data rate, and the difference between the current moment and the moment when the bitrate was last decreased is greater than the first preset threshold.
[0122] Exemplarily, for Condition 31, when the static picture I-frame generated data rate V Static1 is less than or equal to the second transmission data rate V Send2 , that is, V Static1 ≤V Send2 , it indicates that the current bitrate is lower than the transmission capacity of the link, and the current bitrate can be increased. Specifically, one bitrate level can be increased, that is, the bitrate is upshifted based on the current bitrate to obtain the fourth target bitrate.
[0123] In this embodiment, when the third preset condition is satisfied, it indicates that the current network condition is good, and the current bitrate can be increased. New live data is generated based on the fourth target bitrate obtained after increasing the bitrate, so that the generation rate of the new live data matches the current network environment of the receiving end device. In this way, when the receiving end device receives the new live data, it can play it in real time, thereby improving the smoothness of the receiving end device playing the new live data and realizing the automatic adjustment of the video smoothness.
[0124] In one embodiment, when starting to start the stream, it is necessary to compare the difference between the current start-streaming moment and the last end-streaming moment with the historical record effective duration t 历史记录有效期 . When the difference between the current start-streaming moment and the last end-streaming moment is less than the historical record effective duration t 历史记录有效期When it indicates that the flow start interval time is short, the bitrate corresponding to the previous flow stop moment can be determined as the current bitrate at this time; when the difference between the current flow start moment and the previous flow stop moment is greater than or equal to the effective duration t of the historical record 历史记录有效期 When it indicates that the flow start interval time is long, the lowest bitrate is determined as the current bitrate at this time.
[0125] In this embodiment, when the difference between the current flow start moment and the previous flow stop moment is less than the effective duration of the historical record, the bitrate corresponding to the previous flow stop moment is determined as the current bitrate, so as to avoid starting each flow from the lowest bitrate and eliminating the process of detecting the appropriate bitrate gear in the early stage in a short time, thereby reducing the computational amount of bitrate adjustment.
[0126] Figure 4 is the overall flowchart of the bitrate adjustment method for dynamic pictures provided by the embodiments of the present invention, Figure 5 is the overall flowchart of the bitrate adjustment method for static pictures provided by the embodiments of the present invention, as Figure 4 and Figure 5 shown, after starting the flow, it is determined whether the difference between the current flow start moment and the previous flow stop moment is less than the effective duration of the historical record. When the difference between the current flow start moment and the previous flow stop moment is less than the effective duration of the historical record, the bitrate corresponding to the previous flow stop moment is determined as the current bitrate for this flow start. When the difference between the current flow start moment and the previous flow stop moment is greater than or equal to the effective duration of the historical record, the lowest bitrate is determined as the current bitrate for this flow start.
[0127] After starting the flow, it is determined whether the picture is a static picture. In the case of a dynamic picture, the first transmission data rate, the data volume of the I-frame of the dynamic picture, and the data volumes of the first preset number of P-frames of the dynamic picture after the current I-frame of the dynamic picture are calculated, and based on the data volume of the I-frame of the dynamic picture and the data volumes of the first preset number of P-frames of the dynamic picture after the current I-frame of the dynamic picture, the dynamic average generated data rate is determined. When the dynamic average generated data rate is less than or equal to the second preset number times the first transmission data rate, after generating the first live data for the first preset duration, when the first buffer duration is less than the first delay threshold and the difference between the current moment and the previous moment of reducing the bitrate is greater than the first preset threshold, the current bitrate is increased.
[0128] After generating the first live data for the first preset duration, when the first buffer duration is greater than or equal to the first delay threshold, and after continuing to generate the second live data for the second preset duration, when the second buffer duration is less than the second delay threshold and the difference between the current moment and the previous moment of reducing the bitrate is greater than the first preset threshold, the current bitrate is increased.
[0129] After continuing to generate second live data for a second preset duration and when the second buffer duration is greater than or equal to the second delay threshold, reduce the current bitrate.
[0130] Further, after reducing the current bitrate, when the third buffer duration is greater than or equal to the second preset threshold, continue to reduce the bitrate, which can be reduced to the lowest bitrate.
[0131] When the third buffer duration is less than the second preset threshold, the third buffer duration is greater than or equal to the second delay threshold, and after continuing to generate fourth live data for a third preset duration, and when the consumption speed of the remaining buffered data in the buffer is less than the preset speed, continue to reduce the bitrate.
[0132] When the dynamic average data generation rate is greater than a second preset multiple of the first transmission data rate, reduce the current bitrate.
[0133] In the case of a static picture, calculate the second transmission data rate, the amount of static picture I-frame data, and the amount of static picture P-frame data, and based on the amount of static picture I-frame data and the amount of static picture P-frame data, determine the static average data generation rate. When the static average data generation rate is greater than the second transmission data rate, reduce the current bitrate; when the static average data generation rate is less than or equal to the second transmission data rate and the static picture I-frame data generation rate is greater than the second transmission data rate, send the target buffer duration to the receiving end device; when the static picture I-frame data generation rate is less than or equal to the second transmission data rate and the difference between the current time and the time of the last bitrate reduction is greater than the first preset threshold, increase the current bitrate.
[0134] After performing the adjustment of the current bitrate, return to the step of whether the picture is a static picture, and continue to perform the adaptive adjustment of the bitrate for the next cycle.
[0135] The bitrate adjustment device provided by the present invention will be described below. The bitrate adjustment device described below can be correspondingly referred to the bitrate adjustment method described above.
[0136] Figure 6 It is a schematic structural diagram of the bitrate adjustment device provided by an embodiment of the present invention, as Figure 6 shown. The bitrate adjustment device 600 includes a first acquisition unit 601, a first determination unit 602, and a second determination unit 603; where:
[0137] The first acquisition unit 601 is configured to obtain the first transmission data rate sent by the receiving end device in the case of a dynamic picture; the first transmission data rate is determined by the receiving end device based on the amount of data of the current dynamic picture I-frame received and the first reception duration corresponding to the current dynamic picture I-frame;
[0138] A first determination unit 602, configured to determine a dynamic average data generation rate based on the amount of I-frame data of a dynamic video and the amount of data of a first preset number of P-frames of dynamic video after the current I-frame of the dynamic video.
[0139] A second determination unit 603, configured to determine a first target bitrate based on a first buffer duration when the dynamic average data generation rate is less than or equal to a second preset multiple of the first transmission data rate; the first buffer duration is the difference between a first current moment and the moment when first current buffered data is written into a buffer; the first current buffered data is the remaining live data when transmitting first live data generated based on a current bitrate to the receiving end device based on the first transmission data rate; the first target bitrate is used to generate new live data.
[0140] The bitrate adjustment device provided by the present invention, in the case where a video picture is a dynamic picture, determines a dynamic average data generation rate based on the amount of data of a first preset number of P-frames of dynamic video after the current I-frame of the dynamic video and the amount of I-frame data of the dynamic video, and determines a first target bitrate based on a first buffer duration when the dynamic average data generation rate is less than or equal to a second preset multiple of the first transmission data rate, and uses the re-determined first target bitrate to generate new live data, so that the generation rate of the new live data matches the current network environment of the receiving end device. In this way, the receiving end device can play the new live data in real time when receiving the new live data, thereby improving the smoothness of playing the new live data by the receiving end device and realizing automatic adjustment of video smoothness.
[0141] Based on any of the above embodiments, the second determination unit 603 is specifically configured to:
[0142] When a first preset condition is satisfied, increase the current bitrate to obtain the first target bitrate;
[0143] The first preset condition includes any one of the following:
[0144] After generating the first live data for a first preset duration, the first buffer duration is less than a first delay threshold;
[0145] After generating the first live data for a first preset duration, the first buffer duration is less than a first delay threshold, and the difference between the current moment and the moment when the bitrate was last decreased is greater than a first preset threshold; the first preset threshold is used to represent the duration for suppressing gear oscillation switching;
[0146] After generating the first live data for the first preset duration, the first buffer duration is greater than or equal to the first delay threshold, and after continuing to generate the second live data for the second preset duration, the second buffer duration is less than the second delay threshold; the first delay threshold is less than the second delay threshold, the second buffer duration is the difference between the second current moment and the moment when the second current cached data is written into the buffer, and the second current cached data is the remaining live data when sending the third live data to the receiving device based on the first transmission data rate, and the third live data includes the second live data and the first current cached data;
[0147] After generating the first live data for the first preset duration, the first buffer duration is greater than or equal to the first delay threshold, and after continuing to generate the second live data for the second preset duration, the second buffer duration is less than the second delay threshold, and the difference between the current moment and the moment of the last bit rate reduction is greater than the first preset threshold.
[0148] Based on any of the above embodiments, the second determination unit 603 is further specifically configured to:
[0149] After continuing to generate the second live data for the second preset duration, when the second buffer duration is greater than or equal to the second delay threshold, reduce the current bit rate to obtain the first target bit rate.
[0150] Based on any of the above embodiments, the bit rate adjustment device 600 further includes:
[0151] A first adjustment unit, configured to reduce the first target bit rate to obtain a second target bit rate when a second preset condition is satisfied;
[0152] The second preset condition includes any one of the following:
[0153] The third buffer duration is greater than or equal to a second preset threshold; the second preset threshold is used to represent the duration of severe network congestion, the third buffer duration is the difference between the third current moment and the moment when the third current cached data is written into the buffer, and the third current cached data is the remaining live data when sending the second current cached data to the receiving device based on the first transmission data rate;
[0154] The third buffer duration is less than the second preset threshold, the third buffer duration is greater than or equal to the second delay threshold, and after continuing to generate the fourth live data for the third preset duration, the consumption speed of the remaining cached data in the buffer is less than a preset speed; the remaining cached data is the remaining live data when sending the fourth live data and the historical cached live data in the buffer to the receiving device; the second target bit rate is used to generate new live data.
[0155] Based on any of the above embodiments, the bit rate adjustment device 600 further includes:
[0156] A second adjustment unit, configured to reduce the current bit rate to obtain a third target bit rate when the dynamically averaged generated data rate is greater than the first transmitted data rate by a multiple of the second preset number; the third target bit rate is used to generate new live data.
[0157] Based on any of the above embodiments, the bit rate adjustment device 600 further includes:
[0158] A second acquisition unit, configured to acquire a second transmitted data rate sent by the receiving end device in the case of a static picture; the second transmitted data rate is determined by the receiving end device based on the data volume of the currently received static picture I frame and the second reception duration corresponding to the currently received static picture I frame;
[0159] A third determination unit, configured to determine a static average generated data rate based on the data volume of the static picture I frame and the data volume of the static picture P frame;
[0160] A fourth determination unit, configured to determine a fourth target bit rate based on the second transmitted data rate and the static average generated data rate; the fourth target bit rate is used to generate new live data.
[0161] Based on any of the above embodiments, the fourth determination unit is specifically configured to:
[0162] When the static average generated data rate is greater than the second transmitted data rate, reduce the current bit rate to obtain the fourth target bit rate.
[0163] Based on any of the above embodiments, the bit rate adjustment device further includes:
[0164] A fifth determination unit, configured to determine a target buffer duration based on the data rate generated by the static picture I frame, the data rate generated by the static picture P frame, and the second transmitted data rate when the static average generated data rate is less than or equal to the second transmitted data rate and the data rate generated by the static picture I frame is greater than the second transmitted data rate;
[0165] A sending unit, configured to send the target buffer duration to the receiving end device; the target buffer duration is used to instruct the receiving end device to buffer live data within the target buffer duration.
[0166] Based on any of the above embodiments, the fourth determination unit is specifically configured to:
[0167] When the third preset condition is satisfied, increase the current code rate to obtain the fourth target code rate;
[0168] The third preset condition includes any one of the following:
[0169] The data rate generated by the I-frame of the static picture is less than or equal to the second transmission data rate;
[0170] The data rate generated by the I-frame of the static picture is less than or equal to the second transmission data rate, and the difference between the current moment and the moment of the last code rate reduction is greater than the first preset threshold.
[0171] Based on any of the above embodiments, the code rate adjustment device further includes:
[0172] A sixth determination unit, configured to determine the code rate corresponding to the last flow-off moment as the current code rate when the difference between the current flow-start moment and the last flow-off moment is less than the effective duration of the historical record.
[0173] Figure 7 It is a schematic diagram of the physical structure of the electronic device provided by the embodiments of the present invention. As Figure 7 shown, the electronic device may include: a processor 710, a communication interface 720, a memory 730, and a communication bus 740. Among them, the processor 710, the communication interface 720, and the memory 730 complete mutual communication through the communication bus 740. The processor 710 can call the logical instructions in the memory 730 to execute the code rate adjustment method, and the method includes: in the case of a dynamic picture, obtaining the first transmission data rate sent by the receiving-end device; the first transmission data rate is determined by the receiving-end device based on the data volume of the current dynamic picture I-frame and the first reception duration corresponding to the current dynamic picture I-frame;
[0174] Based on the data volume of the dynamic picture I-frame and the data volumes of the first preset number of dynamic picture P-frames after the current dynamic picture I-frame, determine the dynamic average generation data rate;
[0175] When the dynamic average generation data rate is less than or equal to the second preset multiple of the first transmission data rate, determine the first target code rate based on the first buffer duration; the first buffer duration is the difference between the first current moment and the moment when the first current buffer data is written into the buffer area; the first current buffer data is the remaining live data when sending the first live data generated based on the current code rate to the receiving-end device based on the first transmission data rate; the first target code rate is used to generate new live data.
[0176] In addition, when the logical instructions in the above-mentioned memory 730 are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical discs.
[0177] On the other hand, the present invention also provides a computer program product. The computer program product includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the bitrate adjustment method provided by the above-mentioned various methods. The method includes: in the case of a dynamic picture, obtaining a first transmission data rate sent by a receiving-end device; the first transmission data rate is determined by the receiving-end device based on the data volume of the current dynamic picture I-frame received and the first reception duration corresponding to the current dynamic picture I-frame;
[0178] Based on the data volume of the dynamic picture I-frame and the data volumes of the first preset number of dynamic picture P-frames after the current dynamic picture I-frame, determining a dynamic average generated data rate;
[0179] In the case where the dynamic average generated data rate is less than or equal to the first transmission data rate multiplied by a second preset number, determining a first target bitrate based on a first buffer duration; the first buffer duration is the difference between a first current moment and the moment when the first current buffer data is written into the buffer area; the first current buffer data is the remaining live data when sending first live data generated based on the current bitrate to the receiving-end device based on the first transmission data rate; the first target bitrate is used to generate new live data.
[0180] In yet another aspect, the present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it is implemented to execute the bitrate adjustment method provided by the above-mentioned various methods. The method includes: in the case of a dynamic picture, obtaining a first transmission data rate sent by a receiving-end device; the first transmission data rate is determined by the receiving-end device based on the data volume of the current dynamic picture I-frame received and the first reception duration corresponding to the current dynamic picture I-frame;
[0181] Determine a dynamic average data generation rate based on the I-frame data volume of a dynamic video and the data volumes of the first preset number of P-frames of the dynamic video after the current I-frame of the dynamic video.
[0182] When the dynamic average data generation rate is less than or equal to the second preset multiple of the first transmission data rate, determine a first target bitrate based on a first buffer duration; the first buffer duration is the difference between a first current moment and the moment when first current buffered data is written into a buffer; the first current buffered data is the remaining live data when transmitting first live data generated based on a current bitrate to a receiving device based on the first transmission data rate; the first target bitrate is used to generate new live data.
[0183] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art can understand and implement it without creative efforts.
[0184] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the essence of the above technical solution, or the part that contributes to the prior art, can be embodied in the form of a software product, which can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., including several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0185] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A bit rate adjustment method, characterized in that, Including: In the case of a dynamic video, obtaining a first transmission data rate sent by a receiving device; The first transmission data rate is determined by the receiving device based on the data volume of the current I-frame of the dynamic video and the first reception duration corresponding to the current I-frame of the dynamic video; Based on the data volume of the I-frame of the dynamic video and the data volumes of the first preset number of P-frames of the dynamic video after the current I-frame of the dynamic video, determining a dynamic average generated data rate; In the case where the dynamic average generated data rate is less than or equal to a second preset multiple of the first transmission data rate, determining a first target bitrate based on a first buffer duration; the first buffer duration is the difference between a first current moment and the moment when first current buffer data is written into a buffer; The first current buffer data is the remaining live data when sending first live data generated based on a current bitrate to the receiving device based on the first transmission data rate; The first target bitrate is used to generate new live data.
2. The bit rate adjustment method according to claim 1, characterized in that, The determining the first target bitrate based on the first buffer duration includes: In the case of satisfying a first preset condition, increasing the current bitrate to obtain the first target bitrate; The first preset condition includes any one of the following: After generating the first live data for a first preset duration, the first buffer duration is less than a first delay threshold; After generating the first live data for a first preset duration, the first buffer duration is less than a first delay threshold, and the difference between the current moment and the moment of the last bitrate reduction is greater than a first preset threshold; the first preset threshold is used to represent the duration for suppressing gear oscillation switching; After generating the first live data for a first preset duration, the first buffer duration is greater than or equal to the first delay threshold, and after continuing to generate second live data for a second preset duration, a second buffer duration is less than a second delay threshold; the first delay threshold is less than the second delay threshold, the second buffer duration is the difference between a second current moment and the moment when second current buffer data is written into the buffer, and the second current buffer data is the remaining live data when sending third live data to the receiving device based on the first transmission data rate, and the third live data includes the second live data and the first current buffer data; After generating the first live data for a first preset duration, the first buffer duration is greater than or equal to the first delay threshold, and after continuing to generate second live data for a second preset duration, the second buffer duration is less than the second delay threshold, and the difference between the current moment and the moment of the last bitrate reduction is greater than the first preset threshold.
3. The bit rate adjustment method according to claim 2, characterized in that, The method further includes: In the case where after continuing to generate second live data for a second preset duration, the second buffer duration is greater than or equal to the second delay threshold, reducing the current bitrate to obtain the first target bitrate.
4. The bit rate adjustment method according to claim 3, characterized in that, After reducing the current bitrate to obtain the first target bitrate, the method further includes: In the case of satisfying a second preset condition, reducing the first target bitrate to obtain a second target bitrate; The second preset condition includes any one of the following: The third caching duration is greater than or equal to a second preset threshold; the second preset threshold is used to represent the duration of severe network congestion, the third caching duration is the difference between a third current moment and the moment when third current cached data is written into the buffer area, and the third current cached data is the live data remaining when sending second current cached data to the receiving end device based on the first sending data rate; The third caching duration is less than the second preset threshold, the third caching duration is greater than or equal to the second delay threshold, and after continuously generating fourth live data for a third preset duration, the consumption speed of the remaining cached data in the buffer area is less than a preset speed; the remaining cached data is the live data remaining when sending the fourth live data and historical cached live data in the buffer area to the receiving end device; the second target bitrate is used to generate new live data.
5. The bit rate adjustment method according to claim 1, characterized in that, The method further includes: When the dynamic average generated data rate is greater than the first sending data rate multiplied by a second preset quantity, reducing the current bitrate to obtain a third target bitrate; the third target bitrate is used to generate new live data.
6. The bit rate adjustment method according to claim 1, characterized in that, The method further includes: In the case of a static picture, obtaining a second sending data rate sent by the receiving end device; the second sending data rate is determined by the receiving end device based on the data volume of the received current static picture I-frame and the second receiving duration corresponding to the current static picture I-frame; Determining a static average generated data rate based on the data volume of the static picture I-frame and the data volume of the static picture P-frame; Determining a fourth target bitrate based on the second sending data rate and the static average generated data rate; the fourth target bitrate is used to generate new live data.
7. The bit rate adjustment method according to claim 6, characterized in that, The determining the fourth target bitrate based on the second sending data rate and the static average generated data rate includes: When the static average generated data rate is greater than the second sending data rate, reducing the current bitrate to obtain the fourth target bitrate.
8. The bit rate adjustment method according to claim 6, characterized in that, The method further includes: In the case where the static average generated data rate is less than or equal to the second sending data rate and the generated data rate of the static picture I-frame is greater than the second sending data rate, determining a target caching duration based on the generated data rate of the static picture I-frame, the generated data rate of the static picture P-frame, and the second sending data rate; Sending the target caching duration to the receiving end device; the target caching duration is used to instruct the receiving end device to cache live data within the target caching duration.
9. The bit rate adjustment method according to claim 6, wherein, The method further includes: When a third preset condition is satisfied, increasing the current bitrate to obtain the fourth target bitrate; The third preset condition includes any one of the following: The generated data rate of the static picture I-frame is less than or equal to the second sending data rate; The generated data rate of the static picture I-frame is less than or equal to the second sending data rate, and the difference between the current moment and the moment of the last bitrate reduction is greater than a first preset threshold.
10. The bit rate adjustment method according to any one of claims 1-9, wherein, The method further includes: When the difference between the current flow start time and the previous flow end time is less than the valid duration of the historical record, the bitrate corresponding to the previous flow end time is determined as the current bitrate.