CN114245131A - Optimization algorithm for dynamically adjusting video code rate based on buffer queue - Google Patents
Optimization algorithm for dynamically adjusting video code rate based on buffer queue Download PDFInfo
- Publication number
- CN114245131A CN114245131A CN202111553984.2A CN202111553984A CN114245131A CN 114245131 A CN114245131 A CN 114245131A CN 202111553984 A CN202111553984 A CN 202111553984A CN 114245131 A CN114245131 A CN 114245131A
- Authority
- CN
- China
- Prior art keywords
- code rate
- data
- buffer queue
- video
- seconds
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000005457 optimization Methods 0.000 title claims abstract description 13
- 230000001965 increasing effect Effects 0.000 claims description 14
- 230000001960 triggered effect Effects 0.000 claims description 6
- 230000005540 biological transmission Effects 0.000 claims description 3
- 238000000034 method Methods 0.000 claims description 3
- 238000011084 recovery Methods 0.000 claims description 3
- 230000003044 adaptive effect Effects 0.000 claims description 2
- 230000015556 catabolic process Effects 0.000 claims description 2
- 238000006731 degradation reaction Methods 0.000 claims description 2
- 230000000694 effects Effects 0.000 abstract description 4
- 230000007246 mechanism Effects 0.000 abstract description 3
- 238000012544 monitoring process Methods 0.000 abstract description 2
- 230000003247 decreasing effect Effects 0.000 description 2
- 230000006978 adaptation Effects 0.000 description 1
- 230000004075 alteration Effects 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000000593 degrading effect Effects 0.000 description 1
- 238000010586 diagram Methods 0.000 description 1
- 230000002708 enhancing effect Effects 0.000 description 1
- 238000011156 evaluation Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N19/00—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
- H04N19/10—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
- H04N19/134—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or criterion affecting or controlling the adaptive coding
- H04N19/146—Data rate or code amount at the encoder output
- H04N19/15—Data rate or code amount at the encoder output by monitoring actual compressed data size at the memory before deciding storage at the transmission buffer
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N19/00—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
- H04N19/10—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
- H04N19/134—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or criterion affecting or controlling the adaptive coding
- H04N19/164—Feedback from the receiver or from the transmission channel
Landscapes
- Engineering & Computer Science (AREA)
- Multimedia (AREA)
- Signal Processing (AREA)
- Two-Way Televisions, Distribution Of Moving Picture Or The Like (AREA)
Abstract
The invention relates to the technical field of video monitoring and storage, and discloses an optimization algorithm for dynamically adjusting video code rate based on a buffer queue, which is based on the buffer length of an audio and video buffer area and combines two mechanisms of code rate adjustment and frame dropping to provide a better dynamic control algorithm, so that the experience effect of a user in watching video is enhanced, the code rate control algorithm is dynamically adjusted according to the uploading rate of the video and the length of the backlog data of the buffer queue, and meanwhile, the frame dropping mechanism is synthesized to preferentially ensure the continuity of audio data, and according to the principle of fast drop and slow rise, the integrity of cloud data recording is ensured to the maximum extent, and the experience effect of the user in watching the video is enhanced.
Description
Technical Field
The invention relates to the technical field of video monitoring and storage, in particular to an optimization algorithm for dynamically adjusting video code rate based on a buffer queue.
Background
At present, most of intelligent network cameras (IPC) in the market support APP remote live broadcast and video cloud storage, however, in some environments, due to wifi interference or long distance of a router, video playing can be relatively blocked or even lost, user experience is influenced, and cloud video recording is incomplete;
at present, many IPC devices also have dynamic code rate adjustment schemes, generally carry out adjustment according to sending delay and client packet loss rate feedback, and generally have the problems of inaccurate code rate adjustment, frequent switching and inaccurate bandwidth evaluation.
Disclosure of Invention
The invention aims to provide an optimization algorithm for dynamically adjusting video code rate based on a buffer queue, which dynamically adjusts a code rate control algorithm according to the uploading rate of a video and the length of backlog data of the buffer queue, integrates a frame loss mechanism, preferentially ensures the continuity of audio data, and furthest ensures the integrity of cloud recorded data according to the principle of fast reduction and slow rise.
In order to achieve the purpose, the invention provides the following technical scheme: an optimization algorithm for dynamically adjusting video code rate based on a buffer queue comprises the following steps;
s1, the camera configures coding parameters to support multiple code rate values B1-B5, wherein the code rate values from B1 to B5 are increased step by step, B1 is the minimum code rate value, and B5 is the maximum code rate value;
s2, the camera encodes the collected audio and video data, and the encoded data is put into a local memory buffer queue, wherein the queue length duration is counted as T1= tail timestamp-head timestamp;
s3, the device starts an independent thread to monitor the size of the T1 in real time, and the size of the T1 is calculated once per second;
s4, the data sending thread reads data from the local cache queue, sends the data to the server, and clears the data from the queue after the data is successfully sent;
s5, when the network bandwidth is insufficient or the network is congested, the data transmission speed is relatively slow, which may result in an increase of the data length T1 of the local buffer queue.
Preferably, in S5, the code rate adaptation algorithm when the network is congested is as follows:
A1. when T1 is continued for 5 times and exceeds 2 seconds, reducing the current code rate by one level, and clearing the value sequence of the T1 counted before after the degradation;
A2. when the T1 is continuously processed for 5 times for more than 4 seconds, clearing the value sequence of the T1 counted before after the current code rate is degraded for two levels;
A3. when T1 is continuously processed for more than 6 seconds for 5 times, the current code rate is directly reduced to the minimum value B1.
Preferably, the following algorithm is adopted to control frame loss:
B1. because the volume of the audio data is relatively small, the principle of frame loss is to preferentially ensure the integrity of the audio data;
B2. when T1 is continuously carried out for 5 times and exceeds 2 seconds, and the current code rate is already the minimum value B1, a frame dropping strategy is triggered, the strategy is to drop 1/4P frame data of a team head Group of pictures, and audio frames are reserved;
B3. when T1 is continuously carried out for 5 times for more than 4 seconds and the current code rate is already the minimum value B1, a frame dropping strategy is triggered, the strategy is to drop 1/4P frame data of a team head Group of pictures and keep audio frames;
B4. if T1 is 5 consecutive times over 6 seconds and the current bitrate is already the minimum B1, all video data in the queue is emptied, leaving audio frames.
Preferably, the code rate lifting algorithm during network recovery is as follows:
C1. if T1 is n consecutive, default n =5, and the time is lower than 1 second, then the current code rate is increased by one level and the statistical T1 value sequence is emptied;
C2. after the code rate is upgraded, increasing the continuous waiting times n, wherein n = n + 2;
C3. repeating the judgment of the step a;
C4. according to the method, after the network recovers, the interval of the code rate recovering from the minimum value B1 to the maximum value B5 is gradually increased.
Preferably, the algorithm also controls the code rate to decrease and increase for 1 time within 15 minutes.
The optimization algorithm for dynamically adjusting the video code rate based on the buffer queue has the beneficial effects that: all parameters (such as code rate level values, statistical duration and the like) can be dynamically configured through the server and are issued to the equipment to take effect in real time, the algorithm can better ensure smooth switching of video code rates in an environment with frequent network jitter, and can also quickly improve the code rates to a normal level when the network is recovered, thereby ensuring the integrity of cloud recorded data to the maximum extent and enhancing the experience effect of users in watching videos.
Drawings
FIG. 1 is a diagram of network adaptive code rate adjustment according to the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In an embodiment, please refer to fig. 1, the present invention provides a technical solution: an optimization algorithm for dynamically adjusting video code rate based on a buffer queue comprises the following steps;
s1, the camera configures coding parameters to support multiple code rate values B1-B5, wherein the code rate values from B1 to B5 are increased step by step, B1 is the minimum code rate value, and B5 is the maximum code rate value;
s2, the camera encodes the collected audio and video data, and the encoded data is put into a local memory buffer queue, wherein the queue length duration is counted as T1= tail timestamp-head timestamp;
s3, the device starts an independent thread to monitor the size of the T1 in real time, and the size of the T1 is calculated once per second;
s4, the data sending thread reads data from the local cache queue, sends the data to the server, and clears the data from the queue after the data is successfully sent;
s5, when the network bandwidth is insufficient or the network is congested, the data transmission speed is relatively slow, which may result in an increase of the data length T1 of the local buffer queue.
The code rate self-adaptive algorithm when the network is congested comprises the following steps:
A1. when the T1 is continuously processed for more than 2 seconds for 5 times, the current code rate is reduced by one step (for example, the current code rate is reduced from B3 to B2), and after the current code rate is reduced, the value sequence of the T1 counted before is emptied;
A2. when the time of T1 is continuously 5 times and exceeds 4 seconds, clearing the value sequence of the T1 counted before after degrading the current code rate by two levels (for example, reducing the current code rate from B3 to B1);
A3. when T1 is continuously processed for more than 6 seconds for 5 times, the current code rate is directly reduced to the minimum value B1.
The following algorithm is adopted to control frame loss:
B1. because the volume of the audio data is relatively small, the principle of frame loss is to preferentially ensure the integrity of the audio data;
B2. when T1 is continuously carried out for 5 times and exceeds 2 seconds, and the current code rate is already the minimum value B1, a frame dropping strategy is triggered, the strategy is to drop 1/4P frame data of a team head Group of pictures, and audio frames are reserved;
B3. when T1 is continuously carried out for 5 times for more than 4 seconds and the current code rate is already the minimum value B1, a frame dropping strategy is triggered, the strategy is to drop 1/4P frame data of a team head Group of pictures and keep audio frames;
B4. if T1 is 5 consecutive times over 6 seconds and the current bitrate is already the minimum B1, all video data in the queue is emptied, leaving audio frames.
The code rate promotion algorithm during network recovery is as follows:
C1. if T1 is n consecutive, default n =5, next less than 1 second, then the current bitrate is raised by one level (e.g., from B2 to B3) and the statistical T1 value sequence is emptied;
C2. after the code rate is upgraded, increasing the continuous waiting times n, wherein n = n + 2;
C3. repeating the judgment of the step a;
C4. according to the method, after the network recovers, the interval of the code rate recovering from the minimum value B1 to the maximum value B5 is gradually increased.
In order to prevent the code rate from being frequently increased and decreased under certain network bandwidth conditions, the algorithm also controls the number of times of rate decrease and increase within 15 minutes to be 1 time, that is, within 15 minutes, if the code rate is increased and then decreased, the code rate is not increased any more.
Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that changes, modifications, substitutions and alterations can be made in these embodiments without departing from the principles and spirit of the invention, the scope of which is defined in the appended claims and their equivalents.
Claims (5)
1. An optimization algorithm for dynamically adjusting video code rate based on a buffer queue is characterized in that: comprises the following steps;
s1, the camera configures coding parameters to support multiple code rate values B1-B5, wherein the code rate values from B1 to B5 are increased step by step, B1 is the minimum code rate value, and B5 is the maximum code rate value;
s2, the camera encodes the collected audio and video data, and the encoded data is put into a local memory buffer queue, wherein the queue length duration is counted as T1= tail timestamp-head timestamp;
s3, the device starts an independent thread to monitor the size of the T1 in real time, and the size of the T1 is calculated once per second;
s4, the data sending thread reads data from the local cache queue, sends the data to the server, and clears the data from the queue after the data is successfully sent;
s5, when the network bandwidth is insufficient or the network is congested, the data transmission speed is relatively slow, which may result in an increase of the data length T1 of the local buffer queue.
2. The optimization algorithm for dynamically adjusting video bitrate based on the buffer queue according to claim 1, wherein: in S5, the code rate adaptive algorithm during network congestion is:
A1. when T1 is continued for 5 times and exceeds 2 seconds, reducing the current code rate by one level, and clearing the value sequence of the T1 counted before after the degradation;
A2. when the T1 is continuously processed for 5 times for more than 4 seconds, clearing the value sequence of the T1 counted before after the current code rate is degraded for two levels;
A3. when T1 is continuously processed for more than 6 seconds for 5 times, the current code rate is directly reduced to the minimum value B1.
3. The optimization algorithm for dynamically adjusting video bitrate based on the buffer queue according to claim 2, wherein: the following algorithm is adopted to control frame loss:
B1. because the volume of the audio data is relatively small, the principle of frame loss is to preferentially ensure the integrity of the audio data;
B2. when T1 is continuously carried out for 5 times and exceeds 2 seconds, and the current code rate is already the minimum value B1, a frame dropping strategy is triggered, the strategy is to drop 1/4P frame data of a team head Group of pictures, and audio frames are reserved;
B3. when T1 is continuously carried out for 5 times for more than 4 seconds and the current code rate is already the minimum value B1, a frame dropping strategy is triggered, the strategy is to drop 1/4P frame data of a team head Group of pictures and keep audio frames;
B4. if T1 is 5 consecutive times over 6 seconds and the current bitrate is already the minimum B1, all video data in the queue is emptied, leaving audio frames.
4. The optimization algorithm for dynamically adjusting video bitrate based on the buffer queue according to claim 3, wherein: the code rate promotion algorithm during network recovery is as follows:
C1. if T1 is n consecutive, default n =5, and the time is lower than 1 second, then the current code rate is increased by one level and the statistical T1 value sequence is emptied;
C2. after the code rate is upgraded, increasing the continuous waiting times n, wherein n = n + 2;
C3. repeating the judgment of the step a;
C4. according to the method, after the network recovers, the interval of the code rate recovering from the minimum value B1 to the maximum value B5 is gradually increased.
5. The optimization algorithm for dynamically adjusting video bitrate based on the buffer queue according to claim 4, wherein: the algorithm also controls the code rate to decrease and increase for 1 time within 15 minutes.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111553984.2A CN114245131A (en) | 2021-12-18 | 2021-12-18 | Optimization algorithm for dynamically adjusting video code rate based on buffer queue |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111553984.2A CN114245131A (en) | 2021-12-18 | 2021-12-18 | Optimization algorithm for dynamically adjusting video code rate based on buffer queue |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114245131A true CN114245131A (en) | 2022-03-25 |
Family
ID=80758305
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111553984.2A Pending CN114245131A (en) | 2021-12-18 | 2021-12-18 | Optimization algorithm for dynamically adjusting video code rate based on buffer queue |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114245131A (en) |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20110252155A1 (en) * | 2010-04-12 | 2011-10-13 | Shyam Parekh | Queue management unit and method for streaming video packets in a wireless network |
CN102378065A (en) * | 2011-10-19 | 2012-03-14 | 江西省南城县网信电子有限公司 | Method and system for configuring buffer area at streaming media server side based on MPEG (Moving Picture Experts Group)-4 |
CN107295395A (en) * | 2017-06-27 | 2017-10-24 | 武汉斗鱼网络科技有限公司 | Code check adaptive regulation method, device and electronic equipment |
CN109660879A (en) * | 2018-12-20 | 2019-04-19 | 广州虎牙信息科技有限公司 | Frame losing method, system, computer equipment and storage medium is broadcast live |
CN109818874A (en) * | 2017-11-21 | 2019-05-28 | 华为技术有限公司 | Data transmission method, equipment and computer storage medium |
CN110121089A (en) * | 2019-06-10 | 2019-08-13 | 杭州米络星科技(集团)有限公司 | A kind of RTMP live streaming code rate adaptive approach |
-
2021
- 2021-12-18 CN CN202111553984.2A patent/CN114245131A/en active Pending
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20110252155A1 (en) * | 2010-04-12 | 2011-10-13 | Shyam Parekh | Queue management unit and method for streaming video packets in a wireless network |
CN102378065A (en) * | 2011-10-19 | 2012-03-14 | 江西省南城县网信电子有限公司 | Method and system for configuring buffer area at streaming media server side based on MPEG (Moving Picture Experts Group)-4 |
CN107295395A (en) * | 2017-06-27 | 2017-10-24 | 武汉斗鱼网络科技有限公司 | Code check adaptive regulation method, device and electronic equipment |
CN109818874A (en) * | 2017-11-21 | 2019-05-28 | 华为技术有限公司 | Data transmission method, equipment and computer storage medium |
CN109660879A (en) * | 2018-12-20 | 2019-04-19 | 广州虎牙信息科技有限公司 | Frame losing method, system, computer equipment and storage medium is broadcast live |
CN110121089A (en) * | 2019-06-10 | 2019-08-13 | 杭州米络星科技(集团)有限公司 | A kind of RTMP live streaming code rate adaptive approach |
Non-Patent Citations (1)
Title |
---|
杨格兰;曹理宇;张建明;: "基于MPEG-4的流媒体服务器端缓冲区管理", 计算机工程, no. 05, pages 1 - 2 * |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11924263B2 (en) | Methods and devices for efficient adaptive bitrate streaming | |
CN106341738B (en) | Bandwidth calculation method, server side and system for streaming media network transmission | |
US10587664B2 (en) | Systems and methods for controlling the encoding of a segmented media stream using segment transmit times | |
US10044466B2 (en) | Server-side adaptive bit rate control for DLNA HTTP streaming clients | |
US8806541B2 (en) | Video service buffer management in a mobile rate control enabled network | |
US9450701B2 (en) | Data flow control method and apparatus | |
CN108494698B (en) | Congestion control method based on transmission rate | |
CN108401128B (en) | Congestion control method in video call | |
CN106789385B (en) | Video stream sending method, sending device and network camera | |
US8995268B2 (en) | Method for controlling a flow in a packet switching network | |
US10659514B2 (en) | System for video monitoring with adaptive bitrate to sustain image quality | |
CN108347645A (en) | A kind of method and device that video frame decoding is shown | |
CN108965807B (en) | Real-time video playing control method and device, terminal and storage medium | |
CN106210785B (en) | Self-adaptive unidirectional control method and system for media stream network | |
CN101090369B (en) | Method for controlling data packet sending speed in flow medium system | |
CN114245131A (en) | Optimization algorithm for dynamically adjusting video code rate based on buffer queue | |
GB2577610A (en) | Improved congestion response | |
JP2007312051A (en) | Set top box | |
CN105306970B (en) | A kind of control method and device of live streaming media transmission speed | |
JP2004048450A (en) | Stream distribution method, client terminal, device, system, program, and recording medium recording the program | |
CN117915162A (en) | Real-time video transmission dynamic delay control system based on link state and time stamp | |
Ehtiba et al. | Media Playout Techniques for Video Intra-Stream Synchronization: Review and Analysis | |
CN117729157A (en) | Data processing method, device, electronic equipment and storage medium | |
CN117729376A (en) | Video playing method, device, equipment and storage medium | |
CN115955697A (en) | Method for improving user perception in high-speed TCP (Transmission control protocol) service scene |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |