Documentation
ExpressVideoSDK Video Call
Documentation
Demo APP
SDK Center
API Center
FAQ
Code Market
Console
Sign Up
Log In
中文站 English
  • Documentation
  • Video Call
  • Upgrade using advanced features
  • Advanced features
  • Improve video quality
  • Configure bandwidth management

Configure bandwidth management

Last updated:2024-11-14 15:45

Introduction

Traffic control refers to the SDK dynamically adjusting the bitrate, frame rate, resolution, and audio bitrate of video streaming based on the local and remote network conditions. It automatically adapts to the current network environment and fluctuations to ensure smooth audio and video streaming.

The principle of traffic control is based on modeling and estimating the user's network environment based on the current network situation. If the current upload bandwidth is lower than the set streaming bitrate, the SDK will progressively reduce the video bitrate, resolution, frame rate, and audio bitrate in order to reduce the upload bitrate and ensure smooth live broadcasting. Once the network environment returns to normal, the upload bitrate will be restored to the initial setting.

When there is only one RTC publishing stream, one RTC playing stream or one L3 playing stream(1v1), the SDK will automatically enable downstream traffic control. The stream playing end informs the stream publishing end about its network conditions, and the stream publishing end estimates its own upload bandwidth and the downstream bandwidth of the playing end. It adjusts its upload bitrate based on the minimum value of the estimated upload and download bandwidths to ensure smooth communication.

How to use

1 Enable Traffic Control

Before publishing the stream, call the enableTrafficControl interface to enable traffic control by setting the enable parameter to true. You can also set adjustable traffic control properties (bitrate, frame rate, resolution) through the property parameter. Multiple options can be selected, with the default value being ADAPTIVE_FPS, which means adaptive (reduced) video frame rate. When the upstream bandwidth is insufficient, the SDK will reduce the upstream bitrate of the publishing stream based on the current network environment and the property parameter settings to adapt to the upstream bandwidth.

  • Usage Limitations: Only supports RTC publishing stream.
  • When traffic control is disabled, the set traffic control properties property will also be invalidated.
  • When the traffic control properties include adaptive (reduced) video resolution ADAPTIVE_RESOLUTION, only "16:9" or "4:3" aspect ratios are supported as the initial resolution. If the initial resolution is set to other values, the adaptive (reduced) video resolution will not take effect, and the SDK will directly reduce the encoding bitrate.
  • If local media recording is required during the use of traffic control, the adaptive (reduced) video resolution will affect the "MP4" format file recording. In this case, the format needs to be changed to "FLV".For more information, see Recording live streams as local files.
// Enable traffic control and enable adaptive (reduced) video frame rate and adaptive (reduced) video resolution at the same time
ZegoExpressEngine.getEngine().enableTrafficControl(true, ADAPTIVE_RESOLUTION.value() | ADAPTIVE_FPS.value());

2 (Optional) Automatically Adjust Traffic Control Properties

The SDK will automatically set traffic control properties suitable for the selected scene scenario based on the scene selected by the developer when creating the engine. For example, in the Live Broadcasting scene, smooth video streaming is required, so it is recommended to choose adaptive (reduced) video resolution; in the Education scene, clarity is required, so it is recommended to choose adaptive (reduced) video frame rate.

The SDK determines the current traffic control properties based on the order of interface calls, and the properties set by the later call take effect. That is, if the traffic control properties are set through enableTrafficControl first, and then setRoomScenario is called to set scenario, the traffic control properties will change according to scenario.

3 Set the Minimum Video Bitrate for Traffic Control (Can be skipped for pure audio scenes)

After enabling traffic control, call the setMinVideoBitrateForTrafficControl method to set the minimum video bitrate (default value is "0") and the video sending mode. This allows the SDK to not send video or send video at an extremely low frame rate when the network does not reach the minimum video bitrate for sending.

You can call setMinVideoBitrateForTrafficControl at any time after initializing the SDK and before starting to publish the stream startPublishingStream, but this setting will only take effect after traffic control is enabled.

// After enabling traffic control, when the upstream and downstream bandwidth is lower than 200 kbps, continue to send video data at an extremely low frame rate
ZegoExpressEngine.getEngine().setMinVideoBitrateForTrafficControl(200, ZegoTrafficControlMinVideoBitrateMode.ULTRA_LOW_FPS);
Page Directory
  • Free trial
  • 提交工单
    咨询集成、功能及报价等问题
    电话咨询
    400 1006 604
    Get Consulting
    Scan Wechat QR code