Tutorial: Setting Local Video Properties

Setting Local Video Properties

This document describes how to set video properties for a video call or live streaming session. You can set the properties according to your requirements on video quality and smoothness to deliver better user experience. Video properties include resolution, frame rate, and bitrate.

From 1 April 2023, streaming at 2k 4k resolution requires TRTC Monthly Package Premium and higher.

Method

You can call setVideoProfile() to set video properties.

  • Using a predefined profile, which corresponds to a set of recommended resolution, frame rate, and bitrate
const localStream = TRTC.createStream({ userId, audio: true, video: true });
// Set the profile to 480p
localStream.setVideoProfile('480p');
localStream.initialize().then(() => {
  console.log('local stream init success');
  localStream.play('local_stream');
});
  • Specifying a custom resolution, frame rate, and bitrate
const localStream = TRTC.createStream({ userId, audio: true, video: true });
// Specify a value for the resolution, frame rate, and bitrate
localStream.setVideoProfile({ width: 640, height: 480, frameRate: 15, bitrate: 900 /* kpbs */});
localStream.initialize().then(() => {
  console.log('local stream init success');
  localStream.play('local_stream');
});

Note

You must call setVideoProfile() before calling initialize() to initialize the local stream. You cannot change video properties during a call.

Video Profiles

Profile Resolution (W × H) Frame Rate (fps) Bitrate (Kbps)
120p 160 × 120 15 200
180p 320 × 180 15 350
240p 320 × 240 15 400
360p 640 × 360 15 800
480p 640 × 480 15 900
720p 1280 × 720 15 1500
1080p 1920 × 1080 15 2000
1440p 2560 × 1440 30 4860
4K 3840 × 2160 30 9000
  • The target resolution of a profile may be unattainable due to device and browser restrictions, in which case the browser will adjust the resolution to make it as close as possible to the target.