How do I configure dual video tracks?

更新时间:
复制 MD 格式

Alibaba Cloud Real-Time Communication (RTC) supports the dual-track mode, in which a major track and a minor track exist. You can enable this feature based on your business requirements. This topic describes the implementation method and specifications of dual video tracks. iOS is used as an example.

Implementation method

In multi-user video communication, you can call setVideoEncoderConfiguration to reduce the video resolution and bitrate at the publishing end, or call publishLocalDualStream to enable the dual-track mode and call setRemoteVideoStreamType to subscribe to the minor track by default. This reduces the resource consumption of coding and relieves the downstream bandwidth pressure. For more information, see Configure video attributes.

Note After the dual-track mode is enabled, RTC SDK pushes an additional video track with lower resolution and bitrate. The original video track is called a major track, and the low-resolution, low-bitrate video track is called a minor track.

Default mappings of dual-track specifications

RTC SDK automatically sets the default specifications of the minor track based on the specifications of the major track. The following table describes the mappings.

Aspect ratio (width:height) of the major trackMinor track
Resolution (width × height)Bitrate (unit: Kbit/s)Frame rate (unit: fps)
1:1160 × 16010010
3:4120 × 16010010
4:3160 × 12010010
9:1690 × 16010010
16:9160 × 9010010
Other aspect ratiosThe greater of the width and height of a minor track is 160. The smaller of the two is calculated based on the ratio. 10010
Note The default specifications of the minor track follow the following rules:
  • The greater of the width and height of a minor track is fixed at 160. The aspect ratio of a minor track is the same as that of the corresponding major track.
  • The frame rate of the minor track is fixed at 10 fps.
  • The width and height of the minor track must be even numbers.
  • The bitrate of the minor track is fixed at 100 Kbit/s.

Customize minor track specifications

To customize minor track specifications, you can set the extras parameter when you create the AliRtcEngine object. The following sample code provides an example to show how to set extras to set the resolution of a minor track to 320 × 180, the frame rate to 5 fps, and the bitrate to 140 Kbit/s:

{
  "user_specified_low_bitrate_stream_parameter": {
    "width": 320,
    "height": 180,
    "frameRate": 5,
    "bitRate": 140
  }
}
Note
  • When you set the resolution of a minor track, the valid values of the width are [64,640] and the valid values of the height are [64,480].
  • If you set the frame rate of a minor track to be greater than that of a major track, the frame rate of the minor track is adjusted to that of the major track. If you set the frame rate of a minor track to 0 or a negative number, the frame rate of the minor track is adjusted to 10.
  • If you set the bitrate of a minor track to be smaller than the minimum bitrate, the actual bitrate is the bitrate that you set. If you set the bitrate of a minor track to be larger than the maximum bitrate, the actual bitrate is the maximum bitrate.

For more information about the extras parameter, see extras parameters.

Customize major track specifications

To customize major track specifications, you can set the resolution, frame rate, and bitrate based on the following table and the actual bandwidth.

Resolution (width:height)Frame rate (unit: fps)Bitrate (unit: Kbit/s)
Minimum valueRecommended valueMaximum value (multiple of the recommended value)
160 × 12051030× 3
102055× 3
153080× 3
2040100× 3
3060130× 3
120 × 12051025× 3
101750× 3
152570× 3
203490× 3
3050115× 3
320 × 18051565× 3
1030110× 3
1545170× 3
2060220× 3
3090300× 3
180 × 18051050× 3
101770× 3
1526100× 3
2034130× 3
3051180× 3
240 × 18051560× 3
103090× 3
1545130× 3
2060165× 3
3090230× 3
320 × 240520100× 2
1040170× 2
1560256× 2
2080320× 2
30120400× 2
240 × 24051570× 2
1030100× 2
1545150× 2
2060200× 2
3090256× 2
424 × 240526100× 2
1053170× 2
1579260× 2
20105340× 2
30158430× 2
640 × 360583200× 2
10165340× 2
15248512× 2
20330600× 2
30495700× 2
360 × 360530120× 2
1060180× 2
1590260× 2
20120330× 2
30180400× 2
480 × 360540150× 2
1080240× 2
15120350× 2
20160430× 2
30240512× 2
640 × 4805110200× 2
10220350× 2
15330512× 2
20440600× 2
30660700× 2
480 × 480583170× 2
10165260× 2
15248400× 2
20330470× 2
30495600× 2
840 × 4805180256× 2
10360512× 2
15540610× 2
20720800× 2
301080930× 2
1280 × 7205400400× 1.5
10800800× 1.5
1512001200× 1.5
2016001600× 1.5
3024002400× 1.5
960 × 7205250250× 1.5
10500500× 1.5
15750750× 1.5
2010001000× 1.5
3015001500× 1.5
1920 × 10805500500× 1.5
1010001000× 1.5
1515001500× 1.5
2020002000× 1.5
3030003000× 1.5
2560 × 14405800800× 1.5
1016001600× 1.5
1524002400× 1.5
2032003200× 1.5
3048004800× 1.5
3840 × 2160510001000× 1.5
1020002000× 1.5
1530003000× 1.5
2040004000× 1.5
3060006000× 1.5
Note
  • The default resolution of a major track is 640 × 480, the default frame rate is 15 fps, and the default bitrate is 512 Kbit/s.
  • If the major track is a camera track, set the maximum resolution to 1920 × 1080 and the frame rate to 30 fps.
  • If the major track is a screen track, set the maximum resolution to 3840 × 2160 and the frame rate to 30 fps.
  • We recommend that you do not set the bitrate when you set the video specifications. RTC SDK sets an appropriate bitrate based on the resolution and frame rate of the video.