Last updated: 2023-09-28 11:47:39Download PDF
This document describes how to set the image quality for a video call or live streaming session. You can set the properties according to your requirements for video quality and smoothness to deliver better user experience. Video properties include resolution, frame rate, and bitrate.
In the Electron SDK, you can adjust the image quality in the following ways:
TRTCAppSceneparameter in enterRoom: Used to select the scenario.
setVideoEncoderParam: Used to set the encoding parameter.
setNetworkQosParam: Used to specify the QoS control policy.
This document describes how to configure these parameters to make the video quality of the TRTC SDK meet your project-specific needs. You can also refer to Electron API Example: video-quality.
VideoCall: This scenario is most suitable when there are two or more people on a video call. The internal encoders and network protocols are optimized for video smoothness to reduce call latency and stuttering.
LIVE: This scenario is most suitable when there is only one person speaking or performing for an online audience, and occasionally multiple people interact with one another through video. The internal encoders and network protocols are optimized for performance and compatibility to deliver better performance and video clarity.
Video conferencing (primary image on macOS or Windows)
1280 x 720
Online education (teacher on macOS or Windows)
960 x 540
Detailed description of fields
(TRTCVideoResolution) videoResolution Encoded resolution (for example, 640 x 360) refers to the width (pixels) x height (pixels) of the encoded video image. In the
TRTCVideoResolutionenum definition, only landscape resolution (i.e., width >= height) is defined. If you want to use portrait resolution, you need to set
Because many hardware codecs only support pixel widths that are divisible by 16, the actual resolution encoded by the SDK may not be exactly the same as configured by the parameter; instead, it will be automatically corrected based on a multiple of 16. For example, the resolution 640 x 360 may be adapted to 640 x 368 inside the SDK.
(TRTCVideoResolutionMode) resMode Whether to use landscape or portrait resolutions. Because only landscape resolutions are defined in
TRTCVideoResolution, if you want to a use portrait resolution such as 360 x 640, you need to specify
TRTCVideoResolutionModePortrait. Generally, landscape resolutions are used on PCs and Macs, while portrait resolutions are used on mobile devices.
(int) videoFps Frame rate (FPS), which indicates how many frames are encoded per second. The recommended value is 15 fps, which can ensure that the video image is smooth enough without reducing the video quality due to too many frames per second.
If you have high requirements for smoothness, you can set the frame rate to 20 or 25 fps. However, do not set a value above 25 fps, because the normal frame rate of movies is only 24 fps.
(int) videoBitrate Video bitrate, which indicates how many Kbits of encoded binary data is output by the encoder per second. If you set
videoBitrateto 800 Kbps, the encoder will generate 800 Kbits of video data per second. If the data is stored as a file, the file size will be 800 Kbits, which is 100 KB or 0.1 MB.
A higher video bitrate is not always better; instead, it should be chosen appropriately based on the resolution as shown in the table below.
Resolution-bitrate reference table
If the network bandwidth is sufficient, both high definition and smoothness can be ensured. However, if the user's network connection is not ideal, you can choose whether to give priority to video quality or smoothness by specifying the
Smoothness preferred (TRTCVideoQosPreferenceSmooth) Smoothness is ensured on a weak network. The video image may be blurry, but it can be viewed smoothly with little or no stuttering.
Quality preferred (TRTCVideoQosPreferenceClear) Video quality is ensured on a weak network. The image will be as clear as possible but will tend to stutter.
controlModeparameter, select TRTCQosControlModeServer.
TRTCQosControlModeClientis used for internal debugging by the Tencent Cloud R&D team and should be ignored.
1. Higher resolution is always better
A higher resolution also requires a higher bitrate. If the resolution is 1280 x 720, but the bitrate is specified as 200 Kbps, the video will be very blurry. We recommend you set parameters by referring to the Resolution and Bitrate Reference Table.
2. Higher frame rate is always better
Because the image captured by the camera is the result of physical light exposure, setting a higher frame rate does not always result in a smoother video. On the contrary, if the frame rate is too high, the quality of each video frame will be lowered because the exposure time is reduced.
3. Higher bitrate is always better
A higher bitrate also requires a higher resolution. However, for a resolution of 320 x 240, a bitrate of 1000 Kbps is a waste. We recommend you set parameters by referring to the Resolution and Bitrate Reference Table.
4. High resolution and bitrate can always be set on a Wi-Fi network
Wi-Fi network speed is generally not constant. If the device is far from the wireless router or the router channel is occupied, the Wi-Fi network may not be as fast as 4G. The TRTC SDK provides a speed test feature, which can perform speed testing before a video call to determine the network quality based on a score.