TRTCTranscodingConfig

TRTCTranscodingConfig

5.11 Layout and transcoding parameters of On-Cloud MixTranscoding

Constructor

new TRTCTranscodingConfig(mode, appId, bizId, videoWidth, videoHeight, videoBitrate, videoFramerate, videoGOP, backgroundColor, backgroundImage, audioSampleRate, audioBitrate, audioChannels, mixUsersArray, streamId)

These parameters are used to specify the layout position information of each video image and the encoding parameters of mixtranscoding during On-Cloud MixTranscoding.

Parameters:
Name Type Description
mode TRTCTranscodingConfigMode

[Field description] layout mode. please choose a value according to your business needs. The preset mode has better applicability.

appId Number

[Field description] appId of Tencent Cloud CSS
[Recommended value] please click Application Management > Application Information in the TRTC console and get the appId in Relayed Live Streaming Info.

bizId Number

[Field description] bizId of Tencent Cloud CSS
[Recommended value] please click Application Management > Application Information in the TRTC console and get the bizId in Relayed Live Streaming Info.

videoWidth Number

[Field description] specify the target resolution (width) of On-Cloud MixTranscoding
[Recommended value] 360 px. If you only mix audio streams, please set both width and height to 0; otherwise, there will be a black background in the live stream after mixtranscoding.

videoHeight Number

[Field description] specify the target video frame rate (fps) of On-Cloud MixTranscoding
[Recommended value] 640 px. If you only mix audio streams, please set both width and height to 0; otherwise, there will be a black background in the live stream after mixtranscoding.

videoBitrate Number

[Field description] specify the target video bitrate (Kbps) of On-Cloud MixTranscoding [Recommended value] if you enter 0, TRTC will estimate a reasonable bitrate value based on videoWidth and videoHeight. You can also refer to the recommended bitrate value in the video resolution enumeration definition (in the comment section).

videoFramerate Number

[Field description] specify the target video frame rate (fps) of On-Cloud MixTranscoding
[Recommended value] default value: 15 fps. Value range: (0,30].

videoGOP Number

[Field description] specify the target video keyframe interval (GOP) of On-Cloud MixTranscoding
[Recommended value] default value: 2 (in seconds). Value range: [1,8].

backgroundColor Number

[Field description] specify the background color of the mixed video image.
[Recommended value] default value: 0x000000, which means black and is in the format of hex number; for example: "0x61B9F1" represents the RGB color (97,158,241).

backgroundImage String

[Field description] specify the background image of the mixed video image.
[Recommended value] default value: '', indicating not to set the background image.
[Note] you need to upload the background image by clicking Add image in "Application Management" > "Function Configuration" > "Material Management" in the console in advance.
After the upload is successful, you can get the corresponding "image ID". Then, you need to convert it into a string and set it as backgroundImage.
For example, if the "image ID" is 63, you can set backgroundImage = @"63";

audioSampleRate Number

[Field description] specify the target audio sample rate of On-Cloud MixTranscoding
[Recommended value] default value: 48000 Hz. Valid values: 12000 Hz, 16000 Hz, 22050 Hz, 24000 Hz, 32000 Hz, 44100 Hz, 48000 Hz.

audioBitrate Number

[Field description] specify the target audio bitrate of On-Cloud MixTranscoding
[Recommended value] default value: 64 Kbps. Value range: [32,192].

audioChannels Number

[Field description] specify the number of sound channels of On-Cloud MixTranscoding
[Recommended value] default value: 1, which means mono channel. Valid values: 1: mono channel; 2: dual channel.

mixUsersArray Array.<TRTCMixUser>

[Field description] specify the position, size, layer, and stream type of each video image in On-Cloud MixTranscoding

streamId String

[Field description] ID of the live stream output to CDN
- If you don't set this parameter, the SDK will execute the default logic, that is, it will mix the multiple audio/video streams in the room into the audio/video stream of the caller of this API, i.e., A + B => A.
- If you set this parameter, the SDK will mix the audio/video streams in the room into the live stream you specify, i.e., A + B => C (C is the streamId you specify). [Recommended value] default value: null, that is, the audio/video streams in the room will be mixed into the audio/video stream of the caller of this API.