调用SubmitSnapshotJob提交截图作业。
使用说明
- 目前仅支持生成JPG格式图片。
- 异步模式:不保证接口返回时截图已经生成,截图任务将进入后台排队,异步执行截图。只要设置了Interval和Num中的任何一个参数,就表示异步模式。更多截图常见问题,请参见截图常见问题。
- 消息通知:提交截图作业时,PipelineId参数必填,只有在管道上指定了回调信息,完成后才会发送异步消息。
QPS限制
本接口的单用户QPS限制为50次/秒。超过限制,API调用会被限流,这可能会影响您的业务,请合理调用。更多信息,请参见QPS限制。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
请求参数
| 名称 | 类型 | 是否必选 | 示例值 | 描述 |
|---|---|---|---|---|
| Action | String | 是 | SubmitSnapshotJob | 操作接口名,系统规定参数,取值: SubmitSnapshotJob。 |
| Input | String | 是 | {"Bucket":"example-bucket","Location":"example-location","Object":"example%2Ftest.flv"} | 作业输入,JSON对象。需在MPS控制台>工作流管理>媒体Bucket>添加Bucket授予此Bucket媒体处理服务的权限。授权完成后,还需对Object进行UrlEncoding。UrlEncoding示例: 说明 OSS的地域需要与当前MPS所在地域保持一致。 |
| SnapshotConfig | String | 是 | {"OutputFile":{"Bucket":"example-001","Location":"example-location","Object":"{Count}.jpg"},"Time":"5","Num":"10","Interval":"20"} | 截图配置。更多信息,请参见SnapshotConfig参数详情。 说明 截图配置中,如果设置了Interval参数,会指定时间间隔进行截图(默认10 s)。如果视频较短但截图数量较多(比如:视频时长为10 s,截图数量设置为5张,时间间隔设置为3 s),可能会导致截不完设置的截图数量。 |
| UserData | String | 否 | testid-001 | 用户自定义数据。支持中英文、数字、短划线(-),不能以特殊字符开头,最大长度1024个字节。 |
| PipelineId | String | 否 | dd3dae411e704030b921e52698e5**** | 管道ID,可以通过MPS控制台>全局设置>管道获取。 说明 必须保证此管道绑定了可用的消息主题,否则消息无法正确发送。 |
返回数据
| 名称 | 类型 | 示例值 | 描述 |
|---|---|---|---|
| RequestId | String | 19B6D8C5-A5DD-467A-B435-29D393C71E2D | 请求ID。 |
| SnapshotJob | Object | 截图作业。 |
|
| CreationTime | String | 2021-05-19T03:11:48Z | 任务创建时间。 |
| SnapshotConfig | Object | 截图配置。 |
|
| Time | String | 5 | 截图开始时间。单位:毫秒。 |
| TileOut | Object | 拼图配置。 |
|
| Padding | String | 0 | 图片间距。
|
| Color | String | black | 背景颜色。
说明 其中颜色关键字支持三种格式,比如黑色,支持Black,black,#000000。 |
| CellSelStep | String | 3 | 选取单图片步长。 |
| CellHeight | String | 100 | 单图片高度。默认截图输出分辨率高度。 |
| CellWidth | String | 100 | 单图片宽度。默认截图输出分辨率宽度。 |
| Margin | String | 5 | 外框宽度。
|
| Columns | String | 10 | 图片拼合列数。默认:10。 |
| IsKeepCellPic | String | false | 是否保留单图片。可取值:
|
| Lines | String | 10 | 图片拼合行数。默认:10。 |
| Interval | String | 20 | 截图间隔时间。
|
| FrameType | String | intra | 截图类型。默认值:normal。可取值:
说明 如果请求参数中将FrameType参数设置为I帧(关键帧),将只截取关键帧。如果指定的时间节点为非关键帧,则就近选取关键帧。在同等截图规则下,关键帧截图比普通帧截图速度快。 |
| Width | String | 8 | 截图输出图片宽度。 |
| Height | String | 8 | 截图输出图片高度。 |
| OutputFile | Object | 截图输出OSS配置。 |
|
| RoleArn | String | acs:ram::1:role/testrole | 指定角色的ARN。格式:acs:ram::$accountID:role/$roleName。 |
| Object | String | test.png | 截图输出文件(OSS Object)。 |
| Location | String | example-location | 截图输出OSS Bucket所在数据中心(OSS Location)。 |
| Bucket | String | example | 截图输出文件所在OSS Bucket。 |
| Num | String | 10 | 截图数量。若指定则表示序列截图。 |
| TileOutputFile | Object | 拼图任务大图的输出OSS配置。 |
|
| RoleArn | String | acs:ram::1:role/testrole | 指定角色的ARN。格式:acs:ram::$accountID:role/$roleName。 |
| Object | String | example.png | 输出文件 (OSS Object)。 |
| Location | String | example-location | 输出OSS Bucket所在数据中心(OSS Location)。 |
| Bucket | String | example | 输出文件所在OSS Bucket。 |
| State | String | Snapshoting | 截图状态。取值:
|
| Message | String | The resource operated InputFile is bad | 分析失败时错误信息。若成功则不返回此参数。 |
| MNSMessageResult | Object | MNS通知用户作业完成的结果。 |
|
| MessageId | String | 799454621135656C7F815F198A76**** | 成功时消息ID。若失败则不返回此参数。 |
| ErrorMessage | String | The resource operated InputFile is bad | 失败时错误信息。若成功则不返回此参数。 |
| ErrorCode | String | InvalidParameter | 失败时错误码。若成功则不返回此参数。 |
| Input | Object | 作业输入。 |
|
| RoleArn | String | acs:ram::1:role/testrole | 指定角色的ARN。格式:acs:ram::$accountID:role/$roleName。 |
| Object | String | example.flv | 输入文件(OSS Object)。 |
| Location | String | example-location' | 输入OSS Bucket所在数据中心(OSS Location)。 |
| Bucket | String | example | 输入文件所在OSS Bucket。 |
| Count | String | 1 | 截取图片的数量。 |
| TileCount | String | 5 | 拼图图片数量。 |
| UserData | String | testid-001 | 用户自定义数据。 |
| Code | String | ResourceContentBad | 分析失败时错误码。若成功则不返回此参数。 |
| PipelineId | String | dd3dae411e704030b921e52698e5**** | 管道ID。 |
| Id | String | f4e3b9ba9f3840c39d6e288056f0**** | 截图作业ID。 |
示例
请求示例
http(s)://mts.cn-hangzhou.aliyuncs.com/?Action=SubmitSnapshotJob
&Input={"Bucket":"example-bucket","Location":"example-location","Object":"example%2Ftest.flv"}
&SnapshotConfig={"OutputFile":{"Bucket":"example-001","Location":"example-location","Object":"{Count}.jpg"},"Time":"5","Num":"10","Interval":"20"}
&UserData=testid-001
&PipelineId=dd3dae411e704030b921e52698e5****
&<公共请求参数>
正常返回示例
XML格式
HTTP/1.1 200 OK
Content-Type:application/xml
<SubmitSnapshotJobResponse>
<RequestId>19B6D8C5-A5DD-467A-B435-29D393C71E2D</RequestId>
<SnapshotJob>
<CreationTime>2021-05-19T03:11:48Z</CreationTime>
<SnapshotConfig>
<Time>5</Time>
<TileOut>
<Padding>0</Padding>
<Color>black</Color>
<CellSelStep>3</CellSelStep>
<CellHeight>100</CellHeight>
<CellWidth>100</CellWidth>
<Margin>5</Margin>
<Columns>10</Columns>
<IsKeepCellPic>false</IsKeepCellPic>
<Lines>10</Lines>
</TileOut>
<Interval>20</Interval>
<FrameType>intra</FrameType>
<Width>8</Width>
<Height>8</Height>
<OutputFile>
<RoleArn>acs:ram::1:role/testrole</RoleArn>
<Object>test.png</Object>
<Location>example-location</Location>
<Bucket>example</Bucket>
</OutputFile>
<Num>10</Num>
<TileOutputFile>
<RoleArn>acs:ram::1:role/testrole</RoleArn>
<Object>example.png</Object>
<Location>example-location</Location>
<Bucket>example</Bucket>
</TileOutputFile>
</SnapshotConfig>
<State>Snapshoting</State>
<Message>The resource operated InputFile is bad</Message>
<MNSMessageResult>
<MessageId>799454621135656C7F815F198A76****</MessageId>
<ErrorMessage>The resource operated InputFile is bad</ErrorMessage>
<ErrorCode>InvalidParameter</ErrorCode>
</MNSMessageResult>
<Input>
<RoleArn>acs:ram::1:role/testrole</RoleArn>
<Object>example.flv</Object>
<Location>example-location'</Location>
<Bucket>example</Bucket>
</Input>
<Count>1</Count>
<TileCount>5</TileCount>
<UserData>testid-001</UserData>
<Code>ResourceContentBad</Code>
<PipelineId>dd3dae411e704030b921e52698e5****</PipelineId>
<Id>f4e3b9ba9f3840c39d6e288056f0****</Id>
</SnapshotJob>
</SubmitSnapshotJobResponse>
JSON格式
HTTP/1.1 200 OK
Content-Type:application/json
{
"RequestId" : "19B6D8C5-A5DD-467A-B435-29D393C71E2D",
"SnapshotJob" : {
"CreationTime" : "2021-05-19T03:11:48Z",
"SnapshotConfig" : {
"Time" : "5",
"TileOut" : {
"Padding" : "0",
"Color" : "black",
"CellSelStep" : "3",
"CellHeight" : "100",
"CellWidth" : "100",
"Margin" : "5",
"Columns" : "10",
"IsKeepCellPic" : "false",
"Lines" : "10"
},
"Interval" : "20",
"FrameType" : "intra",
"Width" : "8",
"Height" : "8",
"OutputFile" : {
"RoleArn" : "acs:ram::1:role/testrole",
"Object" : "test.png",
"Location" : "example-location",
"Bucket" : "example"
},
"Num" : "10",
"TileOutputFile" : {
"RoleArn" : "acs:ram::1:role/testrole",
"Object" : "example.png",
"Location" : "example-location",
"Bucket" : "example"
}
},
"State" : "Snapshoting",
"Message" : "The resource operated InputFile is bad",
"MNSMessageResult" : {
"MessageId" : "799454621135656C7F815F198A76****",
"ErrorMessage" : "The resource operated InputFile is bad",
"ErrorCode" : "InvalidParameter"
},
"Input" : {
"RoleArn" : "acs:ram::1:role/testrole",
"Object" : "example.flv",
"Location" : "example-location'",
"Bucket" : "example"
},
"Count" : "1",
"TileCount" : "5",
"UserData" : "testid-001",
"Code" : "ResourceContentBad",
"PipelineId" : "dd3dae411e704030b921e52698e5****",
"Id" : "f4e3b9ba9f3840c39d6e288056f0****"
}
}
错误码
访问错误中心查看更多错误码。