You need to enable JavaScript to run this app.
导航
媒体处理任务
最近更新时间:2022.06.14 18:45:24首次发布时间:2022.06.14 18:45:24

本文为您提供了服务端 Java SDK 的媒体处理任务模块相关的 API 调用示例。主要包含:提交媒体处理任务、取消媒体处理任务、查询媒体处理任务等。

初始化

使用前请先完成初始化,参考 初始化

提交媒体处理任务

接口请求参数和返回参数详见 OpenAPI:提交媒体处理任务

package com.volcengine.example.imp.job;

import com.volcengine.service.imp.IImpService;
import com.volcengine.service.imp.impl.ImpServiceImpl;
import com.volcengine.service.imp.model.request.*;
import com.volcengine.service.imp.model.business.*;
import com.volcengine.service.imp.model.response.*;


public class ImpSubmitJobDemo {

    public static void main(String[] args) throws Exception {
        IImpService impService = ImpServiceImpl.getInstance();

        // call below method if you don't set ak and sk
        impService.setAccessKey("your ak");
        impService.setSecretKey("your sk");

        try {
            InputPath.Builder input = InputPath.newBuilder();
            input.setType("VOD");
            input.setVodSpaceName("your space name");
            input.setFileId("your file id");

            ImpSubmitJobRequest.Builder submitJobRequest = ImpSubmitJobRequest.newBuilder();
            submitJobRequest.setInputPath(input.build());
            submitJobRequest.setTemplateId("your template id");
            submitJobRequest.setCallbackArgs("your call back args");
            submitJobRequest.setEnableLowPriority("false");

            ImpSubmitJobResponse resp =  impService.SubmitJob(submitJobRequest.build());
            System.out.println(resp);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

取消媒体处理任务

接口请求参数和返回参数详见 OpenAPI:取消媒体处理任务

package com.volcengine.example.imp.job;

import com.volcengine.service.imp.IImpService;
import com.volcengine.service.imp.impl.ImpServiceImpl;
import com.volcengine.service.imp.model.request.*;
import com.volcengine.service.imp.model.response.*;


public class ImpKillJobDemo {

    public static void main(String[] args) throws Exception {
        IImpService impService = ImpServiceImpl.getInstance();

        // call below method if you don't set ak and sk
        impService.setAccessKey("your ak");
        impService.setSecretKey("your sk");

        try {
            ImpKillJobRequest.Builder killJobRequest = ImpKillJobRequest.newBuilder();
            killJobRequest.setJobId("your job id");

            ImpKillJobResponse resp = impService.KillJob(killJobRequest.build());
            System.out.println(resp);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}

查询媒体处理任务

接口请求参数和返回参数详见 OpenAPI:查询媒体处理任务

package com.volcengine.example.imp.job;

import com.volcengine.service.imp.IImpService;
import com.volcengine.service.imp.impl.ImpServiceImpl;
import com.volcengine.service.imp.model.request.*;
import com.volcengine.service.imp.model.response.*;

public class ImpRetrieveJobDemo {

    public static void main(String[] args) throws Exception {
        IImpService impService = ImpServiceImpl.getInstance();

        // call below method if you don't set ak and sk
        impService.setAccessKey("your ak");
        impService.setSecretKey("your sk");

        try {
            ImpRetrieveJobRequest.Builder retrieveJobRequest = ImpRetrieveJobRequest.newBuilder();
            retrieveJobRequest.addJobIds("your job id 1");
            retrieveJobRequest.addJobIds("your job id 2");

            ImpRetrieveJobResponse resp = impService.RetrieveJob(retrieveJobRequest.build());
            System.out.println(resp);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}