全部产品
云市场

视频DNA

更新时间:2018-12-27 13:29:43

初始化客户端

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

提交视频DNA作业

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

  1. import com.aliyuncs.vod.model.v20170321.SubmitAIJobRequest;
  2. import com.aliyuncs.vod.model.v20170321.SubmitAIJobResponse;
  3. /**
  4. * 提交作业
  5. */
  6. public static SubmitAIJobResponse submitAIJob(DefaultAcsClient client) throws Exception {
  7. SubmitAIJobRequest request = new SubmitAIJobRequest();
  8. // 设置视频ID
  9. request.setMediaId("3eb19a4585bc475e995bddxxxxxxxx");
  10. // 设置AI类型,类型为AIMediaDNA
  11. request.setTypes("AIMediaDNA");
  12. // 返回结果
  13. return client.getAcsResponse(request);
  14. }
  15. /**
  16. * 以下为调用示例
  17. * @param args
  18. * @throws ClientException
  19. */
  20. public static void main(String[] args) throws ClientException {
  21. DefaultAcsClient client = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  22. try {
  23. // 提交作业
  24. SubmitAIJobResponse response = submitAIJob(client);
  25. // 打印请求ID
  26. System.out.println("ResquestId:" + response.getRequestId());
  27. // 打印结果信息
  28. if (response.getAIJobList() != null && response.getAIJobList().size() != 0) {
  29. for (SubmitAIJobResponse.AIJob aiJob : response.getAIJobList()) {
  30. // 视频ID
  31. System.out.println("MediaId:" + aiJob.getMediaId());
  32. // 作业ID
  33. System.out.println("JobId:" + aiJob.getJobId());
  34. // AI类型
  35. System.out.println("Type:" + aiJob.getType());
  36. }
  37. }
  38. } catch (Exception e) {
  39. System.out.println("ErrorMessage:" + e.getLocalizedMessage());
  40. }
  41. }

查询视频DNA作业

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

  1. import com.aliyuncs.vod.model.v20170321.ListAIJobRequest;
  2. import com.aliyuncs.vod.model.v20170321.ListAIJobResponse;
  3. /**
  4. * 查询作业
  5. */
  6. public static ListAIJobResponse listAIJob(DefaultAcsClient client) throws Exception {
  7. ListAIJobRequest request = new ListAIJobRequest();
  8. // 设置作业ID
  9. request.setJobIds("979d4d7a36ae41b1a945a2xxxxx,3eb19a4585bc475e995bddeaxxxxx");
  10. // 返回结果
  11. return client.getAcsResponse(request);
  12. }
  13. /**
  14. * 以下为调用示例
  15. * @param args
  16. * @throws ClientException
  17. */
  18. public static void main(String[] args) throws Exception {
  19. DefaultAcsClient client = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  20. try {
  21. // 查询作业
  22. ListAIJobResponse response = listAIJob(client);
  23. // 打印请求ID
  24. System.out.println("ResquestId:" + response.getRequestId());
  25. // 打印作业列表
  26. System.out.println("============ AIJobList:");
  27. if (response.getAIJobList() != null && response.getAIJobList().size() != 0) {
  28. for (ListAIJobResponse.AIJob aiJob: response.getAIJobList()) {
  29. // 视频ID
  30. System.out.println("MediaId:" + aiJob.getMediaId());
  31. // 作业ID
  32. System.out.println("JobId:" + aiJob.getJobId());
  33. // AI类型,注意校验类型是否为AIMediaDNA
  34. System.out.println("Type:" + aiJob.getType());
  35. // 作业状态
  36. System.out.println("Status:" + aiJob.getStatus());
  37. // 作业结果
  38. System.out.println("Data:" + aiJob.getData());
  39. }
  40. }
  41. // 打印不存在的作业ID
  42. System.out.println("============ NonExistAIJobIds:");
  43. if (response.getNonExistAIJobIds() != null && response.getNonExistAIJobIds().size() != 0) {
  44. for (String jobId: response.getNonExistAIJobIds()) {
  45. // 作业ID
  46. System.out.println("NonExistAIJobId:" + jobId);
  47. }
  48. }
  49. } catch (Exception e) {
  50. System.out.println("ErrorMessage:" + e.getLocalizedMessage());
  51. }
  52. }

获取视频DNA结果

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

  1. import com.aliyuncs.vod.model.v20170321.GetMediaDNAResultRequest;
  2. import com.aliyuncs.vod.model.v20170321.GetMediaDNAResultResponse;
  3. /**
  4. * 查询结果
  5. */
  6. public static GetMediaDNAResultResponse getMediaDNAResult(DefaultAcsClient client) throws Exception {
  7. GetMediaDNAResultRequest request = new GetMediaDNAResultRequest();
  8. // 设置视频ID
  9. request.setMediaId("3eb19a4585bc475e995bddxxxxxxxx");
  10. // 返回结果
  11. return client.getAcsResponse(request);
  12. }
  13. /**
  14. * 以下为调用示例
  15. * @param args
  16. * @throws ClientException
  17. */
  18. public static void main(String[] args) throws Exception {
  19. DefaultAcsClient client = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  20. try {
  21. // 查询结果
  22. GetMediaDNAResultResponse response = getMediaDNAResult(client);
  23. // 打印请求ID
  24. System.out.println("ResquestId:" + response.getRequestId());
  25. // 打印DNA结果
  26. System.out.println("DNAResult:" + response.getDNAResult().toString());
  27. } catch (Exception e) {
  28. System.out.println("ErrorMessage:" + e.getLocalizedMessage());
  29. }
  30. }