You need to enable JavaScript to run this app.
导航

回调内容说明

最近更新时间2024.01.25 15:39:35

首次发布时间2022.02.09 17:21:01

当直播域名配置完成回调功能后,关联事件触发时将以主动发送请求到业务服务器的方式,将含直播事件回调信息的 JSON 数据包发送给业务服务器。

网络协议

  • 请求:通过 HTTP 接口向业务服务器发送 POST 请求,包体内容格式为 JSON,每一种消息的包体内容详情请参见回调内容
  • 应答:通过 HTTP 接口的状态码 200 接收接口返回结果,火山引擎服务端会忽略应答包内的具体内容。

请求可靠性

事件通知请求具备重试能力,请求失败后会立即进行 3 次间隔时间为 3 秒的重试;如 3 次重试还未请求成功,则将请求任务加入重试队列再次进行重试;从首次请求算起超过 10 分钟后仍未请求成功则不再重试。以下情况可视为请求失败。

  • 请求超时(4s)未收到应答包;
  • 应答状态码不为 200。

回调内容

公共安全签名参数

字段类型说明

sign

String

事件通知请求安全签名 sign=MD5 ( AuthKeyPrimary + t ) 。

说明

火山引擎将回调密钥 AuthKeyPrimary 和过期时间 t 进行字符串拼接后通过 MD5 计算得出 sign 值,并将其放在通知消息里,业务服务器在收到事件通知请求后可以根据同样的算法确认 sign 是否正确,进而确认事件通知请求是否确实来自火山引擎。

t

Int64

过期时间,事件通知请求签名过期 UNIX 时间戳。

说明

来自火山引擎的事件通知请求默认过期时间是 10 分钟,如果一条事件请求通知中的 t 值所指定的时间已经过期,则可以判定此条事件请求通知无效,通过此方法可以防止网络重放攻击。

推流开始回调消息

字段类型说明
vhostString域名空间
domainString推流地址
appStringAppName,App 名称
streamStringStreamName,流名称
event_typeString事件名,push_start 表示开始推流
timeInt开始推流时间,单位为 s
time_msInt开始推流时间,单位为 ms

transcoded

Boolean

是否为转码流。

  • true:转码流;
  • false:非转码流。
fp_node_ipString推流节点 IP
fp_client_ipString推流客户端 IP
session_idString本次推流的会话 ID

回调示例如下所示。

{
    "code":0,
    "message":"ok",
    "data":{
        "vhost":"push-rtmp.example.com",
        "domain":"push-rtmp.example.com",
        "app":"live",
        "stream":"stream-123456",
        "event_type":"push_start",
        "detail":{
            "time":1640849510,
            "time_ms":1640849510029,
            "transcoded":false,
            "fp_node_ip":"150.139.1.1",
            "fp_client_ip":"114.100.2.2",
            "session_id":"3693930911_150.139.1.1"
        }
    }
}

推流结束回调消息

字段类型说明
vhostString域名空间
domainString推流地址
appStringAppName,App 名称
streamStringStreamName,流名称
event_typeString事件名,push_end 表示推流结束
errmsgString断流错误原因描述
timeInt结束推流时间,单位为 s
time_msInt结束推流时间,单位为毫秒

transcoded

Boolean

是否为转码流。

  • true:转码流;
  • false:非转码流。
fp_node_ipString推流节点 IP
fp_client_ipString推流客户端 IP
session_idString本次推流的会话 ID

回调示例如下所示。

{
    "code":0,
    "message":"ok",
    "data":{
        "vhost":"push-rtmp.example.com",
        "domain":"push-rtmp.example.com",
        "app":"live",
        "stream":"stream-123456",
        "event_type":"push_end",
        "detail":{
            "time":1640849502,
            "time_ms":1640849502762,
            "transcoded":false,
		        "errmsg":"func:OnStop:eof",
            "fp_node_ip":"106.225.1.1",
            "fp_client_ip":"113.77.2.2",
            "session_id":"2491536431_106.225.1.1"
        }
    }
}

录制回调消息

字段类型说明
vhostString域名空间
domainString推流地址
appStringAppName,App 名称
streamStringStreamName,流名称
event_typeString事件名,record_event 表示录制事件
tos_bucketString保存在对象存储中的 bucket 名称
tos_objectString保存在对象存储中的文件路径
uriString录制保存在点播时,该录制视频在点播中的 Vid
durationInt录制长度,单位毫秒
start_timeInt录制开始时间,Unix 时间,单位为 s
stop_timeInt录制结束时间,Unix 时间

format

String

录制格式。支持的取值如下所示。

  • mp4;
  • m3u8;
  • flv。

url

String

文件地址

说明

如果录制文件存储在 VoD 中,url的返回结果为空,需使用 uri 或者 vod_filename 从点播中获取播放地址。

vod_filenameString录制至点播时的文件路径
account_idSting账号 ID
sizeIntm3u8 文件大小,单位字节

回调示例如下所示。

  • 录制存储在 VoD
{
    "code":0,
    "message":"ok",
    "data":{
        "vhost":"pushrtmp.example.com",
        "domain":"pushrtmp.example.com",
        "app":"live",
        "stream":"stream_123456",
        "event_type":"record_event",
        "detail":{
            "tos_bucket":"",
            "tos_object":"record/pushrtmp.example.com/live/stream_123456_1640847072_1640849947_record.m3u8",
            "uri":"v0df17g10000ca6ut9pka0prk****pig",
            "duration":2868674,
            "start_time":1640847072,
            "stop_time":1640849947,
            "format":"m3u8",
            "url":"",
            "vod_filename":"record/{PubDomain}/{App}/{Stream}/{StartTime}_{EndTime}",
            "account_id":"10000**",
            "size":28361
        }
    }
}
  • 录制存储在 ToS
{
    "code": 0,
    "message": "ok",
    "data": {
        "vhost": "push.example.com",
        "domain": "push.example.com",
        "app": "live",
        "stream": "stream_12345",
        "event_type": "record_event",
        "detail": {
            "tos_bucket": "livetest",
            "tos_object": "record/record/push.example.com/live/stream_123456/1653469134_1653469220.m3u8",
            "uri": "",
            "duration": 84430,
            "start_time": 1653469134,
            "stop_time": 1653469220,
            "format": "m3u8",
            "url": "http://livetest.tos.volces.com/record/record/push.example.com/live/stream_12345/1653469134_1653469220.m3u8",
            "account_id": "2000001174",
            "size": 689
        }
    }
}

截图回调消息

字段类型说明
VhostString域名空间
DomainString推流地址
AppStringAppName,App 名称
StreamStringStreamName,流名称
BucketString保存在对象存储中的 bucket 名称
ObjectKeyString存储的文件路径
HeightInt图片高度,单位像素
WidthInt图片宽度,单位像素
FormatString录制格式
TimeStampInt截图时间,Unix 时间
AccountIdSting账号 ID
ImageXURIString截图存储在 ImageX 时,veImageX 为图片分配的资源 URI
ServiceIDString截图存储在 veImageX 时,veImageX 的服务 ID
event_typeString事件名,snapshot_event 表示截图事件

回调示例如下所示。

  • 截图存储在 veImageX
{
    "Vhost": "push.example.com",
    "Domain": "push.example.com",
    "App": "live",
    "Stream": "stream_1234",
    "Bucket": "bucket1",
    "ObjectKey": "push.example.com/live/stream_1234/2022052510115****.jpg",
    "Height": 1080,
    "Width": 1920,
    "Format": "jpg",
    "TimeStamp": 1653473517,
    "AccountId": "2000001174",
    "ImageXURI": "tos-cn-i-exampleid/2022052510115****.jpg",
    "ServiceID": "exampleid"
}
  • 截图存储在 ToS
{
    "Vhost":"pushrtmp.example.com.",
    "Domain":"pushrtmp.example.com",
    "App":"live",
    "Stream":"stream_1234",
    "Bucket":"bucket1",
    "ObjectKey":"pushp.example.com/live/20211****.jpeg",
    "Height":864,
    "Width":480,
    "Format":"jpeg",
    "TimeStamp":1640849845,
    "AccountId":"10000"
}

拉流转推回调消息

字段类型说明

action

String

事件。

  • init:任务开始;
  • done:任务结束;
  • live_start:直播开始;
  • vod_start:点播开始;
  • stop:断流。
event_timeInt事件的时间,Unix 时间戳,单位为 ns,例如,1650263223542095385
task_idString创建的任务 ID
srcString视频来源的流地址
dstString推流地址

type

Int

类型。

  • 0:表示直播;
  • 1:表示点播。

cycle_mode

Int

点播文件的循环方式。
当 Type=1 时,CycleMode 取值为 -1,表示按照列表顺序循环。

event_typeString事件名,live_pull_to_push 表示拉流转推事件
{
    "action":"vod_start",
    "event_time":1650263223542095385,
    "task_id":"5f4c37605b7d711b51e28d73fa60****",
    "src":"http://test.com/test/test.m3u8",
    "dst":"rtmp://testpush/test/teststream",
    "type":1,
    "cycle_mode":-1
}

审核结果回调消息

字段类型说明
vhostString域名空间名称
DomainString推流域名
AppString应用名称
StreamString流名称
EventTypeString事件类型,默认为 scan_screenshoot_event,表示审核截图事件
EventDataEventData事件详情
EventTimeString事件产生时间,RFC3339 格式的 UTC 时间。单位为 s
EventIdstring事件 ID,用于事件去重

EventData

参数名类型描述
MediaTypeInt可能违规的内容类型。截图审核的默认取值为 1,表示直播截图。
ImageString审核截图保存的 uri,根据您配置的审核规则,返回截图在 TOS、veImageX 中的存储路径

HitLabels

Array of String

截图的违规原因。支持以下取值。

  • 301:涉黄;
  • 302:涉敏1;
  • 303:涉敏2;
  • 304:广告;
  • 305:引人不适;
  • 306:违禁;
  • 307:二维码;
  • 308:诈骗;
  • 309:不良画面;
  • 310:未成年相关;
  • 320:文字违规。
RiskHitArray of Risk命中的违规列表
RiskALLArray of Risk已配置的所有模型列表

Decision

String

根据违规命中情况,给出的操作建议。支持的取值与含义如下所示。

  • PASS:审核通过;
  • REVIEW:需要人工复审;
  • BLOCK:不通过,建议召回。
AIResultOriginString审核平台返回的响应原数据。

Risk

参数名类型描述

Label

String

截图命中的违规类型标签。支持以下取值。

  • 301:涉黄;
  • 302:涉敏1;
  • 303:涉敏2;
  • 304:广告;
  • 305:引人不适;
  • 306:违禁;
  • 307:二维码;
  • 308:诈骗;
  • 309:不良画面;
  • 310:未成年相关;
  • 320:文字违规。
SublabelString截图命中的违规子类型标签。

Decision

String

根据违规命中情况,给出的操作建议。支持的取值与含义如下所示。

  • PASS:审核通过;
  • REVIEW:需要人工复审;
  • BLOCK:不通过,建议召回。
{
    "Vhost": "example.com",
    "Domain": "example.com",
    "App": "live",
    "Stream": "stream1",
    "EventType": "scan_screenshoot_event",
    "EventData": {
        "MediaType": 1,
        "Image": "/liveexample/tob****01/stream**/1659079720209.jpg",
        "HitLabels": [
            "301"
        ],
        "RiskHit": [
            {
                "Label": "301",
                "SubLabel": "301001",
                "Decision": "BLOCK"
            },
            {
                "Label": "301",
                "SubLabel": "301002",
                "Decision": "BLOCK"
            }
        ],
        "RiskALL": [
            {
                "Label": "301",
                "SubLabel": "301001",
                "Decision": "BLOCK"
            },
            {
                "Label": "301",
                "SubLabel": "301002",
                "Decision": "BLOCK"
            }
        ],
        "Decision": "BLOCK",
        "AIResultOrigin": "{\"RequestId\":\"202207291528410102091561590F291DAA\",\"Code\":0,\"Message\":\"success\",\"Data\":{\"DataId\":\"7125691570795811116\",\"Decision\":\"BLOCK\",\"Results\":[{\"Label\":\"301\",\"SubLabel\":\"301001\",\"Decision\":\"BLOCK\",\"score\":0,\"Detail\":null,\"Frames\":null},{\"Label\":\"301\",\"SubLabel\":\"301002\",\"Decision\":\"BLOCK\",\"score\":0,\"Detail\":null,\"Frames\":null}],\"Scores\":null}}"
    },
    "EventTime": "2022-07-29T15:28:40+08:00",
    "EventId": "71256915707958766**",
    "CallbackURL": [
        "http://example.com/callback/scan_screenshoot"
    ]
}

附录

断流错误原因

errmsg说明
func:OnStatus:func:RtmpStatusCode2NssError:duplicate重复推流
param:nssSession:duplicate重复推流
func:OnStatus:func:RtmpStatusCode2NssError:not_allowed推流被禁
func:conn.Read:eof推流断开连接
func:conn.Read:net:timeout读数据超时
func:conn.Read:net:broken_pipe推流断开连接
func:OnStop:eof推流结束
func:conn.Read:net:peer_going_away推流断开连接
func:OnStatus:func:rtmpStatusCode2NssError:api_closeAPI 关闭流
func:conn.Read:net:deadline_exceeded读数据超时
func:Validate:param:Name:invalid流名不合法
func:conn.Read:net:conn_reset_by_peer推流断开连接
func:timeout:idle_too_long长时间没收到数据
func::done未知原因
func:HandleInputPacket:net:func:Input: rtmp:invalid_rtmp_typertmp 协议解析失败
func:HandleInputPacket:net:func:Input: rtmp: FLV Signature don't matchflv 协议解析失败
func:JudgePublishAuth:param:MissParam:invalid_sign推流鉴权参数不存在
func:JudgePublishAuth:access:disableDomain 不合法
param:uniqueSinkMap:duplicate重复推流
func:Validate:param:App:invalidApp 不合法
param:group.Type:cancel转推失败
stream:idle_too_long长时间没收到数据
func:HandleInputPacket:net:func:Input: rtmp:invalid_chunk_sizertmp 协议解析失败