全部产品

转码任务

本篇文档提供了Java SDK转码任务模块相关功能的API调用示例。包含查询视频转码摘要、查询转码任务列表、查询转码任务详情。

初始化客户端

使用前请先初始化客户端,请参见初始化

查询视频转码摘要

调用GetTranscodeSummary接口,完成查询视频转码摘要功能。

接口参数和返回字段请参见GetTranscodeSummary。调用示例如下:

import com.aliyuncs.vod.model.v20170321.GetTranscodeSummaryRequest;
import com.aliyuncs.vod.model.v20170321.GetTranscodeSummaryResponse;

/**
 * 查询视频转码摘要信息
 */
public static GetTranscodeSummaryResponse getTranscodeSummary(DefaultAcsClient client) throws Exception {
    GetTranscodeSummaryRequest request = new GetTranscodeSummaryRequest();
    request.setVideoIds("14f35e2c5ca348831c2d2ae1d5b****,1dd4516420d247c777538c9aaa****");
    return client.getAcsResponse(request);
}


/**
 * 以下为调用示例
 */
public static void main(String[] args) throws ClientException {
    DefaultAcsClient client = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
    GetTranscodeSummaryResponse response = new GetTranscodeSummaryResponse();
    try {
        response = getTranscodeSummary(client);
        for (GetTranscodeSummaryResponse.TranscodeSummary summary : response.getTranscodeSummaryList()) {
            //转码状态
            System.out.println("TranscodeStatus = " + summary.getTranscodeStatus());
            for (GetTranscodeSummaryResponse.TranscodeSummary.TranscodeJobInfoSummary jobInfoSummary : summary.getTranscodeJobInfoSummaryList()) {
                //转码进度
                System.out.println("TranscodeProgress = " + jobInfoSummary.getTranscodeProgress());
                //转码作业状态
                System.out.println("TranscodeJobStatus = " + jobInfoSummary.getTranscodeJobStatus());
                //转码作业完成时间
                System.out.println("CompleteTime = " + jobInfoSummary.getCompleteTime());
            }
        }
    } catch (Exception e) {
        System.out.println("ErrorMessage = " + e.getLocalizedMessage());
    }
    System.out.println("RequestId = " + response.getRequestId());
}

查询转码任务列表

调用ListTranscodeTask接口,完成查询转码任务列表功能。

接口参数和返回字段请参见ListTranscodeTask。调用示例如下:

import com.aliyuncs.vod.model.v20170321.ListTranscodeTaskRequest;
import com.aliyuncs.vod.model.v20170321.ListTranscodeTaskResponse;

/**
 * 查询转码任务列表
 */
public static ListTranscodeTaskResponse listTranscodeTask(DefaultAcsClient client) throws Exception {
    ListTranscodeTaskRequest request = new ListTranscodeTaskRequest();
    request.setVideoId("14f35e2c5ca345cb88de1d5b2801");
    return client.getAcsResponse(request);
}


/**
 * 以下为调用示例
 */
public static void main(String[] args) throws ClientException {
    DefaultAcsClient client = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
    ListTranscodeTaskResponse response = new ListTranscodeTaskResponse();
    try {
        response = listTranscodeTask(client);
        for (ListTranscodeTaskResponse.TranscodeTask transcodeTask : response.getTranscodeTaskList()) {
            //转码任务ID
            System.out.println("TranscodeTaskId = " + transcodeTask.getTranscodeTaskId());
            //转码任务状态
            System.out.println("TaskStatus = " + transcodeTask.getTaskStatus());
        }
    } catch (Exception e) {
        System.out.println("ErrorMessage = " + e.getLocalizedMessage());
    }
    System.out.println("RequestId = " + response.getRequestId());
}

查询转码任务详情

调用GetTranscodeTask接口,完成查询转码任务详情功能。

接口参数和返回字段请参见GetTranscodeTask。调用示例如下:

import com.aliyuncs.vod.model.v20170321.GetTranscodeTaskRequest;
import com.aliyuncs.vod.model.v20170321.GetTranscodeTaskResponse;

/**
 * 查询转码任务详情
 */
public static GetTranscodeTaskResponse getTranscodeTask(DefaultAcsClient client) throws Exception {
    GetTranscodeTaskRequest request = new GetTranscodeTaskRequest();
    request.setTranscodeTaskId("eab6f992b5f9436e6f425****");
    return client.getAcsResponse(request);
}


/**
 * 以下为调用示例
 */
public static void main(String[] args) throws ClientException {
    DefaultAcsClient client = initVodClient("<Your AccessKeyId>", "<Your AccessKeySecret>");
    GetTranscodeTaskResponse response = new GetTranscodeTaskResponse();
    try {
        response = getTranscodeTask(client);
        //转码任务ID
        System.out.println("TranscodeTaskId = " + response.getTranscodeTask().getTranscodeTaskId());
        //转码任务状态
        System.out.println("TaskStatus = " + response.getTranscodeTask().getTaskStatus());
        for (GetTranscodeTaskResponse.TranscodeTask.TranscodeJobInfo jobInfo : response.getTranscodeTask().getTranscodeJobInfoList()) {
            //转码作业ID
            System.out.println("TranscodeJobId = " + jobInfo.getTranscodeJobId());
            //转码作业状态
            System.out.println("TranscodeJobStatus = " + jobInfo.getTranscodeJobStatus());
            //转码处理进度
            System.out.println("TranscodeProgress = " + jobInfo.getTranscodeProgress());
            //转码作业完成时间
            System.out.println("CompleteTime = " + jobInfo.getCompleteTime());

        }
    } catch (Exception e) {
        System.out.println("ErrorMessage = " + e.getLocalizedMessage());
    }
    System.out.println("RequestId = " + response.getRequestId());
}