功能描述
Create Media Jobs 接口用来提交一个任务。
请求
请求示例
POST /jobs HTTP/1.1Host: <BucketName-APPID>.ci.<Region>.myqcloud.comDate: <GMT Date>Authorization: <Auth String>Content-Length: <length>Content-Type: application/xml<body>
说明:
请求头
请求体
该请求操作的实现需要有如下请求体。
<Request><Tag>Segment</Tag><Input><Object></Object></Input><Operation><Segment><Format>mp4</Format><Duration>5</Duration></Segment><Output><Region></Region><Bucket></Bucket><Object></Object></Output></Operation><QueueId></QueueId><CallBack></CallBack></Request>
具体的数据描述如下:
节点名称(关键字)  | 父节点  | 描述  | 类型  | 必选  | 
Request  | 无  | 保存请求的容器  | Container  | 是  | 
Container 类型 Request 的具体数据描述如下:
节点名称(关键字)  | 父节点  | 描述  | 类型  | 必选  | 
Tag  | Request  | 创建任务的 Tag:Segment  | String  | 是  | 
Input  | Request  | 待操作的媒体信息  | Container  | 是  | 
Operation  | Request  | 操作规则  | Container  | 是  | 
QueueId  | Request  | 任务所在的队列 ID  | String  | 是  | 
CallBack  | Request  | 回调地址  | String  | 否  | 
Container 类型 Input 的具体数据描述如下:
节点名称(关键字)  | 父节点  | 描述  | 类型  | 必选  | 
Object  | Request.Input  | 媒体文件的名字  | String  | 是  | 
Container 类型 Operation 的具体数据描述如下:
节点名称(关键字)  | 父节点  | 描述  | 类型  | 必选  | 
Segment  | Request.Operation  | 指定分段参数  | Container  | 是  | 
Output  | Request.Operation  | 结果输出地址  | Container  | 是  | 
Container 类型 Segment 的具体数据描述如下:
节点名称(关键字)  | 父节点  | 描述  | 类型  | 必选  | 限制  | 
Format  | Request.Operation.Segment  | 封装格式  | string  | 是  | aac、mp3、flac、mp4、ts、mkv、avi  | 
Duration  | Request.Operation.Segment  | 分段时长,单位:秒  | string  | 是  | 不小于5的整数  | 
Container 类型 Output 的具体数据描述如下:
节点名称(关键字)  | 父节点  | 描述  | 类型  | 必选  | 
Region  | Request.Operation.Output  | 存储桶的园区  | String  | 是  | 
Bucket  | Request.Operation.Output  | 存储结果的存储桶  | String  | 是  | 
Object  | Request.Operation.Output  | 结果文件的名字,必须包含${Number}参数作为自定义分段后每一小段音/视频流的输出序号  | String  | 是  | 
响应
响应头
响应体
该响应体返回为 application/xml 数据,包含完整节点数据的内容展示如下:
<Response><JobsDetail><Code></Code><Message></Message><JobId></JobId><State></State><CreationTime></CreationTime><StartTime></StartTime><EndTime></EndTime><QueueId></QueueId><Tag>Segment</Tag><Input><Object></Object></Input><Operation><Segment><Format>mp4</Format><Duration>5</Duration></Segment><Output><Region></Region><Bucket></Bucket><Object></Object></Output><MediaInfo></MeidaInfo></Operation></JobsDetail></Response>
具体的数据内容如下:
节点名称(关键字)  | 父节点  | 描述  | 类型  | 
Response  | 无  | 保存结果的容器  | Container  | 
Container 节点 Response 的内容:
节点名称(关键字)  | 父节点  | 描述  | 类型  | 
JobsDetail  | Response  | 任务的详细信息  | Container  | 
Container 节点 JobsDetail 的内容:
节点名称(关键字)  | 父节点  | 描述  | 类型  | 
Code  | Response.JobsDetail  | 错误码,只有 State为 Failed 时有意义  | String  | 
Message  | Response.JobsDetail  | 错误描述,只有 State为 Failed 时有意义  | String  | 
JobId  | Response.JobsDetail  | 新创建任务的 ID  | String  | 
Tag  | Response.JobsDetail  | 新创建任务的 Tag:Segment  | String  | 
State  | Response.JobsDetail  | 任务的状态,为 Submitted、Running、Success、Failed、Pause、Cancel 其中一个  | String  | 
CreationTime  | Response.JobsDetail  | 任务的创建时间  | String  | 
StartTime  | Response.JobsDetail  | 任务的开始时间  | String  | 
EndTime  | Response.JobsDetail  | 任务的结束时间  | String  | 
QueueId  | Response.JobsDetail  | 任务所属的队列 ID  | String  | 
Input  | Response.JobsDetail  | 该任务的输入资源地址  | Container  | 
Operation  | Response.JobsDetail  | 该任务的规则  | Container  | 
Container 节点 Input 的内容:
同 请求中的 Request.Input节点。
Container 节点 Operation 的内容:
节点名称(关键字)  | 父节点  | 描述  | 类型  | 
Segment  | Response.JobsDetail.Operation  | 同请求中的 Request.Operation.Segment  | Container  | 
Output  | Response.JobsDetail.Operation  | 文件的输出地址  | Container  | 
MediaInfo  | Response.JobsDetail.Operation  | 转码输出视频的信息,没有时不返回  | Container  | 
Container 节点 Output 的内容:
同 请求中的 Request.Operation.Output 节点。
错误码
实际案例
请求
POST /jobs HTTP/1.1Authorization:q-sign-algorithm=sha1&q-ak=************************************&q-sign-time=1497530202;1497610202&q-key-time=1497530202;1497610202&q-header-list=&q-url-param-list=&q-signature=****************************************Host:bucket-1250000000.ci.ap-beijing.myqcloud.comContent-Length: 166Content-Type: application/xml<Request><Tag>Segment</Tag><Input><Object>test.mp4</Object></Input><Operation><Segment><Format>mp4</Format><Duration>5</Duration></Segment><Output><Region>ap-beijing</Region><Bucket>abc-1250000000</Bucket><Object>test-trans${Number}</Object></Output></Operation><QueueId>p893bcda225bf4945a378da6662e81a89</QueueId></Request>
响应
HTTP/1.1 200 OKContent-Type: application/xmlContent-Length: 230Connection: keep-aliveDate: Thu, 15 Jun 2017 12:37:29 GMTServer: tencent-cix-ci-request-id: NTk0MjdmODlfMjQ4OGY3XzYzYzhfMjc=<Response><JobsDetail><Code>Success</Code><Message>Success</Message><JobId>je8f65004eb8511eaaed4f377124a303c</JobId><State>Submitted</State><CreationTime>2019-07-07T12:12:12+0800</CreationTime><StartTime></StartTime><EndTime></EndTime><QueueId>p893bcda225bf4945a378da6662e81a89</QueueId><Tag>Segment</Tag><Input><Object>test.mp4</Object></Input><Operation><Segment><Format>mp4</Format><Duration>5</Duration></Segment><Output><Region>ap-beijing</Region><Bucket>abc-1250000000</Bucket><Object>test-trans${Number}</Object></Output></Operation></JobsDetail></Response>