The content of this page has been automatically translated by AI. If you encounter any problems while reading, you can view the corresponding content in Chinese.

How to Achieve Adaptive Bitrate

Last updated: 2025-05-14 16:42:42

Detailed Description

The actual network environment fluctuates greatly. How to achieve adaptive bitrate.

Solution

Method
Description
Method A
iv_avt_init Initialization parameter pstInitParm > congestion allows you to set whether to enable water level alarms and three levels of high, medium, and low water level values for the alarm. When the water level in the p2p internal cache reaches this value, you will receive a iv_avt_notify_cb callback.
Method B
Actively call iv_avt_get_send_stream_buf to query the current water level value during use.
Method C
Actively call iv_avt_get_send_stream_status to query the current instantaneous network speed and the average network speed within 1 second during use.
Users develop and implement adaptive bitrate based on the query results of the above three methods.
Below is an implementation approach, for reference only.
Reduce the video bitrate when the p2p watermark exceeds a certain value.
For example, when the water level exceeds the low water level, the video bitrate will be reduced to 80% of the original. Under normal network conditions, the p2p water level value is very low. The water level value of a video with a bitrate of 2 mbps is generally below 100 KB. This value is for reference only. Sending larger I frames, network fluctuations, etc. will impact the water level value.
During stream pushing, call iv_avt_get_send_stream_status to obtain network speed information at specified intervals (for example, every 1 second).
Since the instantaneous speed fluctuates greatly, it is recommended to use the average transmission speed within 1 second and set a queue of a certain length (for example, a length of 5. If the calling interval is relatively short, the window can be extended appropriately). Store this value in the queue and simultaneously remove the oldest value in the queue. Remove the highest value and the lowest value, and then calculate the average value. The calculated average value can be used to control the bitrate. Generally speaking, this value is similar to the video bitrate. When the average network speed is detected to be lower than the video bitrate, proactively reduce the video bitrate to a value lower than the average network speed.
Users can combine the above methods to implement or reference the thought of the cubic congestion control algorithm to implement their own adaptive bitrate strategies. For p2p pass-through data, please refer to the APIs iv_avt_p2p_set_buf_watermark, iv_avt_p2p_get_send_buf and iv_avt_p2p_get_send_status. The specific implementation approach is similar.