一、注意事项
1. 阅读这篇之前,希望你已经了解腾讯云直播是如何配置回调功能、你是如何接收回调消息的,具体请参见 如何接收事件通知。
2. 任务未到结束时间前,因源或者目标地址不可用进行持续重试,或者机器异常进行任务自动迁移,均会产生任务结束回调,不可将该回调作为任务最终结束回调使用。
3. 如需要判断任务是否正常推流中,可从接收流地方进行判断,如云直播的断流回调,或流状态查询接口等方式。
二、事件类型参数
| 事件类型 | 字段取值说明 |
| 拉流转推 | event_type = 314 |
三、拉流转推回调消息参数
| 参数 | 类型 | 含义 |
| appid | int | 用户 APPID |
| callback_event | string | 回调事件类型 |
| source_urls | string | 拉流源 URL |
| to_url | string | 推流目标 URL |
| stream_id | string | 直播流名称 |
| task_id | string | 任务 ID |
| msg | string | 不同事件,详细回调信息 |
| event_time | string | 事件发生时间戳,示例:"1712893433" |
四、msg 内参数说明
| 参数 | 类型 | 含义 |
| task_start_time | int | 任务开始时间,毫秒时间戳 |
| url | string | 当前正拉取的源 URL |
| index | Int | 点播文件所在列表索引 |
| duration | int | 点播文件时长,秒 |
| task_exit_time | int | 任务退出时间,毫秒时间戳 |
| code | Int | 任务退出错误码 |
| message | string | 任务退出错误信息 |
| type | string | 告警回调(callback_event:TaskAlarm)使用, 告警类型有: PullFileUnstable:文件拉取不稳定PushStreamUnstable:推流不稳定PullFileFailed:文件拉取出错PushStreamFailed:推流出现失败FileEndEarly:文件提前结束 |
五、回调消息示例
TaskStart – 任务开始回调VodSourceFileStart – 点播文件开始时回调VodSourceFileFinish – 点播文件结束时回调TaskExit – 任务退出回调TaskAlarm – 任务告警回调{ "appid": 4, "callback_event": "TaskStart", "event_type": 314, "interface": "general_callback", "msg": "{\\"task_start_time\\":0}", "product_name": "pullpush", "source_urls": "[\\"http://yourURL.cn/live/normal_230753472*****21162358-upload-45eb/playlist.m3u8\\"]\\n", "stream_id": "testvod", "task_id": "118148", "to_url": "rtmp://5000.livepush.myqcloud.com/live/testvod"}{ "appid": 4, "callback_event": "VodSourceFileStart", "callback_url": "http://you.callback.url", "event_type": 314, "interface": "general_callback", "msg": "{\\"url\\":\\"http://remit-tx-ugcpub.douyucdn2.cn/live/normal_466247620*****3100448-upload-216b/playlist.m3u8\\",\\"index\\":0,\\"duration\\":14920}", "product_name": "pullpush", "source_urls": "[\\"http://yourURL.cn/live/normal_466247620*****3100448-upload-216b/playlist.m3u8\\"]\\n", "stream_id": "testvod", "task_id": "118145", "to_url": "rtmp://5000.livepush.myqcloud.com/live/testvod"}{ "appid": 4, "callback_event": "VodSourceFileFinish", "callback_url": "http://you.callback.url", "event_type": 314, "interface": "general_callback", "msg": "{\\"url\\":\\"http://yourURL.cn/live/normal_466247620*****3100448-upload-216b/playlist.m3u8\\",\\"index\\":0,\\"duration\\":14920}", "product_name": "pullpush", "source_urls": "[\\"http://yourURL.cn/live/normal_466247620*****3100448-upload-216b/playlist.m3u8\\"]\\n", "stream_id": "testvod", "task_id": "118145", "to_url": "rtmp://5000.livepush.myqcloud.com/live/testvod"}{ "appid": 4, "callback_event": "TaskExit", "event_type": 314, "interface": "general_callback", "msg": "{\\"message\\":\\"write packet error.\\",\\"code\\":-22,\\"task_exit_time\\":0}", "product_name": "pullpush", "source_urls": "[\\"http://yourURL.cn/live/normal_230753472*****21162358-upload-4\\"]\\n"}{ "appid": 4, "callback_event": "TaskAlarm", "event_type": 314, "interface": "general_callback", "msg": "{\\"url\\": \\"http://5000.livepush.myqcloud.com/live/normal_2307534720200521162358-upload-45eb/playlist.m3u8\\",\\"message\\":\\"Pull file unstable.\\",\\"type\\":\\"PullFileUnstable\\",\\"offset\\":123,"Duation":3333}", "product_name": "pullpush", "task_id": "118148", "source_urls": "[\\"http://5000.livepush.myqcloud.com/live/normal_2307534720200521162358-upload-45eb/playlist.m3u8\\"]\\n", "stream_id": "", "to_url": "rtmp://5000.livepush.myqcloud.com/live/testdouyu"}