全部产品
云市场

视频AI

更新时间:2019-01-30 17:13:53

初始化客户端

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

提交AI作业

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

  1. // 调用样例
  2. var client = initVodClient('<Your AccessKeyId>','<Your AccessKeySecret>');
  3. client.request("SubmitAIJob", {
  4. MediaId: '3eb19a4585bc475e995bddxxxxxxxx',
  5. Types: 'AIVideoCover'
  6. }, {}).then(function (response) {
  7. if (response.AIJobList && response.AIJobList.AIJob && response.AIJobList.AIJob.length > 0){
  8. for(var i=0; i<response.AIJobList.AIJob.length; i++){
  9. var job = response.AIJobList.AIJob[i];
  10. // 视频ID
  11. console.log('MediaId = ' + job.MediaId);
  12. // 作业ID
  13. console.log('JobId = ' + job.JobId);
  14. // AI类型
  15. console.log('Type = ' + job.Type);
  16. }
  17. }
  18. console.log('RequestId = ' + response.RequestId);
  19. }).catch(function (response) {
  20. console.log('ErrorCode = ' + response.data.Code);
  21. console.log('ErrorMessage = ' + response.data.Message);
  22. console.log('RequestId = ' + response.data.RequestId);
  23. });

查询AI作业

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

  1. // 调用样例
  2. var client = initVodClient('<Your AccessKeyId>','<Your AccessKeySecret>');
  3. client.request("ListAIJob", {
  4. JobIds: 'JobId1,JobId2'
  5. }, {}).then(function (response) {
  6. // 打印作业列表
  7. console.log("============ AIJobList ============");
  8. if (response.AIJobList && response.AIJobList.AIJob && response.AIJobList.AIJob.length > 0){
  9. for(var i=0; i<response.AIJobList.AIJob.length; i++){
  10. var job = response.AIJobList.AIJob[i];
  11. // 视频ID
  12. console.log('MediaId = ' + job.MediaId);
  13. // 作业ID
  14. console.log('JobId = ' + job.JobId);
  15. // AI类型
  16. console.log('Type = ' + job.Type);
  17. // 作业状态
  18. console.log('Status = ' + job.Status);
  19. // 作业结果
  20. console.log('Data = ' + job.Data);
  21. }
  22. }
  23. // 打印不存在的作业ID
  24. console.log("============ NonExistAIJobIds ============");
  25. if (response.NonExistAIJobIds && response.NonExistAIJobIds.String && response.NonExistAIJobIds.String.length > 0) {
  26. for (var i=0; i<response.NonExistAIJobIds.String.length; i++) {
  27. // 作业ID
  28. console.log('NonExistAIJobId = ' + response.NonExistAIJobIds.String[i]);
  29. }
  30. }
  31. console.log('RequestId = ' + response.RequestId);
  32. }).catch(function (response) {
  33. console.log('ErrorCode = ' + response.data.Code);
  34. console.log('ErrorMessage = ' + response.data.Message);
  35. console.log('RequestId = ' + response.data.RequestId);
  36. });

添加AI模板

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

  1. // 调用样例
  2. var client = initVodClient('<Your AccessKeyId>','<Your AccessKeySecret>');
  3. // 模板详细配置, 以审核模版为例
  4. var templateConfig = {
  5. AuditAutoBlock: "no",
  6. AuditContent: ["screen"],
  7. AuditRange:["video", "image-cover", "text-title"],
  8. AuditItem: ["terrorism", "porn"]
  9. };
  10. client.request("AddAITemplate", {
  11. TemplateType: 'AIMediaAudit', // 设置模板类型,以智能审核模板为例
  12. TemplateName: 'myaitemplate', // 设置模板名称
  13. TemplateConfig: JSON.stringify(templateConfig) // 设置模板详细配置
  14. }, {}).then(function (response) {
  15. console.log(response);
  16. console.log('RequestId = ' + response.RequestId);
  17. }).catch(function (response) {
  18. console.log('ErrorCode = ' + response.data.Code);
  19. console.log('ErrorMessage = ' + response.data.Message);
  20. console.log('RequestId = ' + response.data.RequestId);
  21. });

删除AI模板

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

  1. // 调用样例
  2. var client = initVodClient('<Your AccessKeyId>','<Your AccessKeySecret>');
  3. client.request("DeleteAITemplate", {
  4. TemplateId: 'xxxxxx577351656804e10113d7xxxxxx' // 设置模板ID
  5. }, {}).then(function (response) {
  6. console.log('TemplateId = ' + response.TemplateId);
  7. console.log('RequestId = ' + response.RequestId);
  8. }).catch(function (response) {
  9. console.log('ErrorCode = ' + response.data.Code);
  10. console.log('ErrorMessage = ' + response.data.Message);
  11. console.log('RequestId = ' + response.data.RequestId);
  12. });

修改AI模板

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

  1. // 调用样例
  2. var client = initVodClient('<Your AccessKeyId>','<Your AccessKeySecret>');
  3. // 模板详细配置, 以审核模版为例
  4. var templateConfig = {
  5. AuditAutoBlock: "no",
  6. AuditContent: ["screen"],
  7. AuditRange:["video", "image-cover"],
  8. AuditItem: ["terrorism", "porn"]
  9. };
  10. client.request("UpdateAITemplate", {
  11. TemplateId: 'xxxxxx577351656804e10113d7xxxxxx', // 模板ID
  12. TemplateName: 'myaitemplatemodify', // 模板名称
  13. TemplateConfig: JSON.stringify(templateConfig) // 模板详细配置
  14. }, {}).then(function (response) {
  15. console.log('TemplateId = ' + response.TemplateId);
  16. console.log('RequestId = ' + response.RequestId);
  17. }).catch(function (response) {
  18. console.log('ErrorCode = ' + response.data.Code);
  19. console.log('ErrorMessage = ' + response.data.Message);
  20. console.log('RequestId = ' + response.data.RequestId);
  21. });

查询AI模板

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

  1. // 调用样例
  2. var client = initVodClient('<Your AccessKeyId>','<Your AccessKeySecret>');
  3. client.request("GetAITemplate", {
  4. TemplateId: 'xxxxxx577351656804e10113d7xxxxxx' // 模板ID
  5. }, {}).then(function (response) {
  6. console.log(response);
  7. // 模板信息
  8. if (response.TemplateInfo){
  9. console.log('TemplateId = ' + response.TemplateInfo.TemplateId);
  10. console.log('TemplateType = ' + response.TemplateInfo.TemplateType);
  11. console.log('TemplateName = ' + response.TemplateInfo.TemplateName);
  12. console.log('TemplateConfig = ' + response.TemplateInfo.TemplateConfig);
  13. }
  14. console.log('RequestId = ' + response.RequestId);
  15. }).catch(function (response) {
  16. console.log('ErrorCode = ' + response.data.Code);
  17. console.log('ErrorMessage = ' + response.data.Message);
  18. console.log('RequestId = ' + response.data.RequestId);
  19. });

查询AI模板列表

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

  1. // 调用样例
  2. var client = initVodClient('<Your AccessKeyId>','<Your AccessKeySecret>');
  3. client.request("ListAITemplate", {
  4. TemplateType: 'AIMediaAudit' // 模板类型
  5. }, {}).then(function (response) {
  6. console.log(response);
  7. // 模板信息列表
  8. if (response.TemplateInfoList && response.TemplateInfoList.length > 0){
  9. for (var i=0; i<response.TemplateInfoList.length; i++){
  10. console.log("The " + i + " Template.");
  11. console.log('TemplateId = ' + response.TemplateInfoList[i].TemplateId);
  12. console.log('TemplateType = ' + response.TemplateInfoList[i].TemplateType);
  13. console.log('TemplateName = ' + response.TemplateInfoList[i].TemplateName);
  14. console.log('TemplateConfig = ' + response.TemplateInfoList[i].TemplateConfig);
  15. }
  16. }
  17. console.log('RequestId = ' + response.RequestId);
  18. }).catch(function (response) {
  19. console.log('ErrorCode = ' + response.data.Code);
  20. console.log('ErrorMessage = ' + response.data.Message);
  21. console.log('RequestId = ' + response.data.RequestId);
  22. });

设置默认AI模板

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

  1. // 调用样例
  2. var client = initVodClient('<Your AccessKeyId>','<Your AccessKeySecret>');
  3. client.request("SetDefaultAITemplate", {
  4. TemplateId: 'xxxxxxd72e9e3d576159ed42d5xxxxxx' // 模板ID
  5. }, {}).then(function (response) {
  6. console.log('TemplateId = ' + response.TemplateId);
  7. console.log('RequestId = ' + response.RequestId);
  8. }).catch(function (response) {
  9. console.log('ErrorCode = ' + response.data.Code);
  10. console.log('ErrorMessage = ' + response.data.Message);
  11. console.log('RequestId = ' + response.data.RequestId);
  12. });

查询默认AI模板

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

  1. // 调用样例
  2. var client = initVodClient('<Your AccessKeyId>','<Your AccessKeySecret>');
  3. client.request("GetDefaultAITemplate", {
  4. TemplateType: 'AIMediaAudit' // 模板类型
  5. }, {}).then(function (response) {
  6. if (response.TemplateInfo){
  7. console.log('TemplateId = ' + response.TemplateInfo.TemplateId);
  8. console.log('TemplateType = ' + response.TemplateInfo.TemplateType);
  9. console.log('TemplateName = ' + response.TemplateInfo.TemplateName);
  10. console.log('IsDefault = ' + response.TemplateInfo.IsDefault);
  11. console.log('TemplateConfig = ' + response.TemplateInfo.TemplateConfig);
  12. }
  13. console.log('RequestId = ' + response.RequestId);
  14. }).catch(function (response) {
  15. console.log('ErrorCode = ' + response.data.Code);
  16. console.log('ErrorMessage = ' + response.data.Message);
  17. console.log('RequestId = ' + response.data.RequestId);
  18. });