Transcoding jobs

Updated at:

Initiate and query transcoding jobs in Intelligent Media Services by calling API operations with a server-side SDK.

Usage notes

To initiate a transcoding job, submit the job with the regionId, Inputs, and OutputGroups parameters. After the job is processed, you can use the returned JobId to query the job information.

Note the following about transcoding job parameters:

  • regionId is the region where the service is provided.

  • Inputs and OutputGroups files corresponding to OutputGroups must be in the same region regionId.

  • Obtain templateId from the transcoding template management page.

For complete parameter structure see MediaConvertJobConfig.

Note

For a list of supported regionId, please refer Service regions.

Sample code

To debug this operation online, visit the Alibaba Cloud OpenAPI Developer Portal.

package <your package>;

import com.aliyun.tea.*;

public class Sample {
    public static com.aliyun.ice20201109.Client createClient() throws Exception {
        com.aliyun.credentials.Client credential = new com.aliyun.credentials.Client();
        com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
                .setCredential(credential);
        config.endpoint = "ice.cn-shanghai.aliyuncs.com";
        return new com.aliyun.ice20201109.Client(config);
    }

    public static void main(String[] args_) throws Exception {
        
        com.aliyun.ice20201109.Client client = Sample.createClient();
        com.aliyun.ice20201109.models.SubmitMediaConvertJobRequest submitMediaConvertJobRequest = new com.aliyun.ice20201109.models.SubmitMediaConvertJobRequest()
                .setConfig("{\"Inputs\":[{\"InputFile\":{\"Type\":\"OSS\",\"Media\":\"http://<bucket name>.oss-cn-shanghai.aliyuncs.com/input/**/60min.mp4\"}}],\"OutputGroups\":[{\"GroupConfig\":{\"Type\":\"File\",\"OutputFileBase\":{\"Type\":\"OSS\",\"Media\":\"http://<bucket name>.oss-cn-shanghai.aliyuncs.com/output/**/\"}},\"Outputs\":[{\"OutputFileName\":\"hd.mp4\",\"TemplateId\":\"<TemplateId>\"},{\"OutputFileName\":\"sd.mp4\",\"TemplateId\":\"<TemplateId>\"}]}]}")
                .setUserData("{\"videoId\":\"abcd\"}");
        com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
        try {
            com.aliyun.ice20201109.models.SubmitMediaConvertJobResponse resp = client.submitMediaConvertJobWithOptions(submitMediaConvertJobRequest, runtime);
            System.out.println(new com.google.gson.Gson().toJson(resp));
        } catch (TeaException error) {
            System.out.println(error.getMessage());
            System.out.println(error.getData().get("Recommend"));
        } catch (Exception _error) {
            TeaException error = new TeaException(_error.getMessage(), _error);
            System.out.println(error.getMessage());
            System.out.println(error.getData().get("Recommend"));
        }        
    }
}

Related API operations