全部产品
云市场

视频DNA

更新时间:2018-12-29 11:43:47

初始化客户端

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

提交作业

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

  1. using System;
  2. using Aliyun.Acs.Core;
  3. using Aliyun.Acs.Core.Exceptions;
  4. using Aliyun.Acs.vod.Model.V20170321;
  5. namespace Aliyun.Acs.vod.Sdk.SubmitAIJob
  6. {
  7. class MainClass
  8. {
  9. public static void Main(string[] args)
  10. {
  11. try
  12. {
  13. // 构造请求
  14. SubmitAIJobRequest request = new SubmitAIJobRequest();
  15. // 设置视频ID
  16. request.MediaId = "3eb19a4585bc475e995bddxxxxxxxx";
  17. // 设置AI类型,类型为AIMediaDNA
  18. request.Types = "AIMediaDNA";
  19. // 初始化客户端
  20. DefaultAcsClient client = InitVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  21. // 发起请求,并得到 response
  22. SubmitAIJobResponse response = client.GetAcsResponse(request);
  23. // 请求ID
  24. Console.WriteLine("RequestId = " + response.RequestId);
  25. if (response.AIJobList != null && response.AIJobList.Count > 0)
  26. {
  27. foreach (var job in response.AIJobList)
  28. {
  29. // 视频ID
  30. Console.WriteLine("MediaId = " + job.MediaId);
  31. // 作业ID
  32. Console.WriteLine("JobId = " + job.JobId);
  33. // AI类型
  34. Console.WriteLine("Type = " + job.Type);
  35. }
  36. }
  37. }
  38. catch (ServerException e)
  39. {
  40. if (e.RequestId != null)
  41. {
  42. Console.WriteLine("RequestId = " + e.RequestId);
  43. }
  44. Console.WriteLine("ErrorCode = " + e.ErrorCode);
  45. Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
  46. }
  47. catch (ClientException e)
  48. {
  49. if (e.RequestId != null)
  50. {
  51. Console.WriteLine("RequestId = " + e.RequestId);
  52. }
  53. Console.WriteLine("ErrorCode = " + e.ErrorCode);
  54. Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
  55. }
  56. catch (Exception e)
  57. {
  58. Console.WriteLine("ErrorMessage = " + e.ToString());
  59. }
  60. }
  61. }
  62. }

查询作业

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

  1. using System;
  2. using Aliyun.Acs.Core;
  3. using Aliyun.Acs.Core.Exceptions;
  4. using Aliyun.Acs.vod.Model.V20170321;
  5. namespace Aliyun.Acs.vod.Sdk.ListAIJob
  6. {
  7. class MainClass
  8. {
  9. public static void Main(string[] args)
  10. {
  11. try
  12. {
  13. // 构造请求
  14. ListAIJobRequest request = new ListAIJobRequest();
  15. // 设置视频ID
  16. request.JobIds = "979d4d7a36ae41b1a945a2xxxxx,3eb19a4585bc475e995bddeaxxxxx";
  17. // 初始化客户端
  18. DefaultAcsClient client = InitVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  19. // 发起请求,并得到 response
  20. ListAIJobResponse response = client.GetAcsResponse(request);
  21. // 请求ID
  22. Console.WriteLine("RequestId = " + response.RequestId);
  23. // 打印作业列表
  24. if (response.AIJobList != null && response.AIJobList.Count > 0)
  25. {
  26. foreach (var job in response.AIJobList)
  27. {
  28. // 视频ID
  29. Console.WriteLine("MediaId = " + job.MediaId);
  30. // 作业ID
  31. Console.WriteLine("JobId = " + job.JobId);
  32. // AI类型
  33. Console.WriteLine("Type = " + job.Type);
  34. // 作业状态
  35. Console.WriteLine("Status = " + job.Status);
  36. // 作业结果
  37. Console.WriteLine("Data = " + job.Data);
  38. }
  39. }
  40. // 打印不存在的作业ID
  41. if (response.NonExistAIJobIds != null && response.NonExistAIJobIds.Count > 0)
  42. {
  43. foreach(jobId in response.NonExistAIJobIds)
  44. {
  45. // 作业ID
  46. Console.WriteLine("JobId = " + jobId);
  47. }
  48. }
  49. }
  50. catch (ServerException e)
  51. {
  52. if (e.RequestId != null)
  53. {
  54. Console.WriteLine("RequestId = " + e.RequestId);
  55. }
  56. Console.WriteLine("ErrorCode = " + e.ErrorCode);
  57. Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
  58. }
  59. catch (ClientException e)
  60. {
  61. if (e.RequestId != null)
  62. {
  63. Console.WriteLine("RequestId = " + e.RequestId);
  64. }
  65. Console.WriteLine("ErrorCode = " + e.ErrorCode);
  66. Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
  67. }
  68. catch (Exception e)
  69. {
  70. Console.WriteLine("ErrorMessage = " + e.ToString());
  71. }
  72. }
  73. }
  74. }

查询结果

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

  1. using System;
  2. using Aliyun.Acs.Core;
  3. using Aliyun.Acs.Core.Exceptions;
  4. using Aliyun.Acs.vod.Model.V20170321;
  5. namespace GetMediaDNAResult
  6. {
  7. class MainClass
  8. {
  9. public static void Main(string[] args)
  10. {
  11. try
  12. {
  13. // 构造请求
  14. GetMediaDNAResultRequest request = new GetMediaDNAResultRequest();
  15. // 设置视频ID
  16. request.MediaId = "3eb19a4585bc475e995bdd62eaee0***1";
  17. // 初始化客户端
  18. DefaultAcsClient client = InitVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
  19. // 发起请求,并得到 response
  20. GetMediaDNAResultResponse response = client.GetAcsResponse(request);
  21. // 请求ID
  22. Console.WriteLine("RequestId = " + response.RequestId);
  23. if (response.DNAResult != null)
  24. {
  25. // 打印DNA结果
  26. Console.WriteLine("DNAResult = " + response.DNAResult.ToString());
  27. }
  28. }
  29. catch (ServerException e)
  30. {
  31. if (e.RequestId != null)
  32. {
  33. Console.WriteLine("RequestId = " + e.RequestId);
  34. }
  35. Console.WriteLine("ErrorCode = " + e.ErrorCode);
  36. Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
  37. }
  38. catch (ClientException e)
  39. {
  40. if (e.RequestId != null)
  41. {
  42. Console.WriteLine("RequestId = " + e.RequestId);
  43. }
  44. Console.WriteLine("ErrorCode = " + e.ErrorCode);
  45. Console.WriteLine("ErrorMessage = " + e.ErrorMessage);
  46. }
  47. catch (Exception e)
  48. {
  49. Console.WriteLine("ErrorMessage = " + e.ToString());
  50. }
  51. }
  52. }
  53. }