启动转推任务

最近更新时间:2024-10-28 02:18:26

我的收藏

1. 接口描述

接口请求域名: trtc.tencentcloudapi.com 。

接口说明:
启动一个混流转推任务,将 TRTC 房间的多路音视频流混成一路音视频流,编码后推到直播 CDN 或者回推到 TRTC 房间。也支持不转码直接转推 TRTC 房间的单路流。启动成功后,会返回一个 SdkAppid 维度唯一的任务 Id(TaskId)。您需要保存该 TaskId,后续需要依赖此 TaskId 更新和结束任务。可以参考文档: 功能说明常见问题

注意:
您可以在控制台开通旁路转推回调功能,对转推 CDN 状态的事件进行监控,回调请参考文档:旁路转推回调说明
您发起混流转推任务时,可能会产生如下费用:
MCU 混流转码费用,请参考文档:云端混流转码计费说明
转推非腾讯云 CDN 费用,请参考文档:云端转推计费说明

默认接口请求频率限制:20次/秒。

推荐使用 API Explorer
点击调试
API Explorer 提供了在线调用、签名验证、SDK 代码生成和快速检索接口等能力。您可查看每次调用的请求内容和返回结果以及自动生成 SDK 调用示例。

2. 输入参数

以下请求参数列表仅列出了接口请求参数和部分公共参数,完整公共参数列表见 公共请求参数

参数名称 必选 类型 描述
Action String 公共参数,本接口取值:StartPublishCdnStream。
Version String 公共参数,本接口取值:2019-07-22。
Region String 公共参数,详见产品支持的 地域列表,本接口仅支持其中的: ap-beijing, ap-guangzhou, ap-hongkong, ap-shanghai 。
SdkAppId Integer TRTC的SdkAppId,和转推的房间所对应的SdkAppId相同。
示例值:1400188366
RoomId String 主房间信息RoomId,转推的TRTC房间所对应的RoomId。
示例值:room_1234
RoomIdType Integer 主房间信息RoomType,必须和转推的房间所对应的RoomId类型相同,0为整型房间号,1为字符串房间号。
示例值:1
AgentParams AgentParams 转推服务加入TRTC房间的机器人参数。
示例值:AgentParams
WithTranscoding Integer 是否转码,0表示无需转码,1表示需要转码。是否收取转码费是由WithTranscoding参数决定的,WithTranscoding为0,表示旁路转推,不会收取转码费用,WithTranscoding为1,表示混流转推,会收取转码费用。
示例值:1
AudioParams McuAudioParams 转推流的音频编码参数。由于音频是必转码的(不会收取转码费用),所以启动任务的时候,必须填写。
示例值:AudioParams
VideoParams McuVideoParams 转推流的视频编码参数,不填表示纯音频转推。
示例值:VideoParams
SingleSubscribeParams SingleSubscribeParams 需要单流旁路转推的用户上行参数,单流旁路转推时,WithTranscoding需要设置为0。
示例值:SingleSubscribeParams
PublishCdnParams.N Array of McuPublishCdnParam 转推的CDN参数,一个任务最多支持10个推流URL。和回推房间参数必须要有一个。
示例值:PublishCdnParams
SeiParams McuSeiParams 混流SEI参数
示例值:SeiParams
FeedBackRoomParams.N Array of McuFeedBackRoomParams 回推房间信息,一个任务最多支持回推10个房间,和转推CDN参数必须要有一个。注:回推房间需使用10.4及以上SDK版本,如您有需求,请联系腾讯云技术支持。
示例值:FeedBackRoomParams
RecordParams McuRecordParams 转推录制参数,参考文档
示例值:RecordParams

3. 输出参数

参数名称 类型 描述
TaskId String 用于唯一标识转推任务,由腾讯云服务端生成,后续更新和停止请求都需要携带TaskiD参数。
示例值:""
RequestId String 唯一请求 ID,由服务端生成,每次请求都会返回(若请求因其他原因未能抵达服务端,则该次请求不会获得 RequestId)。定位问题时需要提供该次请求的 RequestId。

4. 示例

示例1 发起音视频混流转推 CDN

输入示例

POST / HTTP/1.1
Host: trtc.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: StartPublishCdnStream
<公共请求参数>

{
    "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"
}

输出示例

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

示例2 发起纯音频混流转推 CDN

输入示例

POST / HTTP/1.1
Host: trtc.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: StartPublishCdnStream
<公共请求参数>

{
    "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"
}

输出示例

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

示例3 发起单流音视频旁路转推 CDN

输入示例

POST / HTTP/1.1
Host: trtc.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: StartPublishCdnStream
<公共请求参数>

{
    "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"
}

输出示例

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

示例4 发起单流纯音频旁路转推 CDN

输入示例

POST / HTTP/1.1
Host: trtc.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: StartPublishCdnStream
<公共请求参数>

{
    "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"
}

输出示例

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

示例5 发起音视频混流回推 TRTC 房间

输入示例

POST / HTTP/1.1
Host: trtc.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: StartPublishCdnStream
<公共请求参数>

{
    "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"
}

输出示例

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

示例6 发起音视频混流转推 CDN ,输出数据带布局 SEI

输入示例

POST / HTTP/1.1
Host: trtc.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: StartPublishCdnStream
<公共请求参数>

{
    "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"
}

输出示例

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

5. 开发者资源

腾讯云 API 平台

腾讯云 API 平台 是综合 API 文档、错误码、API Explorer 及 SDK 等资源的统一查询平台,方便您从同一入口查询及使用腾讯云提供的所有 API 服务。

API Inspector

用户可通过 API Inspector 查看控制台每一步操作关联的 API 调用情况,并自动生成各语言版本的 API 代码,也可前往 API Explorer 进行在线调试。

SDK

云 API 3.0 提供了配套的开发工具集(SDK),支持多种编程语言,能更方便的调用 API。

命令行工具

6. 错误码

以下仅列出了接口业务逻辑相关的错误码,其他错误码详见 公共错误码

错误码 描述
AuthFailure CAM签名/鉴权错误。
AuthFailure.UnRealNameAuthenticated 未完成实名认证,不允许此操作。
AuthFailure.UnauthorizedOperation CAM鉴权失败。
AuthFailure.UnsupportedOperation 不支持该操作。
FailedOperation 操作失败。
FailedOperation.RestrictedConcurrency 单用户并发过载,请联系我们增大并发路数到合理值。
InternalError 内部错误。
InvalidParameter 参数错误。
InvalidParameter.SdkAppId SdkAppId参数错误。
MissingParameter 缺少参数错误。
ResourceNotFound 资源不存在。
UnsupportedOperation 操作不支持。