FLiveTranscoding
旁路推流的转码属性。
USTRUCT(BlueprintType)
struct FLiveTranscoding
{
GENERATED_BODY()
public:
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|LiveTranscoding")
int width = 360;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|LiveTranscoding")
int height = 640;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|LiveTranscoding")
int videoBitrate = 400;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|LiveTranscoding")
int videoFramerate = 15;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|LiveTranscoding")
bool lowLatency = false;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|LiveTranscoding")
int videoGop = 30;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|LiveTranscoding")
EVIDEO_CODEC_PROFILE_TYPE videoCodecProfile = EVIDEO_CODEC_PROFILE_TYPE::VIDEO_CODEC_PROFILE_HIGH;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|LiveTranscoding")
int64 backgroundColor = 0x000000;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|LiveTranscoding")
EVIDEO_CODEC_TYPE_FOR_STREAM videoCodecType = EVIDEO_CODEC_TYPE_FOR_STREAM::VIDEO_CODEC_H264_FOR_STREAM;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|LiveTranscoding")
int userCount = 0;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|LiveTranscoding")
TArray<FTranscodingUser> transcodingUsers;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|LiveTranscoding")
FString transcodingExtraInfo = "";
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|LiveTranscoding")
FString metadata = "";
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|LiveTranscoding")
TArray <FRtcImage> watermark;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|LiveTranscoding")
int watermarkCount = 0;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|LiveTranscoding")
TArray<FRtcImage> backgroundImage;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|LiveTranscoding")
int backgroundImageCount = 0;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|LiveTranscoding")
EAUDIO_SAMPLE_RATE_TYPE audioSampleRate = EAUDIO_SAMPLE_RATE_TYPE::AUDIO_SAMPLE_RATE_48000;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|LiveTranscoding")
int audioBitrate = 48;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|LiveTranscoding")
int audioChannels = 1;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|LiveTranscoding")
EAUDIO_CODEC_PROFILE_TYPE audioCodecProfile = EAUDIO_CODEC_PROFILE_TYPE::AUDIO_CODEC_PROFILE_LC_AAC;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|LiveTranscoding")
TArray<FLiveStreamAdvancedFeature> advancedFeatures;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Agora|LiveTranscoding")
int advancedFeatureCount = 0;
FLiveTranscoding(){}
FLiveTranscoding(const agora::rtc::LiveTranscoding & AgoraData){
width = AgoraData.width;
height = AgoraData.height;
videoBitrate = AgoraData.videoBitrate;
videoFramerate = AgoraData.videoFramerate;
lowLatency = AgoraData.lowLatency;
videoGop = AgoraData.videoGop;
videoCodecProfile = static_cast<EVIDEO_CODEC_PROFILE_TYPE>(AgoraData.videoCodecProfile);
backgroundColor = AgoraData.backgroundColor;
videoCodecType = static_cast<EVIDEO_CODEC_TYPE_FOR_STREAM>(AgoraData.videoCodecType);
userCount = AgoraData.userCount;
for(int i = 0; i< userCount; i++){
transcodingUsers.Add(FTranscodingUser((AgoraData.transcodingUsers[i])));
}
transcodingExtraInfo = UTF8_TO_TCHAR(AgoraData.transcodingExtraInfo);
metadata = UTF8_TO_TCHAR(AgoraData.metadata);
for(unsigned int i =0; i< AgoraData.watermarkCount;i++)
{
watermark.Add(FRtcImage(AgoraData.watermark[i]));
}
watermarkCount = AgoraData.watermarkCount;
for(unsigned int i =0; i< AgoraData.backgroundImageCount;i++){
backgroundImage.Add(FRtcImage(AgoraData.watermark[i]));
}
backgroundImageCount = AgoraData.backgroundImageCount;
audioSampleRate = static_cast<EAUDIO_SAMPLE_RATE_TYPE>(AgoraData.audioSampleRate);
audioBitrate = AgoraData.audioBitrate;
audioChannels = AgoraData.audioChannels;
audioCodecProfile = static_cast<EAUDIO_CODEC_PROFILE_TYPE>(AgoraData.audioCodecProfile);
for(unsigned int i = 0; i< AgoraData.advancedFeatureCount; i++){
advancedFeatures.Add(FLiveStreamAdvancedFeature(AgoraData.advancedFeatures[i]));
}
advancedFeatureCount = AgoraData.advancedFeatureCount;
}
agora::rtc::LiveTranscoding CreateAgoraData() const {
agora::rtc::LiveTranscoding AgoraData;
AgoraData.width = width;
AgoraData.height = height;
AgoraData.videoBitrate = videoBitrate;
AgoraData.videoFramerate = videoFramerate;
AgoraData.lowLatency = lowLatency;
AgoraData.videoGop = videoGop;
AgoraData.videoCodecProfile = static_cast<agora::rtc::VIDEO_CODEC_PROFILE_TYPE>(videoCodecProfile);
AgoraData.backgroundColor = static_cast<unsigned int>(backgroundColor);
AgoraData.videoCodecType = static_cast<agora::rtc::VIDEO_CODEC_TYPE_FOR_STREAM>(videoCodecType);
AgoraData.userCount = userCount;
SET_UABT_TARRARY_CUSTOMDATA_TO_AGORA_ARRAY___MEMALLOC(AgoraData.transcodingUsers, agora::rtc::TranscodingUser, userCount, this->transcodingUsers)
SET_UABT_FSTRING_TO_CONST_CHAR___MEMALLOC(AgoraData.transcodingExtraInfo,this->transcodingExtraInfo)
SET_UABT_FSTRING_TO_CONST_CHAR___MEMALLOC(AgoraData.metadata,this->metadata)
AgoraData.watermarkCount = watermarkCount;
SET_UABT_TARRARY_CUSTOMDATA_TO_AGORA_ARRAY___MEMALLOC(AgoraData.watermark, agora::rtc::RtcImage, watermarkCount, this->watermark)
AgoraData.backgroundImageCount = backgroundImageCount;
SET_UABT_TARRARY_CUSTOMDATA_TO_AGORA_ARRAY___MEMALLOC(AgoraData.backgroundImage, agora::rtc::RtcImage, backgroundImageCount, this->backgroundImage)
AgoraData.audioSampleRate = static_cast<agora::rtc::AUDIO_SAMPLE_RATE_TYPE>(audioSampleRate);
AgoraData.audioBitrate = audioBitrate;
AgoraData.audioChannels = audioChannels;
AgoraData.advancedFeatureCount = advancedFeatureCount;
SET_UABT_TARRARY_CUSTOMDATA_TO_AGORA_ARRAY___MEMALLOC(AgoraData.advancedFeatures,agora::rtc::LiveStreamAdvancedFeature, advancedFeatureCount,this->advancedFeatures)
return AgoraData;
}
void FreeAgoraData(agora::rtc::LiveTranscoding & AgoraData) const{
SET_UABT_TARRARY_CUSTOMDATA_TO_AGORA_ARRAY___MEMFREE(AgoraData.transcodingUsers,userCount, FTranscodingUser)
SET_UABT_FSTRING_TO_CONST_CHAR___MEMFREE(AgoraData.transcodingExtraInfo)
SET_UABT_TARRARY_CUSTOMDATA_TO_AGORA_ARRAY___MEMFREE(AgoraData.watermark, watermarkCount, FRtcImage)
SET_UABT_TARRARY_CUSTOMDATA_TO_AGORA_ARRAY___MEMFREE(AgoraData.backgroundImage, backgroundImageCount, FRtcImage)
SET_UABT_TARRARY_CUSTOMDATA_TO_AGORA_ARRAY___MEMFREE(AgoraData.advancedFeatures, advancedFeatureCount, FLiveStreamAdvancedFeature)
}
};
width
推流视频的总宽度,默认值 360,单位为像素。
- 如果推视频流,
width
取值范围为 [64,1920]。如果取值低于 64,声网服务器会自动调整为 64; 如果取值高于 1920,声网服务器会自动调整为 1920。 - 如果推音频流,请将
width
和height
设为 0。
height
推流视频的总高度,默认值 640,单位为像素。
- 如果推视频流,
height
取值范围为 [64,1080]。如果取值低于 64,声网服务器会自动调整为 64; 如果取值高于 1080,声网服务器会自动调整为 1080。 - 如果推音频流,请将
width
和height
设为 0。
videoBitrate
视频编码码率,单位为 Kbps。该参数无需设置,保留默认值 STANDARD_BITRATE 即可,SDK 会根据你设定的视频分辨率和帧率自动匹配最合适的码率。有关视频分辨率和帧率的对应关系,详见视频属性。
videoFrameRate
用于旁路直播的输出视频的帧率。取值范围是 (0,30],单位为 fps。15 fps 为默认值。
lowLatency
低延时模式
true
: 低延时,不保证画质。false
:(默认值)高延时,保证画质。
videoGop
videoCodecProfile
用于旁路直播的输出视频的编码规格。可以设置为 66、77 或 100,详见 EVIDEO_CODEC_PROFILE_TYPE。
videoCodecType
transcodingUsers
用于管理参与旁路直播的视频转码合图的用户。最多支持 17 人同时参与转码合图。详见 FTranscodingUser。
transcodingExtraInfo
预留参数:用户自定义的发送到旁路推流客户端的信息,用于填充 H264/H265 视频中 SEI 帧内容。长度限制:4096 字节。关于 SEI 的详细信息,详见 SEI 帧相关问题。
backgroundColor
用于旁路直播的输出视频的背景色,格式为 RGB 定义下的十六进制整数,不要带 # 号,如 0xFFB6C1 表示浅粉色。默认0x000000,黑色。
userCount
参与合图的用户数量,默认 0。取值范围为 [0,17]。
metadata
发送给 CDN 客户端的 metadata。
watermark
直播视频上的水印。图片格式需为 PNG。详见 FRtcImage。
你可以添加一个水印,或使用数组的方式添加多个水印。该参数与 watermarkCount搭配使用。
backgroundImage
直播视频上的背景图。图片格式需为 PNG。详见 FRtcImage。
你可以添加一张背景图,或使用数组的方式添加多张背景图。该参数与 backgroundImageCount 搭配使用。
audioSampleRate
用于旁路推流的输出媒体流的音频采样率 (Hz),详见 EAUDIO_SAMPLE_RATE_TYPE。
audioBitrate
用于旁路直播的输出音频的码率。单位为 Kbps,默认值为 48,最大值为 128。
audioChannels
用于旁路直播的输出音频的声道数,默认值为 1。取值范围为 [1,5] 中的整型,建议取 1 或 2。3、4、5 需要特殊播放器支持:
- 1: (默认)单声道
- 2: 双声道
- 3: 三声道
- 4: 四声道
- 5: 五声道