VideoEncoderConfiguration
Configuration for the video encoder.
public class VideoEncoderConfiguration
{
public VIDEO_CODEC_TYPE codecType;
public VideoDimensions dimensions;
public int frameRate;
public int bitrate;
public int minBitrate;
public ORIENTATION_MODE orientationMode;
public DEGRADATION_PREFERENCE degradationPreference;
public VIDEO_MIRROR_MODE_TYPE mirrorMode;
public AdvanceOptions advanceOptions;
public VideoEncoderConfiguration(VideoDimensions d, int f, int b, ORIENTATION_MODE m, VIDEO_MIRROR_MODE_TYPE mirror = VIDEO_MIRROR_MODE_TYPE.VIDEO_MIRROR_MODE_DISABLED)
{
this.codecType = VIDEO_CODEC_TYPE.VIDEO_CODEC_NONE;
this.dimensions = d;
this.frameRate = f;
this.bitrate = b;
this.minBitrate = (int)BITRATE.DEFAULT_MIN_BITRATE;
this.orientationMode = m;
this.degradationPreference = DEGRADATION_PREFERENCE.MAINTAIN_QUALITY;
this.mirrorMode = mirror;
this.advanceOptions = new AdvanceOptions(ENCODING_PREFERENCE.PREFER_AUTO, COMPRESSION_PREFERENCE.PREFER_LOW_LATENCY);
}
public VideoEncoderConfiguration(int width, int height, int f, int b, ORIENTATION_MODE m, VIDEO_MIRROR_MODE_TYPE mirror = VIDEO_MIRROR_MODE_TYPE.VIDEO_MIRROR_MODE_DISABLED)
{
this.codecType = VIDEO_CODEC_TYPE.VIDEO_CODEC_NONE;
this.dimensions = new VideoDimensions(width, height);
this.frameRate = f;
this.bitrate = b;
this.minBitrate = (int)BITRATE.DEFAULT_MIN_BITRATE;
this.orientationMode = m;
this.degradationPreference = DEGRADATION_PREFERENCE.MAINTAIN_QUALITY;
this.mirrorMode = mirror;
this.advanceOptions = new AdvanceOptions(ENCODING_PREFERENCE.PREFER_AUTO, COMPRESSION_PREFERENCE.PREFER_LOW_LATENCY);
}
public VideoEncoderConfiguration(VideoEncoderConfiguration config)
{
this.codecType = config.codecType;
this.dimensions = config.dimensions;
this.frameRate = config.frameRate;
this.bitrate = config.bitrate;
this.minBitrate = config.minBitrate;
this.orientationMode = config.orientationMode;
this.degradationPreference = config.degradationPreference;
this.mirrorMode = config.mirrorMode;
this.advanceOptions = config.advanceOptions;
}
public VideoEncoderConfiguration()
{
this.codecType = VIDEO_CODEC_TYPE.VIDEO_CODEC_NONE;
this.dimensions = new VideoDimensions((int)FRAME_WIDTH.FRAME_WIDTH_960, (int)FRAME_HEIGHT.FRAME_HEIGHT_540);
this.frameRate = (int)FRAME_RATE.FRAME_RATE_FPS_15;
this.bitrate = (int)BITRATE.STANDARD_BITRATE;
this.minBitrate = (int)BITRATE.DEFAULT_MIN_BITRATE;
this.orientationMode = ORIENTATION_MODE.ORIENTATION_MODE_ADAPTIVE;
this.degradationPreference = DEGRADATION_PREFERENCE.MAINTAIN_QUALITY;
this.mirrorMode = VIDEO_MIRROR_MODE_TYPE.VIDEO_MIRROR_MODE_DISABLED;
this.advanceOptions = new AdvanceOptions(ENCODING_PREFERENCE.PREFER_AUTO, COMPRESSION_PREFERENCE.PREFER_LOW_LATENCY);
}
public VideoEncoderConfiguration(VIDEO_CODEC_TYPE codecType, VideoDimensions dimensions, int frameRate, int bitrate, int minBitrate, ORIENTATION_MODE orientationMode, DEGRADATION_PREFERENCE degradationPreference, VIDEO_MIRROR_MODE_TYPE mirrorMode, AdvanceOptions advanceOptions)
{
this.codecType = codecType;
this.dimensions = dimensions;
this.frameRate = frameRate;
this.bitrate = bitrate;
this.minBitrate = minBitrate;
this.orientationMode = orientationMode;
this.degradationPreference = degradationPreference;
this.mirrorMode = mirrorMode;
this.advanceOptions = advanceOptions;
}
}
Properties
- dimensions
- Resolution (px) for video encoding. See VideoDimensions. This parameter is used to measure encoding quality, expressed as width × height. The default value is 960 × 540. You can set the resolution as needed.
- codecType
- Video codec type. See VIDEO_CODEC_TYPE.
- frameRate
- Frame rate (fps) for video encoding. Default is 15. See FRAME_RATE.
- bitrate
- Bitrate for video encoding in Kbps. See BITRATE. You don't need to set this parameter; keep the default value STANDARD_BITRATE. The SDK automatically selects the optimal bitrate based on your configured video resolution and frame rate. For details on the relationship between resolution and frame rate, see Video Profile.
- minBitrate
- Minimum encoding bitrate in Kbps.
The SDK automatically adjusts the video encoding bitrate based on network conditions. Setting this parameter higher than the default forces the encoder to output high-quality images, but may cause packet loss and video stuttering under poor network conditions. Therefore, unless you have specific quality requirements, Agora recommends not modifying this parameter.
Note: This parameter applies to live streaming only.
- orientationMode
- Orientation mode for video encoding. See ORIENTATION_MODE.
- degradationPreference
- Video degradation preference when bandwidth is limited. See DEGRADATION_PREFERENCE.
Note: When this parameter is set to MAINTAIN_FRAMERATE (1) or MAINTAIN_BALANCED (2), you must also set
orientationModeto ORIENTATION_MODE_ADAPTIVE (0), otherwise the setting will not take effect. - mirrorMode
- Whether to enable mirror mode when sending encoded video. This only affects what remote users see. See VIDEO_MIRROR_MODE_TYPE.
Note: Mirror mode is disabled by default.
- advanceOptions
- Advanced options for video encoding. See AdvanceOptions.