简介
数据万象提供了一套完善便捷的媒体处理机制,通过这套机制可以对存储在对象存储 COS 中的媒体对象进行各类型处理操作。
媒体处理机制分为以下几种方式:
方式 | 类别 | 说明 |
通过裸参数提交任务 | 持久化处理 | |
通过模板设置提交任务 | 持久化处理 | |
工作流处理 | 持久化处理 | |
批量处理 | 持久化处理 | |
同步任务 | 同步处理 |
通过裸参数提交任务
说明
通过裸参数提交任务时不需要设置模板。
请求语法
POST /jobs HTTP/1.1Host: <BucketName-APPID>.ci.<Region>.myqcloud.comDate: <GMT Date>Authorization: <Auth String>Content-Length: <length>Content-Type: application/xml<body>
请求示例:通过裸参数提交音视频转码任务
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: test-1234567890.ci.ap-chongqing.myqcloud.comContent-Length: 166Content-Type: application/xml<Request><Tag>Transcode</Tag><Input><Object>input/demo.mp4</Object></Input><Operation><Transcode><Container><Format>mp4</Format></Container><Video><Codec>H.264</Codec><Profile>high</Profile><Bitrate>1000</Bitrate><Width>1280</Width><Fps>30</Fps><Preset>medium</Preset></Video><Audio><Codec>aac</Codec><Samplerate>44100</Samplerate><Bitrate>128</Bitrate><Channels>4</Channels></Audio><TransConfig><AdjDarMethod>scale</AdjDarMethod><IsCheckReso>false</IsCheckReso><ResoAdjMethod>1</ResoAdjMethod></TransConfig><TimeInterval><Start>0</Start><Duration>60</Duration></TimeInterval><AudioMixArray><AudioSource>https://test-xxx.cos.ap-chongqing.myqcloud.com/mix1.mp3</AudioSource><MixMode>Once</MixMode><Replace>true</Replace><EffectConfig><EnableStartFadein>true</EnableStartFadein><StartFadeinTime>3</StartFadeinTime><EnableEndFadeout>false</EnableEndFadeout><EndFadeoutTime>0</EndFadeoutTime><EnableBgmFade>true</EnableBgmFade><BgmFadeTime>1.7</BgmFadeTime></EffectConfig></AudioMixArray><AudioMixArray><AudioSource>https://test-xxx.cos.ap-chongqing.myqcloud.com/mix2.mp3</AudioSource><MixMode>Once</MixMode><Replace>true</Replace><EffectConfig><EnableStartFadein>true</EnableStartFadein><StartFadeinTime>3</StartFadeinTime><EnableEndFadeout>false</EnableEndFadeout><EndFadeoutTime>0</EndFadeoutTime><EnableBgmFade>true</EnableBgmFade><BgmFadeTime>1.7</BgmFadeTime></EffectConfig></AudioMixArray></Transcode><Watermark><Type>Text</Type><LocMode>Absolute</LocMode><Dx>128</Dx><Dy>128</Dy><Pos>TopRight</Pos><StartTime>0</StartTime><EndTime>100.5</EndTime><Text><Text>水印内容</Text><FontSize>30</FontSize><FontType>simfang.ttf</FontType><FontColor>0xRRGGBB</FontColor><Transparency>30</Transparency></Text></Watermark><RemoveWatermark><Dx>150</Dx><Dy>150</Dy><Width>75</Width><Height>75</Height></RemoveWatermark><Subtitles><Subtitle><Url>https://test-xxx.cos.ap-chongqing.myqcloud.com/test1.srt</Url></Subtitle><Subtitle><Url>https://test-xxx.cos.ap-chongqing.myqcloud.com/test2.srt</Url></Subtitle></Subtitles><DigitalWatermark><Type>Text</Type><Message>123456789ab</Message><Version>V1</Version><IgnoreError>false</IgnoreError></DigitalWatermark><Output><Region>ap-chongqing</Region><Bucket>test-123456789</Bucket><Object>output/out.${ext}</Object></Output><UserData>This is my data.</UserData><JobLevel>0</JobLevel></Operation><CallBack>http://callback.demo.com</CallBack><CallBackFormat>JSON<CallBackFormat></Request>
返回
HTTP/1.1 200 OKContent-Type: application/xmlContent-Length: 230Connection: keep-aliveDate: Mon, 28 Jun 2022 15:23:12 GMTServer: tencent-cix-ci-request-id: NTk0MjdmODlfMjQ4OGY3XzYzYzhf****<Response><JobsDetail><Code>Success</Code><Message/><JobId>j8d121820f5e411ec926ef19d53ba9c6f</JobId><State>Submitted</State><Progress>0</Progress><CreationTime>2022-06-27T15:23:10+0800</CreationTime><StartTime>-</StartTime><EndTime>-</EndTime><QueueId>p2242ab62c7c94486915508540933a2c6</QueueId><Tag>Transcode</Tag><Input><BucketId>test-123456789</BucketId><Object>input/demo.mp4</Object><Region>ap-chongqing</Region></Input><Operation><Transcode><Container><Format>mp4</Format></Container><Video><Codec>H.264</Codec><Profile>high</Profile><Bitrate>1000</Bitrate><Width>1280</Width><Fps>30</Fps><Preset>medium</Preset></Video><Audio><Codec>aac</Codec><Samplerate>44100</Samplerate><Bitrate>128</Bitrate><Channels>4</Channels></Audio><TransConfig><AdjDarMethod>scale</AdjDarMethod><IsCheckReso>false</IsCheckReso><ResoAdjMethod>1</ResoAdjMethod></TransConfig><TimeInterval><Start>0</Start><Duration>60</Duration></TimeInterval><AudioMixArray><AudioSource>https://test-xxx.cos.ap-chongqing.myqcloud.com/mix1.mp3</AudioSource><MixMode>Once</MixMode><Replace>true</Replace><EffectConfig><EnableStartFadein>true</EnableStartFadein><StartFadeinTime>3</StartFadeinTime><EnableEndFadeout>false</EnableEndFadeout><EndFadeoutTime>0</EndFadeoutTime><EnableBgmFade>true</EnableBgmFade><BgmFadeTime>1.7</BgmFadeTime></EffectConfig></AudioMixArray><AudioMixArray><AudioSource>https://test-xxx.cos.ap-chongqing.myqcloud.com/mix2.mp3</AudioSource><MixMode>Once</MixMode><Replace>true</Replace><EffectConfig><EnableStartFadein>true</EnableStartFadein><StartFadeinTime>3</StartFadeinTime><EnableEndFadeout>false</EnableEndFadeout><EndFadeoutTime>0</EndFadeoutTime><EnableBgmFade>true</EnableBgmFade><BgmFadeTime>1.7</BgmFadeTime></EffectConfig></AudioMixArray></Transcode><Watermark><Type>Text</Type><LocMode>Absolute</LocMode><Dx>128</Dx><Dy>128</Dy><Pos>TopRight</Pos><StartTime>0</StartTime><EndTime>100.5</EndTime><Text><Text>水印内容</Text><FontSize>30</FontSize><FontType></FontType><FontColor>0xRRGGBB</FontColor><Transparency>30</Transparency></Text></Watermark><RemoveWatermark><Dx>150</Dx><Dy>150</Dy><Width>75</Width><Height>75</Height></RemoveWatermark><Subtitles><Subtitle><Url>https://test-xxx.cos.ap-chongqing.myqcloud.com/test1.srt</Url></Subtitle><Subtitle><Url>https://test-xxx.cos.ap-chongqing.myqcloud.com/test2.srt</Url></Subtitle></Subtitles><DigitalWatermark><Type>Text</Type><Message>123456789ab</Message><Version>V1</Version><IgnoreError>false</IgnoreError><State>Running</State></DigitalWatermark><Output><Region>ap-chongqing</Region><Bucket>test-123456789</Bucket><Object>output/out.${ext}</Object></Output><UserData>This is my data.</UserData><JobLevel>0</JobLevel></Operation></JobsDetail></Response>
通过模板设置提交任务
通过设置模板 能帮助您简化操作,设置模板后,您后期在业务中可以多次复用,帮助您提升处理效率。
请求语法
POST /jobs HTTP/1.1Host: <BucketName-APPID>.ci.<Region>.myqcloud.comDate: <GMT Date>Authorization: <Auth String>Content-Length: <length>Content-Type: application/xml<body>
请求示例:设置模板后提交音视频转码任务
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: test-1234567890.ci.ap-chongqing.myqcloud.comContent-Length: 166Content-Type: application/xml<Request><Tag>Transcode</Tag><Input><Object>input/demo.mp4</Object></Input><Operation><TemplateId>t1460606b9752148c4ab182f55163ba7cd</TemplateId><WatermarkTemplateId>t1318c5f428d474afba1797f84091cbe22</WatermarkTemplateId><WatermarkTemplateId>t1318c5f428d474afba1797f84091cbe23</WatermarkTemplateId><WatermarkTemplateId>t1318c5f428d474afba1797f84091cbe24</WatermarkTemplateId><RemoveWatermark><Dx>150</Dx><Dy>150</Dy><Width>75</Width><Height>75</Height></RemoveWatermark><Subtitles><Subtitle><Url>https://test-xxx.cos.ap-chongqing.myqcloud.com/test1.srt</Url></Subtitle><Subtitle><Url>https://test-xxx.cos.ap-chongqing.myqcloud.com/test2.srt</Url></Subtitle></Subtitles><DigitalWatermark><Type>Text</Type><Message>123456789ab</Message><Version>V1</Version><IgnoreError>false</IgnoreError></DigitalWatermark><Output><Region>ap-chongqing</Region><Bucket>test-123456789</Bucket><Object>output/out.${ext}</Object></Output><UserData>This is my data.</UserData><JobLevel>0</JobLevel></Operation><CallBack>http://callback.demo.com</CallBack><CallBackFormat>JSON<CallBackFormat></Request>
返回内容
HTTP/1.1 200 OKContent-Type: application/xmlContent-Length: 230Connection: keep-aliveDate: Mon, 28 Jun 2022 15:23:12 GMTServer: tencent-cix-ci-request-id: NTk0MjdmODlfMjQ4OGY3XzYzYzhf****<Response><JobsDetail><Code>Success</Code><Message/><JobId>j8d121820f5e411ec926ef19d53ba9c6f</JobId><State>Submitted</State><Progress>0</Progress><CreationTime>2022-06-27T15:23:11+0800</CreationTime><StartTime>-</StartTime><EndTime>-</EndTime><QueueId>p2242ab62c7c94486915508540933a2c6</QueueId><Tag>Transcode</Tag><Input><BucketId>test-123456789</BucketId><Object>input/demo.mp4</Object><Region>ap-chongqing</Region></Input><Operation><TemplateId>t1460606b9752148c4ab182f55163ba7cd</TemplateId><TemplateName>trans_993874</TemplateName><WatermarkTemplateId>t1318c5f428d474afba1797f84091cbe22</WatermarkTemplateId><WatermarkTemplateId>t1318c5f428d474afba1797f84091cbe23</WatermarkTemplateId><WatermarkTemplateId>t1318c5f428d474afba1797f84091cbe24</WatermarkTemplateId><RemoveWatermark><Dx>150</Dx><Dy>150</Dy><Width>75</Width><Height>75</Height></RemoveWatermark><Subtitles><Subtitle><Url>https://test-xxx.cos.ap-chongqing.myqcloud.com/test1.srt</Url></Subtitle><Subtitle><Url>https://test-xxx.cos.ap-chongqing.myqcloud.com/test2.srt</Url></Subtitle></Subtitles><DigitalWatermark><Type>Text</Type><Message>123456789ab</Message><Version>V1</Version><IgnoreError>false</IgnoreError><State>Running</State></DigitalWatermark><Output><Region>ap-chongqing</Region><Bucket>test-123456789</Bucket><Object>output/out.${ext}</Object></Output><UserData>This is my data.</UserData><JobLevel>0</JobLevel></Operation></JobsDetail></Response>
工作流处理
请求语法
POST /workflow HTTP/1.1Host: <BucketName-APPID>.ci.<Region>.myqcloud.comDate: <GMT Date>Authorization: <Auth String>Content-Length: <length>Content-Type: application/xml<body>
请求示例:对于输入的视频进行截图和转码处理。转码后, 同时转封装和生成智能封面, 最后做图片处理。
POST /workflow 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: test-1234567890.ci.ap-chongqing.myqcloud.comContent-Length: 166Content-Type: application/xml<Request><MediaWorkflow><Name>workflow-1</Name><State>Active</State><Topology><Dependencies><Start>Snapshot_1581665960536,Transcode_1581665960538</Start><Snapshot_1581665960536>End</Snapshot_1581665960536><Transcode_1581665960538>Segment_15816659605667,SmartCover_1581665960539</Transcode_1581665960538><Segment_15816659605667>End</Segment_15816659605667><SmartCover_1581665960539>PicProcess_15816659605668</SmartCover_1581665960539><PicProcess_15816659605668>End</PicProcess_15816659605668></Dependencies><Nodes><Start><Type>Start</Type><Input><ObjectPrefix>input/workflow-1</ObjectPrefix><NotifyConfig><State>On</State><Url>http://www.callback.com</Url><Event>TaskFinish,WorkflowFinish</Event><Type>Url</Type><ResultFormat>JSON</ResultFormat></NotifyConfig><ExtFilter><State>On</State><Video>true</Video><Audio>false</Audio><Image>false</Image><Custom>false</Custom><AllFile>false</AllFile></ExtFilter></Input></Start><Snapshot_1581665960536><Type>Snapshot</Type><Operation><TemplateId>t1460606b9752148c4ab182f55163ba7cd</TemplateId><Output><Region>ap-chongqing</Region><Bucket>test-1234567890</Bucket><Object>abc/${RunId}/snapshot-${number}.${Ext}</Object><SpriteObject>abc/${RunId}/sprite-${number}.${Ext}</SpriteObject></Output></Operation></Snapshot_1581665960536><Transcode_1581665960538><Type>Transcode</Type><Operation><TemplateId>t16e81a29fe48c4e23acefc247a7792b63</TemplateId><Output><Region>ap-chongqing</Region><Bucket>test-1234567890</Bucket><Object>bcd/${RunId}/trans.{Ext}</Object></Output></Operation></Transcode_1581665960538><Segment_15816659605667><Type>Segment</Type><Operation><Segment><Format>mkv</Format><Duration>20</Duration></Segment><Output><Region>ap-chongqing</Region><Bucket>test-1234567890</Bucket><Object>test-trans${Number}.{Ext}</Object></Output></Operation></Segment_15816659605667><SmartCover_1581665960539><Type>SmartCover</Type><Operation><TemplateId>t16e81a29fe48c4e23acefc247a7792b63</TemplateId><Output><Region>ap-chongqing</Region><Bucket>test-1234567890</Bucket><Object>abc/${RunId}/cover-${Number}.{Ext}</Object></Output></Operation></SmartCover_1581665960539><PicProcess_15816659605668><Type>PicProcess</Type><Operation><TemplateId>t1460606b9752148c4ab182f55163ba7cd</TemplateId><Output><Region>ap-chongqing</Region><Bucket>test-1234567890</Bucket><Object>bcd/${RunId}/pic.{Ext}</Object></Output></Operation></PicProcess_15816659605668></Nodes></Topology></MediaWorkflow></Request>
返回内容
HTTP/1.1 200 OKContent-Type: application/xmlContent-Length: 230Connection: keep-aliveDate: Thu, 14 Jul 2022 12:37:29 GMTServer: tencent-cix-ci-request-id: NjJmMWQxYjNfOTBmYTUwNjRfNWYyY18x<Response><RequestId>NjJmMWQxYjNfOTBmYTUwNjRfNWYyY18x</RequestId><MediaWorkflow><Name>workflow-1</Name><State>Active</State><WorkflowId>wc666d0b9f9dd47ae9137a096252d49f7</WorkflowId><BucketId>test-1234567890</BucketId><CreateTime>2022-07-14T12:37:28+0800</CreateTime><UpdateTime>2022-07-14T12:37:28+0800</UpdateTime><Topology><Dependencies><Start>Snapshot_1581665960536,Transcode_1581665960538</Start><Snapshot_1581665960536>End</Snapshot_1581665960536><Transcode_1581665960538>Segment_15816659605667,SmartCover_1581665960539</Transcode_1581665960538><Segment_15816659605667>End</Segment_15816659605667><SmartCover_1581665960539>PicProcess_15816659605668</SmartCover_1581665960539><PicProcess_15816659605668>End</PicProcess_15816659605668></Dependencies><Nodes><Start><Type>Start</Type><Input><QueueId>p09d709939fef48a0a5c247ef39d90cec</QueueId><PicProcessQueueId>p2911917386e148639319e13c285cc774</PicProcessQueueId><ObjectPrefix>input/workflow-1</ObjectPrefix><NotifyConfig><State>On</State><Url>http://www.callback.com</Url><Event>TaskFinish,WorkflowFinish</Event><Type>Url</Type><ResultFormat>JSON</ResultFormat></NotifyConfig><ExtFilter><State>On</State><Video>true</Video><Audio>false</Audio><Image>false</Image><Custom>false</Custom><AllFile>false</AllFile></ExtFilter></Input></Start><Snapshot_1581665960536><Type>Snapshot</Type><Operation><TemplateId>t1460606b9752148c4ab182f55163ba7cd</TemplateId><Output><Region>ap-chongqing</Region><Bucket>test-1234567890</Bucket><Object>abc/${RunId}/snapshot-${number}.${Ext}</Object><SpriteObject>abc/${RunId}/sprite-${number}.${Ext}</SpriteObject></Output></Operation></Snapshot_1581665960536><Transcode_1581665960538><Type>Transcode</Type><Operation><TemplateId>t16e81a29fe48c4e23acefc247a7792b63</TemplateId><Output><Region>ap-chongqing</Region><Bucket>test-1234567890</Bucket><Object>bcd/${RunId}/trans.{Ext}</Object></Output></Operation></Transcode_1581665960538><Segment_15816659605667><Type>Segment</Type><Operation><Segment><Format>mkv</Format><Duration>20</Duration></Segment><Output><Region>ap-chongqing</Region><Bucket>test-1234567890</Bucket><Object>test-trans${Number}.{Ext}</Object></Output></Operation></Segment_15816659605667><SmartCover_1581665960539><Type>SmartCover</Type><Operation><TemplateId>t16e81a29fe48c4e23acefc247a7792b63</TemplateId><Output><Region>ap-chongqing</Region><Bucket>test-1234567890</Bucket><Object>abc/${RunId}/cover-${Number}.{Ext}</Object></Output></Operation></SmartCover_1581665960539><PicProcess_15816659605668><Type>PicProcess</Type><Operation><TemplateId>t1460606b9752148c4ab182f55163ba7cd</TemplateId><Output><Region>ap-chongqing</Region><Bucket>test-1234567890</Bucket><Object>bcd/${RunId}/pic.{Ext}</Object></Output></Operation></PicProcess_15816659605668></Nodes></Topology></MediaWorkflow></Response>
批量处理
请求语法
POST /inventorytriggerjob HTTP/1.1Host: <BucketName-APPID>.ci.<Region>.myqcloud.comDate: <GMT Date>Authorization: <Auth String>Content-Length: <length>Content-Type: application/xml
请求示例:提交一个音视频转码批量任务
POST /inventorytriggerjob 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><Name>demo</Name><Type>Job</Type><Input><Prefix>input</Prefix></Input><Operation><TimeInterval><Start>2022-02-01T12:00:00+0800</Start><End>2022-05-01T12:00:00+0800</End></TimeInterval><UserData>this is my inventorytriggerjob</UserData><CallBack>https://www.callback.com</CallBack><Tag>Transcode</Tag><JobParam><TemplateId>t1460606b9752148c4ab182f55163ba7cd</TemplateId></JobParam><Output><Region>ap-chongqing</Region><Bucket>test-1234567890</Bucket><Object>output/${InventoryTriggerJobId}/out.mp4</Object></Output><JobLevel>0</JobLevel></Operation></Request>
返回
HTTP/1.1 200 OKContent-Type: application/xmlContent-Length: 230Connection: keep-aliveDate: Mon, 28 Jun 2022 15:23:12 GMTServer: tencent-cix-ci-request-id: NjJiZDU1ZmZfOTBmYTUwNjRfNzdjY18xYQ==<Response><RequestId>NjJiZDU1ZmZfOTBmYTUwNjRfNzdjY18xYQ==<RequestId><JobsDetail><Code>Success</Code><Type>Job</Type><Message/><Name>demo</Name><JobId>be8f65004eb8511eaaed4f377124a303c</JobId><State>Running</State><CreationTime>2022-06-27T15:23:10+0800</CreationTime><StartTime>2022-06-27T15:23:11+0800</StartTime><EndTime>2022-06-27T15:25:10+0800</EndTime><Input><Prefix>input</Prefix></Input><Operation><TimeInterval><Start>2022-02-01T12:00:00+0800</Start><End>2022-05-01T12:00:00+0800</End></TimeInterval><QueueId>p893bcda225bf4945a378da6662e81a89</QueueId><UserData>this is my inventorytriggerjob</UserData><CallBack>https://www.callback.com</CallBack><Tag>Transcode</Tag><JobParam><TemplateId>t1460606b9752148c4ab182f55163ba7cd</TemplateId></JobParam><Output><Region>ap-chongqing</Region><Bucket>test-1234567890</Bucket><Object>output/${InventoryTriggerJobId}/out.mp4</Object></Output><JobLevel>0</JobLevel></Operation></JobsDetail></Response>
同步任务
请求示例1:通过 GET 请求方式
https://<BucketName-APPID>.cos.<Region>.myqcloud.com/for-test.mp4?ci-process=snapshot&time=1&format=jpg&<Auth String>
请求示例2:通过 URL 地址添加参数方式
GET /<ObjectKey>?ci-process=snapshot&time=1&format=jpg HTTP/1.1Host: <BucketName-APPID>.cos.<Region>.myqcloud.comDate: <GMT Date>Authorization: <Auth String>Content-Length: <length>