All Products
Search
Document Center

ApsaraVideo Live:Enable dual-stream mode

Last Updated:Dec 09, 2025

This topic describes how to enable dual-stream mode and subscribe to the low-res stream to improve user experience.

What is dual-stream mode?

Dual-stream mode refers to publishing two camera streams simultaneously: a default high-res stream and a low-res stream. Subscribers can choose to receive the low-res stream to reduce bandwidth consumption and system load, thereby improving the experience.

Publish the low-res stream

Check environment support

Check if the current environment supports dual-stream mode. Do not enable this feature if it is not supported.

// Static method
const result = AliRtcEngine.isDualVideoStreamSupported();
if (!result) {
  console.log('Your browser does not support opening dual video stream.');
}

Enable dual-stream mode

Call the setEnableDualVideoStream method to enable the low-res stream and configure its parameters. This method can be called both before and after publishing.

// Prerequisite: An engine instance must be created first.
// Enable the low-res stream and set the required resolution and frame rate.
// The aspect ratio should be consistent with that of the high-res stream to avoid cropping.
aliRtcEngine.setEnableDualVideoStream(true, {
  width: 320,
  height: 180,
  frameRate: 200,
});

// If you need to adjust the parameters, call the method again.
aliRtcEngine.setEnableDualVideoStream(true, {
  width: 240,
  height: 180,
  frameRate: 200,
});

Listen for low-res stream state changes

f you need to handle changes in the low-res stream's state, listen for the dualStreamPublishStateChanged event.

aliRtcEngine.on('dualStreamPublishStateChanged', (oldState, newState, interval, channelId) => {
  // Both oldState and newState are of the AliRtcSubscribeState type. Valid values: 0 (Initializing), 1 (Unpublished), 2 (Publishing), and 3 (Published).
  // interval is the time elapsed between the two states, in milliseconds.
  console.log(`The low-res stream publish state in channel ${channelId} changed from ${oldState} to ${newState}`);
});

Subscribe to the low-res stream

By default, the aliyun-rtc-sdk subscribes to the high-res stream. To subscribe to the low-res stream, call the setRemoteDefaultVideoStreamType method.

// Accepts 1 (high-res stream) or 2 (low-res stream)
aliRtcEngine.setRemoteDefaultVideoStreamType(2);

If the remote user has not published a low-res stream, the SDK will automatically fall back to the high-res stream. The table below illustrates the actual stream type you will receive:

Default stream type set

Low-res stream Published?

Actual stream subscribed

High-res stream

No

High-res stream

High-res stream

Yes

High-res stream

Low-res stream

No

High-res stream

Low-res stream

Yes

Low-res stream