In a video call or interactive video streaming scenario, if multiple users publish video streams at the same time, user experience may be affected by limited device performance and excessive bandwidth consumption.
Use this article as a best practice for implementing a video scenario that enables multiple users to publish video streams simultaneously.
To minimize bandwidth consumption and ensure smooth communication in a video scenario with multiple users, Agora recommends the following:
Before proceeding, ensure that you have implemented the basic real-time audio and video functions in your project.
After calling Stream.init
successfully, call enableDualStream
to enable dual-stream mode on the publishers' clients. In dual-stream mode, the SDK transmits a high-quality video stream and a low-quality video stream from the publisher. The high-quality video stream has a higher resolution and bitrate than the low-quality video stream.
For the Agora Web SDK v3.1.0 or later, the low-quality stream has a fixed default video profile: A resolution (width × height) of 160 × 120 px, a bitrate of 50 Kbps, and a frame rate of 15 fps. For the Agora Web SDK earlier than v3.1.0, the SDK sets the default video profile of the low-quality video stream based on that of the high-quality video stream.
Call setRemoteVideoStreamType
on each subscriber's client to receive the high-quality stream from only one publisher and the low-quality stream of the other publishers.
To reduce bandwidth consumption, Agora recommends calling Client.setLowStreamParameter
to customize the video profile of the low-quality stream.
cswitchStream = function (){
if (highOrLow === 0) {
highOrLow = 1
console.log("Set to low");
}
else {
highOrLow = 0
console.log("Set to high");
}
client.setRemoteVideoStreamType(stream, highOrLow);
}
Call Client.publish
to Publish a local stream, and call Client.subscribe
to Subscribe to a remote stream.
The SDK sets the video profile of the low-quality video stream based on that of the high-quality video stream. This following table shows the relation between the video profiles of the high-quality and low-quality video streams.
Video profile of high-quality stream | Video profile of low-quality stream |
---|---|
|
90P_1 |
|
120P_3 |
|
120P_1 |
|
120P_1 |
|
120P_3 |
For the resolution, frame rate, and bitrate of each video profile, see API Reference.