通知接口
更新时间:2025-02-08
通知功能可以在音视频转码任务状态转换时主动向开发者服务器推送消息。
创建通知
请求(Request)
- 请求语法:
Http
1POST /v{version}/notification HTTP/1.1
2accept-encoding: gzip, deflate
3x-bce-date: {utc-date-string}
4host: media.bj.baidubce.com
5accept: */*
6connection: keep-alive
7x-bce-request-id: {bce-request-id}
8content-type: application/json
9authorization: {bce-authorization-string}
- 请求头域:无特殊Header参数
- 请求参数(以下均为Requestbody参数):
字段名称 | 字段类型 | 必要性 | 字段描述 | 可选值 | 默认值 |
---|---|---|---|---|---|
name | String | 必选 | 通知名称。小写字母开头,其余部分由小写字母、下划线 (_) 或数字组成,最多不超过40个字符 | - | - |
endpoint | String | 必选 | 通知消息接收地址 | - | - |
type | String | 可选 | 通知消息类型。NONE表示普通通知回调;SIGN表示鉴权模式,会在header中增加Notification-Auth-Expire、Notification-Auth-User和Notification-Auth-Token用于验证。用户接收到回调后可以使用SHA256-HEX传入自己的token以及"POST;endpoint;content;expireTime;user"生成Notification-Auth-Token,与header中的对比进行验证 | NONE,SIGN | NONE |
token | String | 可选 | 通知消息鉴权token | - | - |
- 请求示例:
Http
1POST /v3/notification HTTP/1.1
2content-length: 87
3accept-encoding: gzip, deflate
4x-bce-date: 2015-07-03T09:28:13Z
5connection: keep-alive
6accept: */*
7user-agent: python-requests/2.4.0 CPython/2.7.9 Darwin/14.3.0
8host: media.bj.baidubce.com
9x-bce-request-id: 8776558c-81d9-4f97-8e2c-f977a286095d
10content-type: application/json
11authorization: bce-auth-v1/e8e4a9ced6794355a9a1b8a20b58d37b/2015-07-03T09:28:13Z/1800/content-type;host;x-bce-date/4a1692dc4bab84f5801f79ea0c1fece3601cf73ecd94409d2a94b3942b971715
12
13{
14 "name": "mct_notification",
15 "endpoint": "http://mct.notificaitonDomain.com/"
16}
响应(Reponse)
- 响应头域:无特殊Header参数
- 响应参数:无
- 响应示例:
Http
1HTTP/1.1 200 OK
2x-bce-request-id: 8776558c-81d9-4f97-8e2c-f977a286095d
3Date: Fri, 03 Jul 2015 09:28:13 GMT
4Transfer-Encoding: chunked
5Content-Type: application/json;charset=UTF-8
6Cache-Control: no-cache
接收通知回调
- 通知消息:
字段名称 | 字段类型 | 字段描述 |
---|---|---|
messageId | String | 通知Id |
messageBody | Object | 通知消息体 |
+ jobId | String | jobid |
+ pipelineName | String | 队列名 |
+ jobStatus | String | job状态(SUCCESS, FAILED) |
+ createTime | Date | job创建时间 |
+ startTime | Date | job开始时间 |
+ endTime | Date | job结束时间 |
+ error | Object | 错误信息 |
++ code | String | 错误码 |
++ message | String | 错误信息 |
+ source | Object | 输入的原始信息 |
++ sourceKey | String | 原始文件的BOS Key |
++ clips | Array | 待合并的原始视频信息 |
+++ bucket | String | 原始文件的BOS Bucket |
+++ sourceKey | String | 原始文件的BOS Key |
+++ asMasterClip | Boolean | 是否指定该片段作为主分片 |
+++ enableLogo | Boolean | 是否允许在该片段添加水印 |
+++ enableDelogo | Boolean | 是否允许在该片段进行去水印 |
+++ enableCrop | Boolean | 是否允许在该片段添进行去黑边 |
+++ startTimeInSecond | Number | 视频片段的起始时间 |
+++ durationInSecond | Number | 视频片段的持续时间 |
+++ startTimeInMillisecond | Number | 视频片段的起始时间(单位ms,与startTimeInSecond同时设置时,优先生效) |
+++ durationInMillisecond | Number | 视频片段的持续时间(单位ms,与durationInSecond同时设置时,优先生效) |
+ target | Object | 目前信息 |
++ targetKey | String | 目标文件的BOS key |
++ presetName | String | 输出处理的模板的presetName |
+ output | Object | 输出信息 |
++ Video | Object | 视频 |
+++ durationInSeconds | Number | 视频持续时间 |
+++ sizeInKiloByte | Double | |
+++ widthInPixel | Number | 宽 |
+++ heightInPixel | Number | 高 |
+++ frameRate | Number | 帧率 |
+++ mp4MoovSize | Number | |
++ Audio | Object | 音频 |
+++ sampleRateInHz | Number | 音频采样率 |
+++ channels | Number | 声道 |
+ secretKeyUserId | String | |
+ clusterName | String | 视频源信息 |
notification | String | 通知名称 |
server | String | 发送通知的服务host |
subscriptionName | String | (兼容QNS通知) |
version | String | (兼容QNS通知) |
signature | String | (兼容QNS通知) |
- 示例:
JSON
1{
2 "messageBody": {
3 "jobId": "job-jmkmdp90t4rvkhp0",
4 "pipelineName": "test_notification",
5 "jobStatus": "SUCCESS",
6 "createTime": "2019-12-11T03:09:35Z",
7 "startTime": "2019-12-11T03:09:58Z",
8 "endTime": "2019-12-11T03:10:15Z",
9 "source": {
10 "clips": [
11 {
12 "bucket": "tescae",
13 "sourceKey": "input/chengdu.mp4"
14 }
15 ]
16 },
17 "target": {
18 "targetKey": "test_notification.mp4",
19 "presetName": "bce.video_mp4_1920x1080_3660kbps"
20 },
21 "output": {
22 "video": {
23 "durationInSeconds": 15,
24 "sizeInKiloByte": 5804.772461,
25 "widthInPixel": 606,
26 "heightInPixel": 1080,
27 "frameRate": 30,
28 "mp4MoovSize": 9728
29 },
30 "audio": {
31 "sampleRateInHz": 44100,
32 "channels": 2
33 },
34 "bitRateInKBps": "3095.88"
35 }
36 },
37 "messageId": "943520a5-14c4-4980-84a0-9c44b8dfe517",
38 "notification": "test_to_dev_8009",
39 "server": "multimedia.bce-testinternal.baidu.com",
40 "subscriptionName": "",
41 "version": "",
42 "signature": ""
43}
查询通知
请求(Request)
- 请求语法:
Http
1GET /v{version}/notification/{name} HTTP/1.1
2accept-encoding: gzip, deflate
3x-bce-date: {utc-date-string}
4host: media.bj.baidubce.com
5accept: */*
6connection: keep-alive
7x-bce-request-id: {bce-request-id}
8content-type: application/json
9authorization: {bce-authorization-string}
- 请求头域:无特殊Header参数
- 请求参数:无
- 请求示例:
Http
1GET /v3/notification/mct_notification HTTP/1.1
2content-length: 0
3accept-encoding: gzip, deflate
4x-bce-date: 2015-07-03T09:28:13Z
5connection: keep-alive
6accept: */*
7user-agent: python-requests/2.4.0 CPython/2.7.9 Darwin/14.3.0
8host: media.bj.baidubce.com
9x-bce-request-id: 8776558c-81d9-4f97-8e2c-f977a286095d
10content-type: application/json
11authorization: bce-auth-v1/e8e4a9ced6794355a9a1b8a20b58d37b/2015-07-03T09:28:13Z/1800/content-type;host;x-bce-date/4a1692dc4bab84f5801f79ea0c1fece3601cf73ecd94409d2a94b3942b971715
响应(Reponse)
- 响应头域:无特殊Header参数
- 响应参数:
字段名称 | 字段类型 | 字段描述 |
---|---|---|
name | String | 通知名称 |
endpoint | String | 通知消息接收地址 |
- 响应示例:
Http
1HTTP/1.1 200 OK
2x-bce-request-id: 8776558c-81d9-4f97-8e2c-f977a286095d
3Date: Fri, 03 Jul 2015 09:28:13 GMT
4Transfer-Encoding: chunked
5Content-Type: application/json;charset=UTF-8
6Cache-Control: no-cache
7
8{
9 "name" : "mct_notification",
10 "endpoint" : "http://mct.notificaitonDomain.com/"
11}
删除通知
请求(Request)
- 请求语法:
Http
1DELETE /v{version}/notification/{name} HTTP/1.1
2accept-encoding: gzip, deflate
3x-bce-date: {utc-date-string}
4host: media.bj.baidubce.com
5accept: */*
6connection: keep-alive
7x-bce-request-id: {bce-request-id}
8content-type: application/json
9authorization: {bce-authorization-string}
- 请求头域:无特殊Header参数
- 请求参数:无
- 请求示例:
Http
1DELETE /v3/notification/mct_notification HTTP/1.1
2content-length: 0
3accept-encoding: gzip, deflate
4x-bce-date: 2015-07-03T09:28:13Z
5connection: keep-alive
6accept: */*
7user-agent: python-requests/2.4.0 CPython/2.7.9 Darwin/14.3.0
8host: media.bj.baidubce.com
9x-bce-request-id: 8776558c-81d9-4f97-8e2c-f977a286095d
10content-type: application/json
11authorization: bce-auth-v1/e8e4a9ced6794355a9a1b8a20b58d37b/2015-07-03T09:28:13Z/1800/content-type;host;x-bce-date/4a1692dc4bab84f5801f79ea0c1fece3601cf73ecd94409d2a94b3942b971715
响应(Reponse)
- 响应头域:无特殊Header参数
- 响应参数:无
- 响应示例:
Http
1HTTP/1.1 200 OK
2x-bce-request-id: 8776558c-81d9-4f97-8e2c-f977a286095d
3Date: Fri, 03 Jul 2015 09:28:13 GMT
4Transfer-Encoding: chunked
5Content-Type: application/json;charset=UTF-8
6Cache-Control: no-cache
通知列表
请求(Request)
- 请求语法:
Http
1GET /v{version}/notification HTTP/1.1
2accept-encoding: gzip, deflate
3x-bce-date: {utc-date-string}
4host: media.bj.baidubce.com
5accept: */*
6connection: keep-alive
7x-bce-request-id: {bce-request-id}
8content-type: application/json
9authorization: {bce-authorization-string}
- 请求头域:无特殊Header参数
- 请求参数:无
- 请求示例:
Http
1GET /v3/notification HTTP/1.1
2content-length: 0
3accept-encoding: gzip, deflate
4x-bce-date: 2015-07-03T09:28:13Z
5connection: keep-alive
6accept: */*
7user-agent: python-requests/2.4.0 CPython/2.7.9 Darwin/14.3.0
8host: media.bj.baidubce.com
9x-bce-request-id: 8776558c-81d9-4f97-8e2c-f977a286095d
10content-type: application/json
11authorization: bce-auth-v1/e8e4a9ced6794355a9a1b8a20b58d37b/2015-07-03T09:28:13Z/1800/content-type;host;x-bce-date/4a1692dc4bab84f5801f79ea0c1fece3601cf73ecd94409d2a94b3942b971715
响应(Reponse)
- 响应头域:无特殊Header参数
- 响应参数:
字段名称 | 字段类型 | 字段描述 |
---|---|---|
notifications | Object | 通知列表 |
+ name | String | 通知名称 |
+ endpoint | String | 通知消息接收地址 |
- 响应示例:
Http
1HTTP/1.1 200 OK
2x-bce-request-id: 8776558c-81d9-4f97-8e2c-f977a286095d
3Date: Fri, 03 Jul 2015 09:28:13 GMT
4Transfer-Encoding: chunked
5Content-Type: application/json;charset=UTF-8
6Cache-Control: no-cache
7
8{
9 "notifications" : [{
10 "name" : "mct_notification",
11 "endpoint" : "http://mct.notificaitonDomain.com/"
12 },
13 {
14 "name" : "my_notification",
15 "endpoint" : "http://my.notificaitonDomain.com/"
16 }]
17}