Last updated: 2021-04-07 19:55:03

1. API Description

Domain name for API request:

This API is used to enable On-Cloud MixTranscoding and specify the position of each channel of image in stream mixing.

There may be multiple channels of audio/video streams in a TRTC room. You can call this API to request the Tencent Cloud server to combine multiple channels of video images and audio into one channel and specify the position of each image so as to produce just one channel of audio/video stream for recording and live streaming. The mixing stops automatically after a room is destroyed.

You can use this API to perform the following operations:

  • Set image and audio quality parameters of the final live stream, including video resolution, video bitrate, video frame rate, and audio quality.
  • Set the layout, i.e., the position of each channel of image. You only need to set it once when enabling On-Cloud MixTranscoding, and the layout engine will automatically arrange images as configured.
  • Set the names of recording files for future playback.
  • Set the stream ID for CDN live streaming.

Currently, On-Cloud MixTranscoding supports the following layout templates:

  • Floating: the entire screen is covered by the video image of the first user who enters the room, and the images of other users are displayed as small images in horizontal rows in the bottom-left corner in room entry sequence. The screen can accommodate up to 4 rows of 4 small images, which float over the big image. Up to 1 big image and 15 small images can be displayed. A user sending audio only will still occupy an image spot.
  • Grid: the images of the users split the entire screen evenly. The more the users, the smaller the image dimensions. Up to 16 images can be displayed. A user sending audio only will still occupy an image spot.
  • Screen sharing: this is designed for video conferencing and online education. The shared screen (image of the anchor) is always displayed as the big image, which occupies the left half of the screen, and the images of other users occupy the right half in up to 2 columns of up to 8 small images each. Up to 1 big image and 15 small images can be displayed. If the aspect ratio of upstream images do not match that of output images, the big image on the left will be scaled and displayed in whole, while the small images on the right will be cropped.
  • Picture-in-picture: this is designed for mixing the dual-channel (small and big) image or big image with the audio of other users. The small images float over the big image. You can specify which users to be displayed as the big/small images as well as the positions of the small images. Up to 2 images are supported.
  • Custom: this is designed for cases where you want to specify the image positions of users in the mixed stream or preset image positions. If users are assigned to preset positions, the layout engine will reserve the positions for the users; if not, users will occupy the positions in room entry sequence. Once all preset positions are occupied, TRTC will stop mixing the audio and images of other users. If the placeholding feature is enabled for a custom template (PlaceHolderMode in LayoutParams set to 1), but a user for whom a place is reserved is not sending video data, the position will show the corresponding placeholder image (PlaceImageId).

Note: only applications created on and after January 9, 2020 can call this API directly. Applications created before use the stream mixing service of LVB by default. If you want to switch to MCU On-Cloud MixTranscoding, please submit a ticket.

A maximum of 20 requests can be initiated per second for this API.

We recommend you to use API Explorer
Try it
API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

2. Input Parameters

The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

Parameter Name Required Type Description
Action Yes String Common parameter. The value used for this API: StartMCUMixTranscode.
Version Yes String Common parameter. The value used for this API: 2019-07-22.
Region Yes String Common parameter. For more information, please see the list of regions supported by the product.
SdkAppId Yes Integer SDKAppId of TRTC.
RoomId Yes Integer Room ID.
OutputParams Yes OutputParams On-Cloud MixTranscoding output control parameters.
EncodeParams Yes EncodeParams On-Cloud MixTranscoding output encoding parameters.
LayoutParams Yes LayoutParams On-Cloud MixTranscoding output layout parameters.
PublishCdnParams No PublishCdnParams Relayed push parameters of a non-Tencent Cloud CDN

3. Output Parameters

Parameter Name Type Description
RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

4. Example

Example1 Enabling On-Cloud MixTranscoding

This example shows you how to enable On-Cloud MixTranscoding for a specified room (ID: 3560) and specify the screen sharing template for image layout.

The On-Cloud MixTranscoding parameters are as follows:

  • CDN live stream ID: 1400188366_3560_mix
  • Recording file name: 1400188366_3560_mix_file
  • Video parameters for CDN live stream: aspect ratio: 1280 x 720; bitrate: 1560 Kbps; frame rate: 15 FPS; GOP: 2 seconds
  • Audio parameters for CDN live stream: audio sample rate: 48 kHz; bitrate: 64 Kbps; sound channel: dual
  • Layout template: screen sharing. The screen sharing image of user main_pc occupies the left side of the screen as the big image.

Input Example
&<Common request parameters>

Output Example

  "Response": {
    "RequestId": "eac6b301-a322-493a-8e36-83b295459397"

5. Developer Resources


TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier fo