This section introduces how to set video publishing parameters using the audio/video SDK.
When setting video profiles in a video call or an interactive live stream, you can adjust video picture resolution, frame rate, and bit rate according to preference for better user experience.
Before configuring video profiles, make sure that the basic real-time audio/video function is ready for your project. See details in Quickstart Guide.
Thunder SDK uses setVideoEncoderConfig to set video-related publishing brackets.
/**
* Get video start parameters from Argo according to the parameters;
* If it has been previewed, it will take effect in the preview;
* If the publishing has already started, update the parameters, and the local preview and remote subscription will see the changed effect;
* Need to be called after "initialization"
* @param yyVideoConfig Specific encoding configuration
* @return 0: Succeed. For other errors, refer to {@link ThunderRtcConstant.ThunderRet}
*/
public int setVideoEncoderConfig(ThunderVideoEncoderConfiguration yyVideoConfig)
ThunderVideoEncoderConfiguration
defines two types, including playType
(playing type) and publishMode
(publishing bracket).
For publishing modes, there are several types, as defined below:
public static final class ThunderPublishPlayType {
public static final int THUNDERPUBLISH_PLAY_SINGLE = 0; // Single publishing
public static final int THUNDERPUBLISH_PLAY_INTERACT = 1; // Co-hosting video publishing
public static final int THUNDERPUBLISH_PLAY_SCREENCAP = 2; // Screen recording publishing
public static final int THUNDERPUBLISH_PLAY_MULTI_INTERACT = 3; // Multi-person co-hosting video publishing
}
Depending on which of these publishing types you are working with, video optimization will target different aspects.
The current client is divided into the following brackets:
/**
* Publishing bracket
*/
public static final class ThunderPublishVideoMode {
public static final int THUNDERPUBLISH_VIDEO_MODE_NORMAL = 1; /*! Normal */
public static final int THUNDERPUBLISH_VIDEO_MODE_HIGHQULITY = 2; /*! High quality */
public static final int THUNDERPUBLISH_VIDEO_MODE_SUPERQULITY = 3; /*! Super quality */
public static final int THUNDERPUBLISH_VIDEO_MODE_BLUERAY_2M = 4; /*! Blue ray 2M */
public static final int THUNDERPUBLISH_VIDEO_MODE_BLUERAY_4M = 5; /*! Blue ray 4M */
}
To flexibly customize user-defined video quality, Thunder uses a dynamically reconfigurable scheme in the background to determine video publishing clarity and smoothness. Users can customize each bracket’s resolution, bit rate, frame rate, and other parameters, and may contact technical support to modify associated parameters.
Once ThunderEngine
is initialized, you can call setVideoEncoderConfig as needed to set video profiles and to set a required publishing bracket in this method.
//Create encoding configuration
ThunderVideoEncoderConfiguration configuration = new ThunderVideoEncoderConfiguration();
configuration.playType = ThunderRtcConstant.ThunderPublishPlayType.THUNDERPUBLISH_PLAY_SINGLE;
configuration.publishMode = ThunderRtcConstant.ThunderPublishVideoMode.THUNDERPUBLISH_VIDEO_MODE_HIGHQULITY;
//Settings
ThunderEngine.setVideoEncoderConfig(configuration);
Generally, you should fit video parameters to the situation or scenario. For example, in a one-to-one teaching scenario, the windows of the teacher and the student are both large, requiring a high resolution; therefore, the frame and bit rates are also higher. However, in a one-to-four scenario, the windows of the teacher and the students are relatively small, allowing for a low resolution, lower bit and frame rates, overall reducing the resources consumed by encoding and decoding and relieving stress on downlink bandwidth. Commonly, the modes can be set based on the values recommended in the following scenarios.
Refer to the following table when considering the customization of video parameters.
Resolution (Width x Height) | Frame Rate (fps) | Standard Bit Rate (kbps, Applicable to Communication) | Live Streaming Bit Rate (kbps, Applicable to Live Streaming) |
---|---|---|---|
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 |