Web

更新时间:
复制 MD 格式

The Real-Time Communication (RTC) software development kit (SDK) lets you set video encoding properties to improve the user experience in different scenarios. This topic describes how to set these properties.

Background information

In Real-Time Communication scenarios, you can set video encoding properties to adjust video definition and smoothness. For one-to-one video calls, you can increase the resolution and frame rate for a better user experience. If multiple users are in a channel, you can lower the resolution and bitrate to reduce resource consumption and downstream bandwidth usage.

Implementation

Before setting video properties, call the getAvailableResolutions method and pass the camera parameter to retrieve the supported resolutions and frame rates. Then, call the setVideoProfile method to set the video properties. The settings take effect after you call publish.

aliWebrtc.setVideoProfile({ 
      width,
      height,
      frameRate,
    },type);
NameTypeDescription
configwidthNumberThe width. Valid values:
  • Camera: 640 (default).
  • Screen sharing: 960 (default).
heightNumberThe height. Valid values:
  • Camera: 480 (default).
  • Screen sharing: 540 (default).
frameRateNumberThe frame rate. The value ranges from 5 to 30. Valid values:
  • Camera: 15 (default).
  • Screen sharing: 10 (default).
maxBitrateNumberThe maximum bitrate. Valid values:
  • Camera: 500000 (default).
  • Screen sharing: 1500000 (default).
Important This parameter is removed in version 1.13.2. The SDK automatically sets the maximum bitrate based on the specified resolution and frame rate. For versions earlier than 1.13.2, you must configure this parameter when you call setVideoProfile.
typeNumberThe stream type. Valid values:
  • 1. Camera.
  • 2: screen sharing stream.
Note Note that higher video resolutions and frame rates require higher encoding bitrates. This increases the load on device performance and consumes more network bandwidth. The RTC SDK provides default values for video encoding properties. For more information about customizing video encoding properties, see Video resolution, frame rate, and bitrate mapping.