明水印接口
更新时间:2023-11-20
创建水印
请求(Request)
-
请求语法:
POST /v{version}/watermark HTTP/1.1 accept-encoding: gzip, deflate x-bce-date: {utc-date-string} host: media.bj.baidubce.com accept: */* connection: keep-alive x-bce-request-id: {bce-request-id} content-type: application/json authorization: {bce-authorization-string}
- 请求头域:无特殊Header参数
- 请求参数(以下均为Requestbody参数):
字段名称 | 字段类型 | 必要性 | 字段描述 | 可选值 | 默认值 |
---|---|---|---|---|---|
bucket | String | 必选 | BOS存储上水印文件Bucket | - | - |
key | String | 必选 | BOS存储上水印文件Key,支持JPG、PNG、APNG、BMP、PBM、TIF、GIF 、MOV等格式,其中MOV、GIF、APNG为动态水印 | - | - |
verticalAlignment | String | 可选 | 垂直对齐方式 | top, center, bottom | top |
horizontalAlignment | String | 可选 | 水平对齐方式 | left, center, right | left |
verticalOffsetInPixel | Number | 可选 | 垂直偏移,该参数仅在verticalAlignment设置为top或bottom时有效,单位:像素 | 0 ~ 3072 | 0 |
horizontalOffsetInPixel | Number | 可选 | 水平偏移,该参数仅在horizontalAlignment设置为left或right时有效,单位:像素 | 0 ~ 4096 | 0 |
timeline | Object | 可选 | 水印有效显示起止时间(仅当watermarkId被设置到Preset.watermarks.image多水印参数中时该字段可生效) | - | - |
+ startTimeInMillisecond | Number | 可选 | 水印显示起始时间,单位:毫秒 | 大于等于0 | -(为空表示从第0s开始) |
+ durationInMillisecond | Number | 可选 | 水印显示持续时间,单位:毫秒 | 大于等于0 | -(为空表示持续视频时长) |
repeated | Number | 可选 | (动态)水印重复显示次数,为0表示无限循环(仅当watermarkId被设置到Preset.watermarks.image多水印参数中时该字段可生效) | 大于等于0 | 1 |
allowScaling | Bool | 可选 | 是否允许自动进行缩放(仅当watermarkId被设置到Preset.watermarks.image多水印参数中时该字段可生效) | true、false | true |
-
请求示例:
POST /v3/watermark HTTP/1.1 accept-encoding: gzip, deflate x-bce-date: 2015-03-24T13:08:44Z host: media.bj.baidubce.com accept: */* connection: keep-alive x-bce-request-id: d97c57d0-ca44-4d1c-bfeb-941a92440968 content-type: application/json authorization: bce-auth-v1/46bd9968a6194b4bbdf0341f2286ccce/2015-03-24T13:08:44Z/1800/host;x-bce-date/7e21c9cf1e4e2cc6921a407a388fe98df122c53b9f509043d841be76eb09a1f9 { "bucket" : "samplebucket", "key" : "samplefolderpath/samplewatermark.png", "verticalOffsetInPixel" : 0, "horizontalOffsetInPixel" : 0 }
响应(Reponse)
- 响应头域:无特殊Header参数
- 响应参数:
字段名称 | 字段类型 | 字段描述 |
---|---|---|
watermarkId | String | 水印的唯一标识 |
-
响应示例:
HTTP/1.1 200 OK Transfer-Encoding: chunked x-bce-request-id: d97c57d0-ca44-4d1c-bfeb-941a92440968 Cache-Control: no-cache Server: BWS Date: Tue, 24 Mar 2015 13:34:07 GMT Content-Type: application/json;charset=UTF-8 { "watermarkId" : "wmk-lsdspxdastmnbama" }
查询指定水印
请求(Request)
-
请求语法:
GET /v{version}/watermark/{watermarkId} HTTP/1.1 accept-encoding: gzip, deflate x-bce-date: {utc-date-string} host: media.bj.baidubce.com accept: */* connection: keep-alive x-bce-request-id: {bce-request-id} content-type: application/json authorization: {bce-authorization-string}
- 请求头域:无特殊Header参数
- 请求参数:无
-
请求示例:
POST /v3/watermark/wmk-lsdspxdastmnbama HTTP/1.1 accept-encoding: gzip, deflate x-bce-date: 2015-03-24T13:08:44Z host: media.bj.baidubce.com accept: */* connection: keep-alive x-bce-request-id: 9c1f8229-a8d4-46e1-b8e2-25412e0eee63 content-type: application/json authorization: bce-auth-v1/535f3834e538448aa88f3c589bab2ea3/2015-03-24T13:08:44Z/1800/host;x-bce-date/7e21c9cf1e4e2cc6921a407a388fe98df122c53b9f509043d841be76eb09a1f9
响应(Reponse)
- 响应头域:无特殊Header参数
- 响应参数:与[创建水印/请求/请求参数]保持一致,增加以下字段
字段名称 | 字段类型 | 字段描述 |
---|---|---|
watermarkId | String | 水印的唯一标识 |
createTime | Date | 水印创建时间 |
-
响应示例:
HTTP/1.1 200 OK Transfer-Encoding: chunked x-bce-request-id: 9c1f8229-a8d4-46e1-b8e2-25412e0eee63 Cache-Control: no-cache Server: BWS Date: Tue, 24 Mar 2015 13:34:07 GMT Content-Type: application/json;charset=UTF-8 { "watermarkId" : "wmk-lsdspxdastmnbama", "createTime": "2015-05-11T12:42:21Z", "bucket" : "samplebucket", "key" : "samplefolderpath/samplewatermark.png", "verticalOffsetInPixel" : 0, "horizontalOffsetInPixel" : 0 }
查询当前用户水印
请求(Request)
-
请求语法:
GET /v{version}/watermark HTTP/1.1 accept-encoding: gzip, deflate x-bce-date: {utc-date-string} host: media.bj.baidubce.com accept: */* connection: keep-alive x-bce-request-id: {bce-request-id} content-type: application/json authorization: {bce-authorization-string}
- 请求头域:无特殊Header参数
- 请求参数:无
-
请求示例:
GET /v3/watermark HTTP/1.1 accept-encoding: gzip, deflate x-bce-date: 2015-03-24T13:08:44Z host: media.bj.baidubce.com accept: */* connection: keep-alive x-bce-request-id: 249ac308-4554-4825-ab0f-867dd92024d8 content-type: application/json authorization: bce-auth-v1/02296dd93f1940a39913d9a406332486/2015-03-24T13:08:44Z/1800/host;x-bce-date/cef8a3207e29c4663292c42665de1154e760c734f82248b36a71be2bb3281b1d
响应(Reponse)
- 响应头域:无特殊Header参数
- 响应参数:与[创建水印/请求/请求参数]保持一致,增加以下字段
字段名称 | 字段类型 | 字段描述 |
---|---|---|
watermarkId | String | 水印的唯一标识 |
createTime | Date | 水印创建时间 |
-
响应示例:
HTTP/1.1 200 OK Transfer-Encoding: chunked x-bce-request-id: 249ac308-4554-4825-ab0f-867dd92024d8 Cache-Control: no-cache Server: BWS Date: Tue, 24 Mar 2015 13:34:07 GMT Content-Type: application/json;charset=UTF-8 { "watermarks": [ { "watermarkId" : "wmk-lsdspxdastmnbama", "createTime": "2015-05-11T12:42:21Z", "bucket" : "samplebucket", "key" : "samplefolderpath/samplewatermark.png", "verticalOffsetInPixel" : 0, "horizontalOffsetInPixel" : 0 }, { "watermarkId" : "wmk-feji7exr57r3824x", "createTime": "2015-05-07T12:34:20Z", "bucket" : "samplebucket", "key" : "samplefolderpath/samplewatermark1.png", "verticalOffsetInPixel" : 150, "horizontalOffsetInPixel" : 40 }, { "watermarkId" : "wmk-lsdspxdastmnbama", "createTime": "2015-05-08T12:22:15Z", "bucket" : "samplebucket2", "key" : "samplefolderpath/samplewatermark.png", "verticalOffsetInPixel" : 0, "horizontalOffsetInPixel" : 200 } ] }
删除水印
请求(Request)
-
请求语法:
DELETE /v{version}/watermark/{watermarkId} HTTP/1.1 accept-encoding: gzip, deflate x-bce-date: {utc-date-string} host: media.bj.baidubce.com accept: */* connection: keep-alive x-bce-request-id: {bce-request-id} content-type: application/json authorization: {bce-authorization-string}
- 请求头域:无特殊Header参数
- 请求参数:无
-
请求示例:
DELETE /v3/watermark/wmk-lsdspxdastmnbama HTTP/1.1 accept-encoding: gzip, deflate x-bce-date: 2015-03-24T13:08:44Z host: media.bj.baidubce.com accept: */* connection: keep-alive x-bce-request-id: f922935d-cf8a-4078-a43a-dc3475ab3a70 content-type: application/json authorization: bce-auth-v1/535f3834e538448aa88f3c589bab2ea3/2015-03-24T13:08:44Z/1800/host;x-bce-date/19468bb170d1073c5cdd292f4424d80d259d0a17528648426f305d39a2d6c452
响应(Response)
- 响应头域:无特殊Header参数
- 响应参数:无
-
响应示例:
HTTP/1.1 200 OK x-bce-request-id: f922935d-cf8a-4078-a43a-dc3475ab3a70 Cache-Control: no-cache
常见异常
水印不存在
- 异常代码:404
- 异常字段:watermark: XXXX does not exist
- 产生原因: 1.试图查询/删除不存在(未创建/已删除)的水印 2.创建转码模板使用了不存在的水印
水印图片不存在
- 异常代码:404
- 异常字段:bos object: XXXX does not exist
- 产生原因: 1.创建水印时使用了不存在的bos object 2.创建job时引用了不存在的bos object(转码源视频或水印图片)
水印无法删除
- 异常代码:400
- 异常字段:watermark is in use, please delete the relative presets first
- 产生原因: 1.试图删除的水印正在被当前活跃的preset使用,建议用户先删除对应的preset
Transmux模式下增加水印
- 异常代码:400
- watermark is not supported in Transmux mode
- 产生原因: 1.试图在Transmux模式下添加水印,改模式不进行重新编码所以无法添加水印