You can set the video profile, either before or after a user joins a channel, for the user to enjoy better video quality during a video call or interactive live streaming.
The Agora SDK uses the SetVideoEncoderConfiguration
method to set the video profile. Each video profile corresponds to a set of video parameters, including the resolution, frame rate, bitrate, and video orientation.
Before setting the video profile, ensure that you have implemented the basic real-time communication functions in your project. For details, see Start a Video Call or Start Live Interactive Video Streaming.
After initializing IRtcEngine
, you can call the SetVideoEncoderConfiguration
method to set the video profile and set the video resolution, frame rate, birtate and orientation mode.
Refer to the following diagram to set the video profile in your project:
You can also choose when to call the SetVideoEncoderConfiguration
method according to your scenarios:
EnableVideo
and EnableVideoObserver
and before JoinChannelByKey
to set the local video encoding parameters before joining the channel.EnableVideo
to reduce the render time of the first video frame.// Create a VideoEncoderConfiguration instance. See the descriptions of the parameters in API Reference.
VideoEncoderConfiguration config = new VideoEncoderConfiguration();
// Sets the video resolution.
config.dimensions.width = 640;
config.dimensions.height = 480;
// Sets the video frame rate.
config.frameRate = FRAME_RATE.FRAME_RATE_FPS_15;
// Sets the video encoding bitrate (Kbps).
config.bitrate = 800;
// Sets the adaptive orientation mode. See the description in API Reference.
config.orientationMode = ORIENTATION_MODE.ORIENTATION_MODE_ADAPTIVE;
// Sets the video encoding degradation preference under limited bandwidth. MIANTAIN_QUALITY means to degrade the frame rate to maintain the video quality.
config.degradationPreference = DEGRADATION_PREFERENCE.MAINTAIN_QUALITY;
// Sets the video encoder configuration.
mRtcEngine.SetVideoEncoderConfiguration(config);
Setting DEGRADATION_PREFERENCE
as MAINTAIN_QUALITY
means that the SDK degrades the frame rate under limited bandwidth so as to maintain the video quality. Developers can set the minFrameRate
parameter to balance the frame rate and video quality under unreliable network connections:
minFrameRate
is relatively low, the frame rate degrades significantly, so the poor network conditions have little impact on the video quality.minFrameRate
is relatively high, the frame rate degrades within a limited range, so the poor network conditions can have huge impact on the video quality.Do not set the minFrameRate
parameter to a value greater than frameRate
. The default value of minFrameRate
is experiment verified and can satisfy most use scenarios. Agora does not recommend changing it.
If you do not need to set the video profile after joining the channel, you can call the SetVideoEncoderConfiguration
method before the EnableVideo
method to reduce the render time of the first video frame.
The Agora Unity SDK may adjust the parameters under poor network conditions.
A interactive live streaming channel generally requires a higher bitrate for better video quality. Therefore, Agora recommends setting the bitrate in the LIVE_BROADCASTING
profile to twice of that in the COMMUNICATION
profile. See Set the bitrate.
For better video quality during the interactive live streaming, a stable network connection is recommended.
Setting parameters in the SetVideoEncoderConfiguration
method may affect your bill. For more information, see Billing.
Video profiles vary from case to case. For example, in a one-to-one online class, the video windows of the teacher and student are both large, which requires higher resolutions, frame rates, and bitrates. While in a one-to-four online class, the video windows of the teacher and students are smaller, so lower resolutions, frame rates, and bitrates are used to accommodate the downward bandwidth.
The following profiles for different scenarios are recommended:
You can also customize the video parameters with the SetVideoEncoderConfiguration
method, such as increasing the bitrate to ensure the video quality according to the table below.
Resolution (width x height) |
Frame rate (fps) |
Base bitrate (Kbps, for COMMUNICATION ) |
Live bitrate (Kbps, for LIVE_BROADCASTING ) |
---|---|---|---|
160 x 120 | 15 | 65 | 130 |
120 x 120 | 15 | 50 | 100 |
320 x 180 | 15 | 140 | 280 |
180 x 180 | 15 | 100 | 200 |
240 x 180 | 15 | 120 | 240 |
320 x 240 | 15 | 200 | 400 |
240 x 240 | 15 | 140 | 280 |
424 x 240 | 15 | 220 | 440 |
640 x 360 | 15 | 400 | 800 |
360 x 360 | 15 | 260 | 520 |
640 x 360 | 30 | 600 | 1200 |
360 x 360 | 30 | 400 | 800 |
480 x 360 | 15 | 320 | 640 |
480 x 360 | 30 | 490 | 980 |
640 x 480 | 15 | 500 | 1000 |
480 x 480 | 15 | 400 | 800 |
640 x 480 | 30 | 750 | 1500 |
480 x 480 | 30 | 600 | 1200 |
848 x 480 | 15 | 610 | 1220 |
848 x 480 | 30 | 930 | 1860 |
640 x 480 | 10 | 400 | 800 |
1280 x 720 | 15 | 1130 | 2260 |
1280 x 720 | 30 | 1710 | 3420 |
960 x 720 | 15 | 910 | 1820 |
960 x 720 | 30 | 1380 | 2760 |