tencent cloud

文档反馈

StartPublishCdnStream

最后更新时间:2024-10-17 16:54:38

    1. API Description

    Domain name for API request: trtc.tencentcloudapi.com.

    In a TRTC room, there may be multiple audio and video streams concurrently active. You can use the MixTranscoding API to notify Tencent Cloud server to mix multiple video screens from the same room or multiple rooms together, and specify the position of each screen, while mixing multiple audio streams together. The final result is a single audio and video stream, which can be used for recording and live viewing. It also supports pushing this mixed audio and video stream back to the TRTC room.

    The Cloud API MixTranscoding feature includes three interfaces:

    1. StartPublishCdnStream: Start a MixTranscoding task. This interface will initiate a new MixTranscoding task. After the task is successfully started, a unique TaskId will be returned under the sdkappid dimension. You need to save this TaskId, as it will be required for updating and stopping the task later.
    2. UpdatePublishCdnStream: Update the specified MixTranscoding task, including updating the video screen layout, updating the mixing list, updating the list of CDN addresses to be relayed, and updating the list of rooms to be pushed back.
    3. StopPublishCdnStream: Stop the specified MixTranscoding task.

    You can achieve the following goals through this set of interfaces:

    1. Set the final video and audio quality, including video resolution, video frame rate, video bitrate, and audio quality.
    2. Set the layout position of each screen. You only need to set it once. When you specify the MixTranscoding user to enter the room and send audio and video, the layout engine will automatically mix the user's screen to the specified layout position. You can also use the update interface to adjust the layout position.
    3. Set multiple CDN relay target addresses. A single relay task can support up to 10 CDN relay addresses at the same time.
    4. Set multiple room pushback lists. A single relay task can support up to 10 TRTC rooms for mixed stream pushback.

    The following layout templates are currently supported. Dynamic layout templates (floating template, grid template, screen sharing template) only support a single TRTC room, while custom templates support mixing audio and video streams from multiple TRTC rooms. The specific descriptions are as follows:

    1. Floating template: The video screen of the first user entering the room will fill the entire screen, and the video screens of other users will be arranged horizontally from the bottom left corner, displaying as small screens, with up to 4 rows and 4 screens per row. The small screens float above the large screen. It supports up to 1 large screen and 15 small screens. If the user only sends audio, it does not occupy the layout configuration by default, but it can also be set. Each sub-screen is rendered by default using the center cropping method, and the rendering method of the sub-screen can also be set uniformly.
    2. Grid template: The video screens of all users are of the same size, evenly dividing the entire screen. The more people there are, the smaller the size of each user's screen. It supports up to 16 screens. If the user only sends audio, it does not occupy the layout configuration by default, but it can also be set. Each sub-screen is rendered by default using the center cropping method, and the rendering method of the sub-screen can also be set uniformly.
    3. Screen sharing template: Suitable for video conference and online education scenarios. The screen sharing (or the main speaker's camera) always occupies the large screen position on the left side of the screen. You need to explicitly set the MixTranscoding user information that occupies the large screen. Other users are arranged vertically on the right side, with up to two columns and 8 small screens per column. It supports up to 1 large screen and 15 small screens. If the uplink resolution aspect ratio is different from the screen output aspect ratio, the large screen on the left side will be scaled to maintain content integrity, while the small screens on the right side will be cropped. The rendering method of the sub-screen can also be set uniformly.
    4. Custom layout template: Allows you to actively set the layout position according to your business needs. Each preset layout position supports named settings (named settings require specifying the room number and username) and unnamed settings. When a sub-screen is named, the position is reserved for the user, and the user will automatically occupy the position when entering the room and sending audio and video data. Other users will not occupy this position. When the preset layout position is not named, the layout engine will automatically fill in the order of entering the room. When the preset positions are full, no other users' screens and sounds will be mixed. Each sub-screen position supports setting placeholder images (BackgroundImageUrl). When the user does not enter the room or only sends audio data, the screen at this position can display the corresponding placeholder image.

    When using the relay API, you may incur the following costs depending on the usage characteristics:
    For MCU MixTranscoding fees, please refer to the documentation: Billing of MixTranscoding and Relay to CDN | Tencent Cloud.
    For non-Tencent Cloud CDN relay fees, please refer to the documentation: Billing of MixTranscoding and Relay to CDN | Tencent Cloud.

    Instructions for using parameters:

    1. AgentParams: Each relay task will pull a robot user into the TRTC room to pull the stream. You need to set this robot user through the AgentParams.UserId parameter. This robot ID cannot conflict with the normal user ID in the room, otherwise, the relay task will be abnormally terminated due to the robot user being kicked out of the TRTC room. You can avoid this by adding a special prefix. You can control the automatic termination of the relay task by setting AgentParams.MaxIdleTime. When this parameter is set, the relay task will automatically stop when all participating MixTranscoding anchors continuously leave the TRTC room for more than MaxIdleTime duration. Note: The relay task will not automatically stop when the participating MixTranscoding anchor only stops sending audio and video.
    2. WithTranscoding: If you need to mix multiple audio and video streams into one, WithTranscoding must be set to 1.
    3. AudioParams: The audio parameters and video parameters of the relay task are set separately. If you want to mix the audio of specified users, you need to explicitly set AudioParams.SubscribeAudioList. If you do not set AudioParams.SubscribeAudioList, the mixing engine will automatically mix the audio of all users in the TRTC room. If you want to mix the audio of all users in the TRTC room except for specified users, you can set the audio blacklist list through AudioParams.UnSubscribeAudioList.
    4. VideoParams: If you want to mix user videos, you can set it through VideoParams. If you only want to mix audio, you do not need to set VideoParams. You can set the screen layout mode through VideoParams.LayoutParams.MixLayoutMode, including dynamic layout (1: floating layout (default), 2: screen sharing layout, 3: grid layout) and custom layout. The dynamic layout mode is automatically mixed by the layout engine according to a fixed layout, and there is no need to set VideoParams.LayoutParams.MixLayoutList. When using the floating layout and screen sharing layout, you can specify the large screen user by setting VideoParams.LayoutParams.MaxVideoUser. The custom layout mode provides you with the ability to layout screens independently, and you can specify the layout position of each user through VideoParams.LayoutParams.MixLayoutList. In each layout parameter, you can specify the layout position for the specified user by setting the UserMediaStream parameter, or you can not set the UserMediaStream, and the layout engine will automatically fill in the order of users entering the TRTC room. In addition, you can set the rendering method (RenderMode) and cropping method (CustomCrop) for each layout position.
    5. VideoParams.WaterMarkList: If you want to overlay a watermark on the mixed screen, you can set it through VideoParams.WaterMarkList. It supports image watermarks and text watermarks and supports transparent channels.
    6. SingleSubscribeParams: If you want to push a single stream from the TRTC room to the CDN, you can set it using the SingleSubscribeParams parameter. In this case, you need to set the WithTranscoding parameter to 0.
    7. PublishCdnParams.N: If you want to push the stream to the CDN, you can set it using the PublishCdnParams.N parameter. It supports pushing to up to 10 CDN addresses at the same time. If the relay address is Tencent Cloud CDN, please set IsTencentCdn explicitly to 1; if you need to relay to a non-Tencent Cloud CDN, please contact Tencent Cloud Technical Support to enable it. Relaying to non-Tencent Cloud will incur relay fees. For fee information, please refer to the official documentation: On-Cloud Relay Billing Overview.
    8. FeedBackRoomParams.N: If you want to push the mixed audio and video stream back to the TRTC room, you can set it using the FeedBackRoomParams.N parameter. It supports pushing up to 10 streams back to the TRTC room at the same time. You need to specify the TRTC room number and robot ID (UserId) for the pushback. The robot ID cannot conflict with the normal user ID, otherwise, the relay task will be abnormally terminated due to the robot user being kicked out of the TRTC room. You can avoid this by adding a special prefix.
    9. SeiParams: If you want to add SEI information to the mixed audio and video stream, you can set it using the SeiParams parameter. It supports volume layout SEI and overlay relay request SEI. The content of the volume layout SEI is a fixed JSON structure, please see the SEI description in the following section of this chapter. You can set the SEI to follow the keyframe by setting the FollowIdr parameter. The description of the volume layout SEI is as follows:
      If your CDN audience needs to recognize the position of the participating MixTranscoding anchors and the volume information of the participating MixTranscoding anchors, you can use the volume layout SEI. The payload content and parameter description of the volume layout SEI are as follows:
      { "app_data":"", "canvas":{ "w":1080, "h":960 }, "regions":[ { "uid":"65949987242835883c", "zorder":2, "volume":45, "x":270, "y":480, "w":540, "h":480 }, { "uid":"659c9d8d242b328d31", "zorder":2, "volume":0, "x":0, "y":0, "w":540, "h":480 }, { "uid":"64989a82272b308c", "zorder":2, "volume":91, "x":540, "y":0, "w":540, "h":480 } ], "ver":"1.0", "ts":1648544726 }
      canvas: This is the width and height of the VideoEncode setting in the MixTranscoding signaling, that is, the width and height of the entire canvas of the MixTranscoding output.
      regions: Contains the real mixed user ID and the corresponding sub-screen position. If the participating MixTranscoding user does not enter the TRTC room or does not turn on the video uplink, the regions will not include the user.
      uid: Represents the user ID participating in MixTranscoding.
      zorder: The layer of the participating MixTranscoding userid in the MixTranscoding output.
      x/y: The coordinates of the sub-screen of the participating MixTranscoding userid on the canvas.
      w/h: The size of the sub-screen of the participating MixTranscoding userid.
      volume: Represents the volume of the MixTranscoding user, with a value range of 0-100. The larger the value, the greater the volume of the user participating in MixTranscoding.
      ts: The server local second-level timestamp for outputting SEI.
      ver: can be ignored.

    Usage Precautions:

    1. When using the Mixed Relay Interface, you need to call the Start Relay Task Interface (StartPublishCdnStream) first to get the Task ID from the response. Then, use the Task ID to update the relay task (UpdatePublishCdnStream) and stop the relay task (StopPublishCdnStream).
    2. The Relay API does not support initiating Automatic Bypass Tasks configured in the TRTC Console, nor does it support Custom Stream ID bypass tasks set in the TRTC SDK room entry interface.
    3. To ensure the stability of the relay link, the same relay task does not support switching between Audio only, Audio and Video, and Video only.
    4. To ensure the stability of the relay link, updating video parameters (codec) and audio parameters (codec, Sample rate, bitrate, and number of channels) is not supported during the Update Video process.
    5. When initiating a single stream bypass task, filling in both Audio Parameters and Video Parameters means Audio and Video bypass. If only Audio Parameters are filled in, it means Audio only bypass, and switching from Audio only to Audio and Video is not supported during the task progress. For Audio and Video bypass, the Width, Height, Fps, BitRate, and Gop in Video Parameters must be filled in according to the real upstream parameters.
    6. The SequenceNumber parameter must be carried in the update request to prevent request disorder. Customers must ensure that the SequenceNumber parameter increases when updating the same task, otherwise, the mix task update will fail.
    7. When calling the API, choose the region according to the following instructions: If the Application ID is 1400xxx, the region can be Beijing, Shanghai, Guangzhou, or Hong Kong. If your CDN audience is mainly overseas, please choose Hong Kong. If the Application ID is 200xxx or 400xxx, please choose Singapore.
    8. Streams pushed back to the TRTC room will not participate in the mixing of other push back room tasks. If one of the following conditions is met, it can participate in the mixing of other relay CDN tasks: (1) The push stream robot is specified to participate in the mixing in the video parameters of the relay CDN task; (2) The push stream robot is specified to participate in the mixing in the audio parameters of the relay CDN task through the whitelist method; (3) The room number of the mix user participating in the relay CDN task is completely different from the room number of the mix user corresponding to the push back robot.
    9. You can create a relay task before the anchor enters the room. When the relay task is finished, you need to call the stop interface actively. If you do not call the Stop Relay Task Interface, Tencent Cloud will automatically stop the mix relay task when all users participating in the mix have no data uploaded for a period of time exceeding the timeout (AgentParams.MaxIdleTime) set when starting the relay task.

    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 Params. The value used for this API: StartPublishCdnStream.
    Version Yes String Common Params. The value used for this API: 2019-07-22.
    Region Yes String Common Params. For more information, please see the list of regions supported by the product. This API only supports: ap-guangzhou, ap-hongkong, ap-singapore.
    SdkAppId Yes Integer The SDKAppID of the TRTC room whose streams are relayed.
    RoomId Yes String The ID of the room whose streams are relayed (the main room).
    RoomIdType Yes Integer The type of the RoomId parameter, which must be the same as the ID type of the room whose streams are relayed. 0: integer; 1: string.
    AgentParams Yes AgentParams The information of the relaying robot in the room.
    WithTranscoding Yes Integer Whether to transcode the streams. 0: No. 1: Yes. This parameter determines whether transcoding fees are charged. If it is 0, streams will only be relayed, and no transcoding fees will be incurred. If it is 1, streams will be transcoded before being relayed, and transcoding fees will be incurred.
    AudioParams No McuAudioParams The audio encoding parameters. Because audio is always transcoded (no fees are incurred), this parameter is required when you start a relay task.
    VideoParams No McuVideoParams The video encoding parameters for relaying. If you do not pass this parameter, only audio will be relayed.
    SingleSubscribeParams No SingleSubscribeParams The information of a single stream relayed. When you relay a single stream, set WithTranscoding to 0.
    PublishCdnParams.N No Array of McuPublishCdnParam The information of the CDNs to relay to. You need to specify at least one between this parameter and FeedBackRoomParams.N.
    SeiParams No McuSeiParams The stream mixing SEI parameters.
    FeedBackRoomParams.N No Array of McuFeedBackRoomParams The information of the room to which streams are relayed. Between this parameter and PublishCdnParams, you must specify at least one. Please note that relaying to a TRTC room is only supported in some SDK versions. For details, please contact technical support.

    3. Output Parameters

    Parameter Name Type Description
    TaskId String The task ID, which is generated by the Tencent Cloud server. You need to pass in the task ID when making a request to update or stop a relaying task.
    RequestId String The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem.

    4. Example

    Example1 Starting a task to mix audio&video streams and relay the mixed stream

    Input Example

    POST / HTTP/1.1
    Host: trtc.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: StartPublishCdnStream
    <Common request parameters>
    
    {
        "AgentParams": {
            "MaxIdleTime": 30,
            "UserSig": "eJw1zV8LgjAUBfCvInsO2dStGfQSQUb2pFJvsnLJJZW1LekPffdc6X08v8O5b5Snmd9LjRYeCnyMZt4vgUp2Fi7wB6vtuVRC207q0kpjSzIVTXUVSkE11EiEMeE8ZGw0*VCg5SCcDeRuBAutiwkLeRRwOo*nMajduy5O*gIaus9qel9vX*lJbHJmyDMxuKFFI27tsT*I1S6pl*jzBb*IOTE_",
            "UserId": "trtc_partner_test_1"
        },
        "AudioParams": {
            "AudioEncode": {
                "SampleRate": 48000,
                "Codec": 0,
                "BitRate": 64,
                "Channel": 2
            }
        },
        "VideoParams": {
            "VideoEncode": {
                "Height": 720,
                "Width": 1280,
                "Fps": 15,
                "BitRate": 1536,
                "Gop": 2
            },
            "LayoutParams": {
                "PureAudioHoldPlaceMode": 0,
                "MixLayoutMode": 4,
                "MixLayoutList": [
                    {
                        "LocationX": 0,
                        "LocationY": 0,
                        "UserMediaStream": {
                            "StreamType": 0,
                            "UserInfo": {
                                "RoomIdType": 0,
                                "RoomId": "295066",
                                "UserId": "Trtc_User_0"
                            }
                        },
                        "ZOrder": 0,
                        "ImageHeight": 720,
                        "ImageWidth": 640,
                        "RenderMode": 0
                    },
                    {
                        "LocationX": 640,
                        "LocationY": 0,
                        "UserMediaStream": {
                            "StreamType": 0,
                            "UserInfo": {
                                "RoomIdType": 0,
                                "RoomId": "295066",
                                "UserId": "Trtc_User_1"
                            }
                        },
                        "ZOrder": 0,
                        "ImageHeight": 720,
                        "ImageWidth": 640,
                        "RenderMode": 0
                    }
                ]
            },
            "BackGroundColor": "0xFF0000",
            "WaterMarkList": [
                {
                    "WaterMarkType": 0,
                    "WaterMarkImage": {
                        "LocationX": 64,
                        "LocationY": 64,
                        "WaterMarkHeight": 64,
                        "WaterMarkWidth": 64,
                        "WaterMarkUrl": "https://xkt-course-1304449343.cos.ap-beijing.myqcloud.com/test/mark/37f9eb62-ca72-430e-bfca-e700b59b20e0.png",
                        "ZOrder": 3
                    }
                }
            ]
        },
        "PublishCdnParams": [
            {
                "PublishCdnUrl": "rtmp://3891.livepush.myqcloud.com/live/trtc_publishcdn_test1",
                "IsTencentCdn": 1
            }
        ],
        "RoomIdType": 0,
        "SdkAppId": 1400188366,
        "WithTranscoding": 1,
        "RoomId": "295066"
    }
    

    Output Example

    {
        "Response": {
            "TaskId": "-m97l2ZU7vxyBSmXYsRx1Xy9Kf4bVVfbbhSKC4K-4pycoZWKv542xbi139uTvGt1zAHoAQ..",
            "RequestId": "b934c535-8d82-4f52-bd52-a1cbb043c4be"
        }
    }
    

    Example2 Starting a task to mix audio streams and relay the mixed stream

    Input Example

    POST / HTTP/1.1
    Host: trtc.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: StartPublishCdnStream
    <Common request parameters>
    
    {
        "AgentParams": {
            "MaxIdleTime": 30,
            "UserSig": "eJw1zV8LgjAUBfCvInsO2dStGfQSQUb2pFJvsnLJJZW1LekPffdc6X08v8O5b5Snmd9LjRYeCnyMZt4vgUp2Fi7wB6vtuVRC207q0kpjSzIVTXUVSkE11EiEMeE8ZGw0*VCg5SCcDeRuBAutiwkLeRRwOo*nMajduy5O*gIaus9qel9vX*lJbHJmyDMxuKFFI27tsT*I1S6pl*jzBb*IOTE_",
            "UserId": "trtc_partner_test_1"
        },
        "AudioParams": {
            "AudioEncode": {
                "SampleRate": 48000,
                "Codec": 0,
                "BitRate": 64,
                "Channel": 2
            },
            "SubscribeAudioList": [
                {
                    "UserInfo": {
                        "RoomIdType": 0,
                        "RoomId": "295066",
                        "UserId": "Trtc_User_0"
                    }
                },
                {
                    "UserInfo": {
                        "RoomIdType": 0,
                        "RoomId": "295066",
                        "UserId": "Trtc_User_1"
                    }
                }
            ]
        },
        "PublishCdnParams": [
            {
                "PublishCdnUrl": "rtmp://3891.livepush.myqcloud.com/live/trtc_publishcdn_test1",
                "IsTencentCdn": 1
            }
        ],
        "RoomIdType": 0,
        "SdkAppId": 1400188366,
        "WithTranscoding": 1,
        "RoomId": "295066"
    }
    

    Output Example

    {
        "Response": {
            "RequestId": "388014ec-a0b8-4b8f-86bc-1f467448f5f0",
            "TaskId": "-m9lnV5U7nj4rkLBWMXF9n8-EohONCXbalWuLYK-4pycoZWQndibcqSVnrlqKF5om7EIDVk4awE."
        }
    }
    

    Example3 Starting a task to relay the audio&video of a stream

    Input Example

    POST / HTTP/1.1
    Host: trtc.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: StartPublishCdnStream
    <Common request parameters>
    
    {
        "AgentParams": {
            "MaxIdleTime": 30,
            "UserSig": "eJw1zV8LgjAUBfCvInsO2dStGfQSQUb2pFJvsnLJJZW1LekPffdc6X08v8O5b5Snmd9LjRYeCnyMZt4vgUp2Fi7wB6vtuVRC207q0kpjSzIVTXUVSkE11EiEMeE8ZGw0*VCg5SCcDeRuBAutiwkLeRRwOo*nMajduy5O*gIaus9qel9vX*lJbHJmyDMxuKFFI27tsT*I1S6pl*jzBb*IOTE_",
            "UserId": "trtc_partner_test_1"
        },
        "AudioParams": {
            "AudioEncode": {
                "SampleRate": 48000,
                "Codec": 0,
                "BitRate": 64,
                "Channel": 2
            }
        },
        "VideoParams": {
            "VideoEncode": {
                "Height": 720,
                "Width": 1280,
                "Fps": 15,
                "BitRate": 1536,
                "Gop": 2
            }
        },
        "SingleSubscribeParams": {
            "UserMediaStream": {
                "StreamType": 0,
                "UserInfo": {
                    "RoomIdType": 0,
                    "RoomId": "295066",
                    "UserId": "Trtc_User_0"
                }
            }
        },
        "PublishCdnParams": [
            {
                "PublishCdnUrl": "rtmp://3891.livepush.myqcloud.com/live/trtc_publishcdn_test1",
                "IsTencentCdn": 1
            }
        ],
        "RoomIdType": 0,
        "SdkAppId": 1400188366,
        "WithTranscoding": 0,
        "RoomId": "295066"
    }
    

    Output Example

    {
        "Response": {
            "TaskId": "-m97l2ZU7tq6nEsHR89259B8aCDblqnbGhWKC4K-4pycoZWpyHnld1jC9aCD+EU7V8WRAQ..",
            "RequestId": "f23d95bf-ddaf-4d0c-86c0-6bf50c74c0a0"
        }
    }
    

    Example4 Starting a task to relay only the audio of a stream

    Input Example

    POST / HTTP/1.1
    Host: trtc.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: StartPublishCdnStream
    <Common request parameters>
    
    {
        "AgentParams": {
            "MaxIdleTime": 30,
            "UserSig": "eJw1zV8LgjAUBfCvInsO2dStGfQSQUb2pFJvsnLJJZW1LekPffdc6X08v8O5b5Snmd9LjRYeCnyMZt4vgUp2Fi7wB6vtuVRC207q0kpjSzIVTXUVSkE11EiEMeE8ZGw0*VCg5SCcDeRuBAutiwkLeRRwOo*nMajduy5O*gIaus9qel9vX*lJbHJmyDMxuKFFI27tsT*I1S6pl*jzBb*IOTE_",
            "UserId": "trtc_partner_test_1"
        },
        "AudioParams": {
            "AudioEncode": {
                "SampleRate": 48000,
                "Codec": 0,
                "BitRate": 64,
                "Channel": 2
            }
        },
        "SingleSubscribeParams": {
            "UserMediaStream": {
                "StreamType": 0,
                "UserInfo": {
                    "RoomIdType": 0,
                    "RoomId": "295066",
                    "UserId": "Trtc_User_0"
                }
            }
        },
        "PublishCdnParams": [
            {
                "PublishCdnUrl": "rtmp://3891.livepush.myqcloud.com/live/trtc_publishcdn_test1",
                "IsTencentCdn": 1
            }
        ],
        "RoomIdType": 0,
        "SdkAppId": 1400188366,
        "WithTranscoding": 0,
        "RoomId": "295066"
    }
    

    Output Example

    {
        "Response": {
            "TaskId": "-m97l2ZU7r57nZBesMa84KgzxhH0OBbbCRaKC4K-4pycoZW7yFPtusNuZOen1Ca0qtQQAQ..",
            "RequestId": "ef089f8b-d0d1-4131-894d-4edd68d61605"
        }
    }
    

    Example5 Starting a task to mix audio&video streams and feedback to trtc room

    Input Example

    POST / HTTP/1.1
    Host: trtc.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: StartPublishCdnStream
    <Common request parameters>
    
    {
        "AgentParams": {
            "MaxIdleTime": 30,
            "UserSig": "eJw1zV8LgjAUBfCvInsO2dStGfQSQUb2pFJvsnLJJZW1LekPffdc6X08v8O5b5Snmd9LjRYeCnyMZt4vgUp2Fi7wB6vtuVRC207q0kpjSzIVTXUVSkE11EiEMeE8ZGw0*VCg5SCcDeRuBAutiwkLeRRwOo*nMajduy5O*gIaus9qel9vX*lJbHJmyDMxuKFFI27tsT*I1S6pl*jzBb*IOTE_",
            "UserId": "trtc_partner_test_1"
        },
        "AudioParams": {
            "AudioEncode": {
                "SampleRate": 48000,
                "Codec": 0,
                "BitRate": 64,
                "Channel": 2
            }
        },
        "VideoParams": {
            "VideoEncode": {
                "Height": 720,
                "Width": 1280,
                "Fps": 15,
                "BitRate": 1536,
                "Gop": 2
            },
            "LayoutParams": {
                "PureAudioHoldPlaceMode": 0,
                "MixLayoutMode": 4,
                "MixLayoutList": [
                    {
                        "LocationX": 0,
                        "LocationY": 0,
                        "UserMediaStream": {
                            "StreamType": 0,
                            "UserInfo": {
                                "RoomIdType": 0,
                                "RoomId": "295066",
                                "UserId": "Trtc_User_0"
                            }
                        },
                        "ZOrder": 0,
                        "ImageHeight": 720,
                        "ImageWidth": 640,
                        "RenderMode": 0
                    },
                    {
                        "LocationX": 640,
                        "LocationY": 0,
                        "UserMediaStream": {
                            "StreamType": 0,
                            "UserInfo": {
                                "RoomIdType": 0,
                                "RoomId": "295066",
                                "UserId": "Trtc_User_1"
                            }
                        },
                        "ZOrder": 0,
                        "ImageHeight": 720,
                        "ImageWidth": 640,
                        "RenderMode": 0
                    }
                ]
            },
            "BackGroundColor": "0xFF0000",
            "WaterMarkList": [
                {
                    "WaterMarkType": 0,
                    "WaterMarkImage": {
                        "LocationX": 64,
                        "LocationY": 64,
                        "WaterMarkHeight": 64,
                        "WaterMarkWidth": 64,
                        "WaterMarkUrl": "https://xkt-course-1304449343.cos.ap-beijing.myqcloud.com/test/mark/37f9eb62-ca72-430e-bfca-e700b59b20e0.png",
                        "ZOrder": 3
                    }
                }
            ]
        },
        "FeedBackRoomParams": [
            {
                "RoomId": "630777",
                "RoomIdType": 0,
                "UserId": "trtc_partner_test_2",
                "UserSig": "eJwtjEELgjAYhv-Ldy10m7mtQYcQOtklU6mLSFs1LVnzq4Tovwfa8Xmel-cD*zQLXsaDAhYQmI9stenQnu2o0eOpcrXHzvgKTY8V*8963dbOWQ2KLgihUkacTwXt3YCigpIlo0KyyZrBWW9ARZyQ-4O9gIJrYfK365M85PEw02HZPneNaJJbg4-1Nj6KQqZZacVhI1fw-QEkCzYe"
            }
        ],
        "RoomIdType": 0,
        "SdkAppId": 1400188366,
        "WithTranscoding": 1,
        "RoomId": "295066"
    }
    

    Output Example

    {
        "Response": {
            "RequestId": "921e9cf6-b77c-4a7a-ab0e-c66a3e66fc59",
            "TaskId": "-m9lnV5U7n7TwoLKSsii1JivUn7DLDDbP16uLYK-4pycoZWQndib8GQJZEMMXFyOHe9Ds6WfxAE."
        }
    }
    

    Example6 Starting a task to mix audio&video streams and relay the mixed stream with layout SEI

    Input Example

    POST / HTTP/1.1
    Host: trtc.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: StartPublishCdnStream
    <Common request parameters>
    
    {
        "AgentParams": {
            "MaxIdleTime": 30,
            "UserSig": "eJw1zV8LgjAUBfCvInsO2dStGfQSQUb2pFJvsnLJJZW1LekPffdc6X08v8O5b5Snmd9LjRYeCnyMZt4vgUp2Fi7wB6vtuVRC207q0kpjSzIVTXUVSkE11EiEMeE8ZGw0*VCg5SCcDeRuBAutiwkLeRRwOo*nMajduy5O*gIaus9qel9vX*lJbHJmyDMxuKFFI27tsT*I1S6pl*jzBb*IOTE_",
            "UserId": "trtc_partner_test_1"
        },
        "AudioParams": {
            "AudioEncode": {
                "SampleRate": 48000,
                "Codec": 0,
                "BitRate": 64,
                "Channel": 2
            }
        },
        "VideoParams": {
            "VideoEncode": {
                "Height": 720,
                "Width": 1280,
                "Fps": 15,
                "BitRate": 1536,
                "Gop": 2
            },
            "LayoutParams": {
                "PureAudioHoldPlaceMode": 0,
                "MixLayoutMode": 4,
                "MixLayoutList": [
                    {
                        "LocationX": 0,
                        "LocationY": 0,
                        "UserMediaStream": {
                            "StreamType": 0,
                            "UserInfo": {
                                "RoomIdType": 0,
                                "RoomId": "295066",
                                "UserId": "Trtc_User_0"
                            }
                        },
                        "ZOrder": 0,
                        "ImageHeight": 720,
                        "ImageWidth": 640,
                        "RenderMode": 0
                    },
                    {
                        "LocationX": 640,
                        "LocationY": 0,
                        "UserMediaStream": {
                            "StreamType": 0,
                            "UserInfo": {
                                "RoomIdType": 0,
                                "RoomId": "295066",
                                "UserId": "Trtc_User_1"
                            }
                        },
                        "ZOrder": 0,
                        "ImageHeight": 720,
                        "ImageWidth": 640,
                        "RenderMode": 0
                    }
                ]
            },
            "BackGroundColor": "0xFF0000",
            "WaterMarkList": [
                {
                    "WaterMarkType": 0,
                    "WaterMarkImage": {
                        "LocationX": 64,
                        "LocationY": 64,
                        "WaterMarkHeight": 64,
                        "WaterMarkWidth": 64,
                        "WaterMarkUrl": "https://xkt-course-1304449343.cos.ap-beijing.myqcloud.com/test/mark/37f9eb62-ca72-430e-bfca-e700b59b20e0.png",
                        "ZOrder": 3
                    }
                }
            ]
        },
        "SeiParams": {
            "LayoutVolume": {
                "AppData": "layout_sei_test",
                "PayloadType": 100,
                "Interval": 1000,
                "FollowIdr": 1
            }
        },
        "PublishCdnParams": [
            {
                "PublishCdnUrl": "rtmp://3891.livepush.myqcloud.com/live/trtc_publishcdn_test1",
                "IsTencentCdn": 1
            }
        ],
        "RoomIdType": 0,
        "SdkAppId": 1400188366,
        "WithTranscoding": 1,
        "RoomId": "295066"
    }
    

    Output Example

    {
        "Response": {
            "RequestId": "6dfc18cc-2123-4a11-9591-f1e873fbbd65",
            "TaskId": "-m9lnV5U7nzo2Xwh48Dc-YCDrR5Bk8DbJ1WrLYK-4pycoZWQndibrNig9cq-7ljX4SenbKWlZAE."
        }
    }
    

    5. Developer Resources

    SDK

    TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

    Command Line Interface

    6. Error Code

    The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

    Error Code Description
    AuthFailure CAM signature/authentication error.
    AuthFailure.UnRealNameAuthenticated Identity verification has not been completed, so this operation is not allowed.
    AuthFailure.UnauthorizedOperation CAM authentication failed.
    AuthFailure.UnsupportedOperation Unsupported operation.
    FailedOperation Operation failed.
    FailedOperation.RestrictedConcurrency Maximum number of concurrent on-cloud recording tasks reached. Contact us to raise the limit.
    InternalError Internal error.
    InvalidParameter Parameter error.
    InvalidParameter.SdkAppId SdkAppId is incorrect.
    MissingParameter Missing parameter.
    ResourceNotFound The resource does not exist.
    UnsupportedOperation Unsupported operation.