全部产品
云市场

转码任务

更新时间:2019-03-05 15:54:57

初始化客户端

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

查询视频转码摘要

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

  1. import com.aliyuncs.vod.model.v20170321.GetTranscodeSummaryRequest;
  2. import com.aliyuncs.vod.model.v20170321.GetTranscodeSummaryResponse;
  3. /**
  4. * 查询视频转码摘要信息
  5. */
  6. public static GetTranscodeSummaryResponse getTranscodeSummary(DefaultAcsClient client) throws Exception {
  7. GetTranscodeSummaryRequest request = new GetTranscodeSummaryRequest();
  8. request.setVideoIds("14f35e2c5ca348831c2d2ae1d5b2801,1dd4516420d247c777538c9aaafb01");
  9. return client.getAcsResponse(request);
  10. }
  11. /**
  12. * 以下为调用示例
  13. */
  14. public static void main(String[] args) throws ClientException {
  15. DefaultAcsClient client = initVodClient("<您的AccessKeyId>", "<您的AccessKeySecret>");
  16. GetTranscodeSummaryResponse response = new GetTranscodeSummaryResponse();
  17. try {
  18. response = getTranscodeSummary(client);
  19. for (GetTranscodeSummaryResponse.TranscodeSummary summary : response.getTranscodeSummaryList()) {
  20. //转码状态
  21. System.out.println("TranscodeStatus = " + summary.getTranscodeStatus());
  22. for (GetTranscodeSummaryResponse.TranscodeSummary.TranscodeJobInfoSummary jobInfoSummary : summary.getTranscodeJobInfoSummaryList()) {
  23. //转码进度
  24. System.out.println("TranscodeProgress = " + jobInfoSummary.getTranscodeProgress());
  25. //转码作业状态
  26. System.out.println("TranscodeJobStatus = " + jobInfoSummary.getTranscodeJobStatus());
  27. //转码作业完成时间
  28. System.out.println("CompleteTime = " + jobInfoSummary.getCompleteTime());
  29. }
  30. }
  31. } catch (Exception e) {
  32. System.out.println("ErrorMessage = " + e.getLocalizedMessage());
  33. }
  34. System.out.println("RequestId = " + response.getRequestId());
  35. }

查询转码任务列表

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

  1. import com.aliyuncs.vod.model.v20170321.ListTranscodeTaskRequest;
  2. import com.aliyuncs.vod.model.v20170321.ListTranscodeTaskResponse;
  3. /**
  4. * 查询转码任务列表
  5. */
  6. public static ListTranscodeTaskResponse listTranscodeTask(DefaultAcsClient client) throws Exception {
  7. ListTranscodeTaskRequest request = new ListTranscodeTaskRequest();
  8. request.setVideoId("14f35e2c5ca345cb88de1d5b2801");
  9. return client.getAcsResponse(request);
  10. }
  11. /**
  12. * 以下为调用示例
  13. */
  14. public static void main(String[] args) throws ClientException {
  15. DefaultAcsClient client = initVodClient("<您的AccessKeyId>", "<您的AccessKeySecret>");
  16. ListTranscodeTaskResponse response = new ListTranscodeTaskResponse();
  17. try {
  18. response = listTranscodeTask(client);
  19. for (ListTranscodeTaskResponse.TranscodeTask transcodeTask : response.getTranscodeTaskList()) {
  20. //转码任务ID
  21. System.out.println("TranscodeTaskId = " + transcodeTask.getTranscodeTaskId());
  22. //转码任务状态
  23. System.out.println("TaskStatus = " + transcodeTask.getTaskStatus());
  24. }
  25. } catch (Exception e) {
  26. System.out.println("ErrorMessage = " + e.getLocalizedMessage());
  27. }
  28. System.out.println("RequestId = " + response.getRequestId());
  29. }

查询转码任务详情

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

  1. import com.aliyuncs.vod.model.v20170321.GetTranscodeTaskRequest;
  2. import com.aliyuncs.vod.model.v20170321.GetTranscodeTaskResponse;
  3. /**
  4. * 查询转码任务详情
  5. */
  6. public static GetTranscodeTaskResponse getTranscodeTask(DefaultAcsClient client) throws Exception {
  7. GetTranscodeTaskRequest request = new GetTranscodeTaskRequest();
  8. request.setTranscodeTaskId("eab6f992b5f9436e6f425a421");
  9. return client.getAcsResponse(request);
  10. }
  11. /**
  12. * 以下为调用示例
  13. */
  14. public static void main(String[] args) throws ClientException {
  15. DefaultAcsClient client = initVodClient("<您的AccessKeyId>", "<您的AccessKeySecret>");
  16. GetTranscodeTaskResponse response = new GetTranscodeTaskResponse();
  17. try {
  18. response = getTranscodeTask(client);
  19. //转码任务ID
  20. System.out.println("TranscodeTaskId = " + response.getTranscodeTask().getTranscodeTaskId());
  21. //转码任务状态
  22. System.out.println("TaskStatus = " + response.getTranscodeTask().getTaskStatus());
  23. for (GetTranscodeTaskResponse.TranscodeTask.TranscodeJobInfo jobInfo : response.getTranscodeTask().getTranscodeJobInfoList()) {
  24. //转码作业ID
  25. System.out.println("TranscodeJobId = " + jobInfo.getTranscodeJobId());
  26. //转码作业状态
  27. System.out.println("TranscodeJobStatus = " + jobInfo.getTranscodeJobStatus());
  28. //转码处理进度
  29. System.out.println("TranscodeProgress = " + jobInfo.getTranscodeProgress());
  30. //转码作业完成时间
  31. System.out.println("CompleteTime = " + jobInfo.getCompleteTime());
  32. }
  33. } catch (Exception e) {
  34. System.out.println("ErrorMessage = " + e.getLocalizedMessage());
  35. }
  36. System.out.println("RequestId = " + response.getRequestId());
  37. }