全部产品
云市场

视频DNA

更新时间:2018-12-27 12:16:58

初始化客户端

使用前请先初始化客户端,参考 init_vod_client 接口。

提交视频DNA作业

接口参数和返回字段请参考 SubmitAIJob

  1. from aliyunsdkvod.request.v20170321 import SubmitAIJobRequest
  2. def submit_ai_job(clt):
  3. request = SubmitAIJobRequest.SubmitAIJobRequest()
  4. request.set_MediaId('<videoId>') # 视频ID
  5. request.set_Types('AIMediaDNA') # 设置AI类型,类型为AIMediaDNA
  6. request.set_accept_format('JSON')
  7. response = json.loads(clt.do_action_with_exception(request))
  8. return response
  9. try:
  10. clt = init_vod_client('<AccessKeyId>', '<AccessKeySecret>')
  11. job = submit_ai_job(clt)
  12. print(json.dumps(job, ensure_ascii=False, indent=4))
  13. except Exception as e:
  14. print(e)
  15. print(traceback.format_exc())

查询视频DNA作业

接口参数和返回字段请参考 ListAIJob

  1. from aliyunsdkvod.request.v20170321 import ListAIJobRequest
  2. def list_ai_job(clt):
  3. request = ListAIJobRequest.ListAIJobRequest()
  4. jobIds = ['jobId1', 'jobId2']
  5. request.set_JobIds(','.join(jobIds))
  6. request.set_accept_format('JSON')
  7. response = json.loads(clt.do_action_with_exception(request))
  8. return response
  9. try:
  10. clt = init_vod_client('<AccessKeyId>', '<AccessKeySecret>')
  11. jobs = list_ai_job(clt)
  12. print(json.dumps(jobs, ensure_ascii=False, indent=4))
  13. except Exception as e:
  14. print(e)
  15. print(traceback.format_exc())

获取视频DNA结果

接口参数和返回字段请参考 GetMediaDNAResult

  1. from aliyunsdkvod.request.v20170321 import GetMediaDNAResultRequest
  2. def get_media_dna_result(clt):
  3. request = GetMediaDNAResultRequest.GetMediaDNAResultRequest()
  4. request.set_MediaId('<videoId>') # 视频ID
  5. request.set_accept_format('JSON')
  6. response = json.loads(clt.do_action_with_exception(request))
  7. return response
  8. try:
  9. clt = init_vod_client('<AccessKeyId>', '<AccessKeySecret>')
  10. dna = get_media_dna_result(clt)
  11. print(json.dumps(dna, ensure_ascii=False, indent=4))
  12. except Exception as e:
  13. print(e)
  14. print(traceback.format_exc())