全部产品
云市场

视频DNA

更新时间:2018-12-31 23:37:05

初始化客户端

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

提交视频DNA作业

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

  1. package main
  2. import (
  3. "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
  4. "github.com/aliyun/alibaba-cloud-sdk-go/services/vod"
  5. "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
  6. "fmt"
  7. )
  8. func MySubmitAIJob(client *vod.Client) (response *vod.SubmitAIJobResponse, err error) {
  9. request := vod.CreateSubmitAIJobRequest()
  10. // 视频ID
  11. request.MediaId = "<VideoId>"
  12. // 设置AI类型,类型为固定值 AIMediaDNA
  13. request.Types = "AIMediaDNA"
  14. request.AcceptFormat = "JSON"
  15. return client.SubmitAIJob(request)
  16. }
  17. func main() {
  18. client, err := InitVodClient("<accessKeyId>", "<accessKeySecret>")
  19. if err != nil {
  20. panic(err)
  21. }
  22. response, err := MySubmitAIJob(client)
  23. if err != nil {
  24. panic(err)
  25. }
  26. fmt.Println(response.GetHttpContentString())
  27. fmt.Println(response.RequestId)
  28. for _, job := range response.AIJobList.AIJob {
  29. fmt.Printf("%s: %s\n", job.Type, job.JobId)
  30. }
  31. }

查询视频DNA作业

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

  1. package main
  2. import (
  3. "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
  4. "github.com/aliyun/alibaba-cloud-sdk-go/services/vod"
  5. "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
  6. "fmt"
  7. )
  8. func MyListAIJob(client *vod.Client) (response *vod.ListAIJobResponse, err error) {
  9. request := vod.CreateListAIJobRequest()
  10. // 视频AI作业ID,多个用逗号分隔
  11. request.JobIds = "JobId1,JobId2"
  12. request.AcceptFormat = "JSON"
  13. return client.ListAIJob(request)
  14. }
  15. func main() {
  16. client, err := InitVodClient("<accessKeyId>", "<accessKeySecret>")
  17. if err != nil {
  18. panic(err)
  19. }
  20. response, err := MyListAIJob(client)
  21. if err != nil {
  22. panic(err)
  23. }
  24. fmt.Println(response.GetHttpContentString())
  25. fmt.Println(response.RequestId)
  26. for _, job := range response.AIJobList.AIJob {
  27. fmt.Printf("%s: %s %s\n", job.JobId, job.Status, job.Data)
  28. }
  29. }

获取视频DNA结果

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

  1. package main
  2. import (
  3. "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
  4. "github.com/aliyun/alibaba-cloud-sdk-go/services/vod"
  5. "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
  6. "fmt"
  7. )
  8. func MyGetMediaDNAResult(client *vod.Client) (response *vod.GetMediaDNAResultResponse, err error) {
  9. request := vod.CreateGetMediaDNAResultRequest()
  10. // 视频ID
  11. request.MediaId = "<VideoId>"
  12. request.AcceptFormat = "JSON"
  13. return client.GetMediaDNAResult(request)
  14. }
  15. func main() {
  16. client, err := InitVodClient("<accessKeyId>", "<accessKeySecret>")
  17. if err != nil {
  18. panic(err)
  19. }
  20. response, err := MyGetMediaDNAResult(client)
  21. if err != nil {
  22. panic(err)
  23. }
  24. fmt.Println(response.GetHttpContentString())
  25. fmt.Println(response.RequestId)
  26. }