媒体转码的转码任务是异步的接口,提交转码任务后,可以通过两种方式获得任务的执行状态:
1、通过轮询的方式,查询转码任务状态:
通过查询转码作业(QueryJobList),可以获取转码任务的状态,根据返回值的state字段的值,可以判断任务当前的状态:
{ "QueryJobListResponse":{ "RequestId":"58CBF1B8-048C-4550-B59C-F6EA57A8CEB6", "JobList": { "Job": [{ "JobId": "31fa3c9ca8134f9cec2b4b0b0f787830", "Input": { "Bucket": "example-bucket", "Location": "oss-cn-hangzhou", "Object": "example.flv" }, "Output": { "OutputFile": { "Bucket": "example-bucket", "Location": "oss-cn-hangzhou", "Object": "example-output.flv" }, "TemplateId": "0001-01", "WaterMarkList": { "WaterMark": [{ "InputFile": { "Bucket": "example-bucket", "Location": "oss-cn-hangzhou", "Object": "example-logo.png" }, "WaterMarkTemplateId": "88c6ca184c0e47098a5b665e2a126797" }] }, "Properties":{ "Streams":{ "VideoStreamList":{ "VideoStream":[ { "Index":"1", "CodecName":"h264", "CodecLongName":"H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10", "Profile":"High", "CodecTimeBase":"1001/48000", "CodecTagString":"[0][0][0][0]", "CodecTag":"0x0000", "Width":"1920", "Height":"1080", "HasBFrames":"1", "Sar":"1:1", "Dar":"16:9", "PixFmt":"yuv420p", "Level":"41", "Fps":"25", "AvgFPS":"24000/1001", "Timebase":"1/1000", "StartTime":"0.042000", "Duration":"100", "Bitrate":"30541090", "NumFrames":"100", "Lang":"eng", "NetworkCost":{ "PreloadTime":"8", "CostBandwidth":"10", "AvgBitrate":"300.34" } } ] }, "AudioStreamList":{ "AudioStream":[ { "Index":"1", "CodecName":"dca", "CodecTimeBase":"1/48000", "CodecLongName":"DCA (DTS Coherent Acoustics)", "CodecTagString":"[0][0][0][0]", "CodecTag":"0x0000", "SampleFmt":"fltp", "Samplerate":"48000", "Channels":"2", "ChannelLayout":"5.1(side)", "Timebase":"1/1000", "StartTime":"0.042000", "Duration":"123", "Bitrate":"1536000", "NumFrames":"123", "Lang":"eng" } ] }, "SubtitleStreamList":{ "SubtitleStream":[ { "Index":"3", "Lang":"eng" } ] } }, "Format":{ "NumStreams":"1", "NumPrograms":"2", "FormatName":"matroska,webm", "FormatLongName":"Matroska / WebM", "StartTime":"0.042000", "Duration":"17.600000", "Size":"70569598", "Bitrate":"32077090" } }, "UserData":"testid-001" }, "State": "Submitted", "Code": "", "Message": "", "Percent": 0, "PipelineId": "88c6ca184c0e47098a5b665e2a126797", "CreationTime":"2014-01-10T12:00:00Z" }] } } } 具体的作业状态:Submitted表示作业已提交,Transcoding表示转码中,TranscodeSuccess表示转码成功,TranscodeFail表示转码失败,TranscodeCancelled表示转码取消
接口的详细说明参见:
https://help.aliyun.com/document_detail/mts/api-reference/trans-ossfile/QueryJobList.html?spm=5176.product8315085_mts.6.103.Y5Yh1N
2、利用消息通知功能,接收转码任务结果:
转码作业结束时,媒体转码会利用MNS的消息通知功能,向客户配置的URL推送任务执行信息。
详细配置方法说明参见:【点此查看】
HTTP的消息接收服务 Java 实现示例:【点此下载】
如果问题还未能解决,请联系售后技术支持。
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。