Technology Encyclopedia Home >How to set the uplink video bitrate, resolution, and frame rate in the real-time audio and video SDK?

How to set the uplink video bitrate, resolution, and frame rate in the real-time audio and video SDK?

To set the uplink video bitrate, resolution, and frame rate in a real-time audio and video SDK, you typically need to configure these parameters when initializing the video stream or during the session setup. The exact method depends on the SDK you are using, but most SDKs provide APIs or configuration options to customize these settings.

Steps to Set Uplink Video Parameters:

  1. Resolution: Set the desired video resolution (e.g., 720p, 1080p). This is usually specified as width and height in pixels.
  2. Frame Rate: Set the frame rate (e.g., 15 fps, 30 fps). This determines how many frames are sent per second.
  3. Bitrate: Set the video bitrate (e.g., 1 Mbps, 2 Mbps). This controls the amount of data sent per second for the video stream.

Example:

If you are using a hypothetical SDK, the configuration might look like this:

const videoConfig = {
  resolution: { width: 1280, height: 720 }, // 720p
  frameRate: 30, // 30 fps
  bitrate: 2000 // 2 Mbps
};

// Initialize the video stream with the configuration
sdk.initializeVideoStream(videoConfig);

Using Tencent Cloud Real-Time Communication (TRTC) SDK:

If you are using Tencent Cloud's TRTC SDK, you can set these parameters when creating a video track or configuring the local stream. For example:

const localTrack = await TRTC.createCameraVideoTrack({
  width: 1280,
  height: 720,
  frameRate: 30,
  bitrate: 2000
});

Tencent Cloud TRTC also provides advanced features like adaptive bitrate control, which can dynamically adjust the bitrate based on network conditions to ensure smooth video transmission. You can enable this feature in the SDK configuration to optimize the user experience.