FVideoEncoderConfiguration
视频编码器的配置。
C++
USTRUCT(BlueprintType)
struct FVideoEncoderConfiguration
{
GENERATED_BODY()
public:
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|VideoEncoderConfiguration")
EVIDEO_CODEC_TYPE codecType = EVIDEO_CODEC_TYPE::VIDEO_CODEC_NONE;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|VideoEncoderConfiguration")
FVideoDimensions dimensions = FVideoDimensions();
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|VideoEncoderConfiguration")
int frameRate = 15;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|VideoEncoderConfiguration")
int bitrate = 0;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|VideoEncoderConfiguration")
int minBitrate = -1;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|VideoEncoderConfiguration")
EORIENTATION_MODE orientationMode = EORIENTATION_MODE::ORIENTATION_MODE_ADAPTIVE;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|VideoEncoderConfiguration")
EDEGRADATION_PREFERENCE degradationPreference = EDEGRADATION_PREFERENCE::MAINTAIN_QUALITY;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|VideoEncoderConfiguration")
EVIDEO_MIRROR_MODE_TYPE mirrorMode = EVIDEO_MIRROR_MODE_TYPE::VIDEO_MIRROR_MODE_DISABLED;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|VideoEncoderConfiguration")
FAdvanceOptions advanceOptions = FAdvanceOptions();
FVideoEncoderConfiguration(){}
FVideoEncoderConfiguration(const agora::rtc::VideoEncoderConfiguration & AgoraData){
codecType = static_cast<EVIDEO_CODEC_TYPE>(AgoraData.codecType);
dimensions = FVideoDimensions(AgoraData.dimensions);
frameRate = AgoraData.frameRate;
bitrate = AgoraData.bitrate;
minBitrate = AgoraData.minBitrate;
orientationMode = static_cast<EORIENTATION_MODE>(AgoraData.orientationMode);
degradationPreference = static_cast<EDEGRADATION_PREFERENCE>(AgoraData.degradationPreference);
mirrorMode = static_cast<EVIDEO_MIRROR_MODE_TYPE>(AgoraData.mirrorMode);
advanceOptions = FAdvanceOptions(AgoraData.advanceOptions);
}
agora::rtc::VideoEncoderConfiguration CreateAgoraData() const {
agora::rtc::VideoEncoderConfiguration AgoraData;
AgoraData.codecType = static_cast<agora::rtc::VIDEO_CODEC_TYPE>(codecType);
AgoraData.dimensions = dimensions.CreateAgoraData();
AgoraData.frameRate = frameRate;
AgoraData.bitrate = bitrate;
AgoraData.minBitrate = minBitrate;
AgoraData.orientationMode = static_cast<agora::rtc::ORIENTATION_MODE>(orientationMode);
AgoraData.degradationPreference = static_cast<agora::rtc::DEGRADATION_PREFERENCE>(degradationPreference);
AgoraData.mirrorMode = static_cast<agora::rtc::VIDEO_MIRROR_MODE_TYPE>(mirrorMode);
AgoraData.advanceOptions = advanceOptions.CreateAgoraData();
return AgoraData;
}
void FreeAgoraData(agora::rtc::VideoEncoderConfiguration& AgoraData) const {
dimensions.FreeAgoraData(AgoraData.dimensions);
advanceOptions.FreeAgoraData(AgoraData.advanceOptions);
}
};
dimensions
视频编码的分辨率 (px),详见 FVideoDimensions。该参数用于衡量编码质量,以长 × 宽表示,默认值为 960 × 540。用户可以自行设置分辨率。
codecType
视频编码类型,详见 EVIDEO_CODEC_TYPE。
frameRate
视频编码的帧率(fps),默认值为 15。
- FRAME_RATE_FPS_1(1): 1 fps。
- FRAME_RATE_FPS_7(7): 7 fps。
- FRAME_RATE_FPS_10(10): 10 fps。
- FRAME_RATE_FPS_15(15): 15 fps。
- FRAME_RATE_FPS_24(24): 24 fps。
- FRAME_RATE_FPS_30(30): 30 fps。
- FRAME_RATE_FPS_60(60): 60 fps。该帧率仅适用于 Windows 和 macOS 平台。
bitrate
视频编码码率,单位为 Kbps。该参数无需设置,保留默认值 STANDARD_BITRATE 即可,SDK 会根据你设定的视频分辨率和帧率自动匹配最合适的码率。有关视频分辨率和帧率的对应关系,详见视频属性。
- STANDARD_BITRATE (0): (默认) 标准码率模式。
- COMPATIBLE_BITRATE (-1): 适配码率模式。一般情况下,声网建议你不要使用该值。
minBitrate
最低编码码率,单位为 Kbps。
SDK 会根据网络状况自动调整视频编码码率。将参数设为高于默认值可强制视频编码器输出高质量图片,但在网络状况不佳情况下可能导致网络丢包并影响视频播放的流畅度造成卡顿。因此如非对画质有特殊需求,声网建议不要修改该参数的值。
注意
该参数仅适用于直播场景。
orientationMode
视频编码的方向模式,详见 EORIENTATION_MODE。
degradationPreference
带宽受限时,视频编码降级偏好。详见 EDEGRADATION_PREFERENCE。
注意
当该参数设置为 MAINTAIN_FRAMERATE (1) 或者 MAINTAIN_BALANCED (2) 时,需要同时将 orientationMode 设置为 ORIENTATION_MODE_ADAPTIVE (0),否则设置不生效。
mirrorMode
发送编码视频时是否开启镜像模式,只影响远端用户看到的视频画面。详见 EVIDEO_MIRROR_MODE_TYPE。
注意
该参数不生效。如需实现镜像显示效果,请在 Unreal Engine 中进行镜像设置。
注意
默认关闭镜像模式。
advanceOptions
视频编码的高级选项。详见 FAdvanceOptions。