Tous les produits
Search
Centre de documentation

ApsaraVideo Media Processing:Merge and edit videos

Dernière mise à jour :Aug 10, 2026

Utilisez le SDK ApsaraVideo Media Processing (MPS) pour Java afin de fusionner et de découper des vidéos. La fusion vidéo combine des clips de différents formats, débits binaires et résolutions en une seule sortie. Cette fonction est couramment utilisée pour ajouter des génériques de début ou de fin, ou pour assembler des segments issus d'un flux en direct enregistré. Le découpage vidéo extrait un segment d'une vidéo source et l'enregistre sous forme de nouveau fichier, ce qui s'avère utile pour capturer des moments forts.

Scénarios

  • Assemblage de génériques de début/fin : Ajoutez un générique de début ou de fin fixe à une vidéo, ou assemblez des segments provenant d'un flux en direct enregistré.

  • Extraction de clips : Rognez un segment d'une vidéo source et exportez-le en tant que fichier autonome. Cette méthode est généralement utilisée pour capturer des moments forts.

  • Effets de génériques de début et de fin : Intégrez un générique de début au début d'une vidéo en mode Picture-in-Picture (PiP), ou ajoutez un générique de fin à la fin de la vidéo.

Fusionner plusieurs clips vidéo en séquence

L'exemple suivant découpe la vidéo d'entrée à partir de 00:00:03.000 avec une durée de 00:00:13.000 secondes, puis la fusionne avec le segment allant de 00:00:01.000 à 00:00:05.030 d'une vidéo de générique de début. La durée totale de la sortie est de 17,30 secondes.

/**
     * Merge multiple video clips in sequence.
     * @return
     * @throws Exception
     */
    public static void mergrUrlListJob() throws Exception {

        // Construct output parameters.
        JSONArray outputs = new JSONArray();

        // Configure the job input. Make sure that the media file used as the job input resides in the same region as the client.
        JSONObject input = new JSONObject();
        input.put("Bucket", "<your bucket name>");
        input.put("Location", "oss-cn-shanghai");

        // Configure the job output.
        JSONObject output = new JSONObject();
        try {
            input.put("Object", URLEncoder.encode("mps-test/demo/test.mp4", "utf-8"));
            String outPutObject = URLEncoder.encode("mps-test/demo/merge-out.mp4", "utf-8");
            output.put("OutputObject", outPutObject);
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException("input URL encode failed");
        }
        output.put("TemplateId", "<transcode templateId>");

        // Construct data for video clipping.
        JSONObject clip = new JSONObject();
        // Cut the video from 1.000s to 5.030s.
        clip.put("TimeSpan", "{\"Seek\":\"00:00:01.000\",\"Duration\":\"5.30\"}");
        // Cut the video from 1.000s to 5.030s that remains from the end of the video.
        //clip.put("TimeSpan", "{\"Seek\":\"00:00:01.000\",\"End\":\"5.30\"}");
        // Specifies whether to edit the first clip of the video. Valid values: true and false. A value of true specifies that the video clips are merged for a transcoding job after editing. A value of false specifies that the video clips are merged for a transcoding job before editing.
        clip.put("ConfigToClipFirstPart", true);

        // Construct data for video merging.
        JSONArray mergeList = new JSONArray();
        JSONObject merge = new JSONObject();
        merge.put("MergeURL", "http://bucket-name.oss-cn-shanghai.aliyuncs.com/" + URLEncoder.encode("mps-test/demo/test2mp4", "utf-8"));
        merge.put("Start", "00:00:03.000");
        merge.put("Duration", "00:00:13.000");

        mergeList.add(merge);
        output.put("Clip", clip);
        output.put("MergeList", mergeList);

        outputs.add(output);

        com.aliyun.mts20140618.Client client = MergeClipJobs.createClient();
        com.aliyun.mts20140618.models.SubmitJobsRequest submitJobsRequest = new com.aliyun.mts20140618.models.SubmitJobsRequest()
                // The job input.
                .setInput(input.toJSONString())
                // The job output configuration.
                .setOutputs(outputs.toJSONString())
                // The OSS bucket in which the output file is stored.
                .setOutputBucket("exampleBucket")
                // The region in which the OSS bucket resides.
                .setOutputLocation("oss-cn-shanghai")
                // The ID of the pipeline.
                .setPipelineId("dd3dae411e704030b921e52698e5****");
        com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
        try {
            // Write your own code to display the response of the API operation if necessary.
            client.submitJobsWithOptions(submitJobsRequest, runtime);
        } catch (TeaException error) {
            // Handle exceptions with caution in actual business scenarios and do not ignore the exceptions in your project. In this example, exceptions are provided for reference only. 
            // The error message.
            System.out.println(error.getMessage());
            // The URL for troubleshooting.
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        } catch (Exception _error) {
            TeaException error = new TeaException(_error.getMessage(), _error);
            // Handle exceptions with caution in actual business scenarios and do not ignore the exceptions in your project. In this example, exceptions are provided for reference only. 
            // The error message.
            System.out.println(error.getMessage());
            // The URL for troubleshooting.
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        }
    }

Fusionner des clips vidéo à l'aide d'un fichier de configuration

L'exemple suivant découpe la vidéo d'entrée à partir de 00:00:03.000 avec une durée de 00:00:10.000 secondes, puis la fusionne avec le segment allant de 00:00:01.000 à 00:00:05.030 du générique de début.

Le fichier de configuration mergeConfigfile contient les éléments suivants :

{"MergeList":[{"MergeURL":"https://bucket-name.oss-cn-beijing.aliyuncs.com/mps-test/demo/test2.mp4","Start":"00:00:03.000","Duration":"00:00:10.000"}]}

/**
     * Merge video clips by using the OSS path of a configuration file.
     * @return
     * @throws Exception
     */
    public static void mergrConfigFileJob() throws Exception {

        // Construct output parameters.
        JSONArray outputs = new JSONArray();

        // Configure the job input. Make sure that the media file used as the job input resides in the same region as the client.
        JSONObject input = new JSONObject();
        input.put("Bucket", "<your bucket name>");
        input.put("Location", "oss-cn-shanghai");

        // Configure the job output.
        JSONObject output = new JSONObject();
        try {
            input.put("Object", URLEncoder.encode("mps-test/demo/test.mp4", "utf-8"));
            String outPutObject = URLEncoder.encode("mps-test/demo/merge-out.mp4", "utf-8");
            output.put("OutputObject", outPutObject);
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException("input URL encode failed");
        }
        output.put("TemplateId", "<transcode templateId>");

        // Construct data for video clipping.
        JSONObject clip = new JSONObject();
        // Cut the video from 1.000s to 5.030s.
        clip.put("TimeSpan", "{\"Seek\":\"00:00:01.000\",\"Duration\":\"5.30\"}");
        // Cut the video from 1.000s to 5.030s that remains from the end of the video.
        //clip.put("TimeSpan", "{\"Seek\":\"00:00:01.000\",\"End\":\"5.30\"}");
        // Specifies whether to edit the first clip of the video. Valid values: true and false. A value of true specifies that the video clips are merged for a transcoding job after editing. A value of false specifies that the video clips are merged for a transcoding job before editing.
        clip.put("ConfigToClipFirstPart", true);

        output.put("Clip", clip);
        // The OSS path of the configuration file must be an HTTP URL.
        output.put("MergeConfigUrl", "http://bucket-name.oss-cn-shanghai.aliyuncs.com/mps-test/demo/mergeConfigfile");

        outputs.add(output);

        com.aliyun.mts20140618.Client client = MergeClipJobs.createClient();
        com.aliyun.mts20140618.models.SubmitJobsRequest submitJobsRequest = new com.aliyun.mts20140618.models.SubmitJobsRequest()
                // The job input.
                .setInput(input.toJSONString())
                // The job output configuration.
                .setOutputs(outputs.toJSONString())
                // The OSS bucket in which the output file is stored.
                .setOutputBucket("exampleBucket")
                // The region in which the OSS bucket resides.
                .setOutputLocation("oss-cn-shanghai")
                // The ID of the pipeline.
                .setPipelineId("dd3dae411e704030b921e52698e5****");
        com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
        try {
            // Write your own code to display the response of the API operation if necessary.
            client.submitJobsWithOptions(submitJobsRequest, runtime);
        } catch (TeaException error) {
            // Handle exceptions with caution in actual business scenarios and do not ignore the exceptions in your project. In this example, exceptions are provided for reference only. 
            // The error message.
            System.out.println(error.getMessage());
            // The URL for troubleshooting.
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        } catch (Exception _error) {
            TeaException error = new TeaException(_error.getMessage(), _error);
            // Handle exceptions with caution in actual business scenarios and do not ignore the exceptions in your project. In this example, exceptions are provided for reference only. 
            // The error message.
            System.out.println(error.getMessage());
            // The URL for troubleshooting.
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        }
    }

Intégrer un générique de début ou ajouter un générique de fin à une vidéo

L'exemple suivant intègre un générique de début (680 x 480) à partir de la troisième seconde de la vidéo d'entrée en mode Picture-in-Picture (PiP), et ajoute un générique de fin (680 x 480) à la fin. La zone vide après le générique de fin est remplie par un arrière-plan blanc.

Remarque

Les objets OSS référencés dans les URL des génériques de début et de fin doivent être encodés en UTF-8, et les URL doivent utiliser le protocole HTTP. Pour plus d'informations, consultez Encodage d'URL.

 /**
     * Embed opening parts at the beginning of the input video or add ending parts to the end of the input video.
     * @return
     * @throws Exception
     */
    public static void openAndTailJob() throws Exception {

        // Construct output parameters.
        JSONArray outputs = new JSONArray();

        // Configure the job input. Make sure that the media file used as the job input resides in the same region as the client.
        JSONObject input = new JSONObject();
        input.put("Bucket", "<your bucket name>");
        input.put("Location", "oss-cn-shanghai");

        // Configure the job output.
        JSONObject output = new JSONObject();
        try {
            input.put("Object", URLEncoder.encode("mps-test/demo/test.mp4", "utf-8"));
            String outPutObject = URLEncoder.encode("mps-test/demo/merge-out.mp4", "utf-8");
            output.put("OutputObject", outPutObject);
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException("input URL encode failed");
        }
        output.put("TemplateId", "<transcode templateId>");

        JSONArray openingList = new JSONArray();
        JSONObject opening = new JSONObject();
        opening.put("OpenUrl", "http://bucket-name.oss-cn-shanghai.aliyuncs.com/" + URLEncoder.encode("mps-test/demo/open.mp4", "utf-8"));
        opening.put("Start", "3");
        opening.put("Width", "680");
        opening.put("Height", "480");
        openingList.add(opening);

        JSONArray tailSlateList = new JSONArray();
        JSONObject tailSlate = new JSONObject();
        // Objects specified by URLs of the opening and ending parts must be UTF-8-encoded. 
        tailSlate.put("TailUrl", "http://bucket-name.oss-cn-shanghai.aliyuncs.com/" + URLEncoder.encode("mps-test/demo/tail.mp4", "utf-8"));
        tailSlate.put("BlendDuration", "2");
        tailSlate.put("Width", "680");
        tailSlate.put("Height", "480");
        tailSlate.put("IsMergeAudio", true);
        tailSlate.put("BgColor", "White");
        tailSlateList.add(tailSlate);

        output.put("OpeningList", openingList);
        output.put("TailSlateList", tailSlateList);
        outputs.add(output);

        com.aliyun.mts20140618.Client client = MergeClipJobs.createClient();
        com.aliyun.mts20140618.models.SubmitJobsRequest submitJobsRequest = new com.aliyun.mts20140618.models.SubmitJobsRequest()
                // The job input.
                .setInput(input.toJSONString())
                // The job output configuration.
                .setOutputs(outputs.toJSONString())
                // The OSS bucket in which the output file is stored.
                .setOutputBucket("exampleBucket")
                // The region in which the OSS bucket resides.
                .setOutputLocation("oss-cn-shanghai")
                // The ID of the pipeline.
                .setPipelineId("dd3dae411e704030b921e52698e5****");
        com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
        try {
            // Write your own code to display the response of the API operation if necessary.
            client.submitJobsWithOptions(submitJobsRequest, runtime);
        } catch (TeaException error) {
            // Handle exceptions with caution in actual business scenarios and do not ignore the exceptions in your project. In this example, exceptions are provided for reference only. 
            // The error message.
            System.out.println(error.getMessage());
            // The URL for troubleshooting.
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        } catch (Exception _error) {
            TeaException error = new TeaException(_error.getMessage(), _error);
            // Handle exceptions with caution in actual business scenarios and do not ignore the exceptions in your project. In this example, exceptions are provided for reference only. 
            // The error message.
            System.out.println(error.getMessage());
            // The URL for troubleshooting.
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        }
    }

Exemple de code complet

Les trois exemples utilisent submitJobsWithOptions pour soumettre des tâches de transcodage asynchrones. Le client est initialisé avec les identifiants issus des variables d'environnement.

package com.alibaba.bltest.api_v2;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.aliyun.tea.TeaException;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

public class MergeClipJobs {

    /**
     * <b>description</b> :
     * <p>Use your AccessKey pair to initialize the client.</p>
     * @return Client
     *
     * @throws Exception
     */
    public static com.aliyun.mts20140618.Client createClient() throws Exception {

        com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
                // Required. Make sure that the ALIBABA_CLOUD_ACCESS_KEY_ID environment variable is configured. 
                .setAccessKeyId(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"))
                // Required. Make sure that the ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variable is configured. 
                .setAccessKeySecret(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"));
        config.endpoint = "mts.cn-shanghai.aliyuncs.com";
        return new com.aliyun.mts20140618.Client(config);
    }

    /**
     * Merge multiple video clips in sequence.
     * @return
     * @throws Exception
     */
    public static void mergrUrlListJob() throws Exception {

        // Construct output parameters.
        JSONArray outputs = new JSONArray();

        // Configure the job input. Make sure that the media file used as the job input resides in the same region as the client.
        JSONObject input = new JSONObject();
        input.put("Bucket", "<your bucket name>");
        input.put("Location", "oss-cn-shanghai");

        // Configure the job output.
        JSONObject output = new JSONObject();
        try {
            input.put("Object", URLEncoder.encode("mps-test/demo/test.mp4", "utf-8"));
            String outPutObject = URLEncoder.encode("mps-test/demo/merge-out.mp4", "utf-8");
            output.put("OutputObject", outPutObject);
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException("input URL encode failed");
        }
        output.put("TemplateId", "<transcode templateId>");

        // Construct data for video clipping.
        JSONObject clip = new JSONObject();
        // Cut the video from 1.000s to 5.030s.
        clip.put("TimeSpan", "{\"Seek\":\"00:00:01.000\",\"Duration\":\"5.30\"}");
        // Cut the video from 1.000s to 5.030s that remains from the end of the video.
        //clip.put("TimeSpan", "{\"Seek\":\"00:00:01.000\",\"End\":\"5.30\"}");
        // Specifies whether to edit the first clip of the video. Valid values: true and false. A value of true specifies that the video clips are merged for a transcoding job after editing. A value of false specifies that the video clips are merged for a transcoding job before editing.
        clip.put("ConfigToClipFirstPart", true);

        // Construct data for video merging.
        JSONArray mergeList = new JSONArray();
        JSONObject merge = new JSONObject();
        merge.put("MergeURL", "http://bucket-name.oss-cn-shanghai.aliyuncs.com/" + URLEncoder.encode("mps-test/demo/test2mp4", "utf-8"));
        merge.put("Start", "00:00:03.000");
        merge.put("Duration", "00:00:13.000");

        mergeList.add(merge);
        output.put("Clip", clip);
        output.put("MergeList", mergeList);

        outputs.add(output);

        com.aliyun.mts20140618.Client client = MergeClipJobs.createClient();
        com.aliyun.mts20140618.models.SubmitJobsRequest submitJobsRequest = new com.aliyun.mts20140618.models.SubmitJobsRequest()
                // The job input.
                .setInput(input.toJSONString())
                // The job output configuration.
                .setOutputs(outputs.toJSONString())
                // The OSS bucket in which the output file is stored.
                .setOutputBucket("exampleBucket")
                // The region in which the OSS bucket resides.
                .setOutputLocation("oss-cn-shanghai")
                // The ID of the pipeline.
                .setPipelineId("dd3dae411e704030b921e52698e5****");
        com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
        try {
            // Write your own code to display the response of the API operation if necessary.
            client.submitJobsWithOptions(submitJobsRequest, runtime);
        } catch (TeaException error) {
            // Handle exceptions with caution in actual business scenarios and do not ignore the exceptions in your project. In this example, exceptions are provided for reference only. 
            // The error message.
            System.out.println(error.getMessage());
            // The URL for troubleshooting.
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        } catch (Exception _error) {
            TeaException error = new TeaException(_error.getMessage(), _error);
            // Handle exceptions with caution in actual business scenarios and do not ignore the exceptions in your project. In this example, exceptions are provided for reference only. 
            // The error message.
            System.out.println(error.getMessage());
            // The URL for troubleshooting.
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        }
    }

    /**
     * Merge video clips by using the OSS path of a configuration file.
     * @return
     * @throws Exception
     */
    public static void mergrConfigFileJob() throws Exception {

        // Construct output parameters.
        JSONArray outputs = new JSONArray();

        // Configure the job input. Make sure that the media file used as the job input resides in the same region as the client.
        JSONObject input = new JSONObject();
        input.put("Bucket", "<your bucket name>");
        input.put("Location", "oss-cn-shanghai");

        // Configure the job output.
        JSONObject output = new JSONObject();
        try {
            input.put("Object", URLEncoder.encode("mps-test/demo/test.mp4", "utf-8"));
            String outPutObject = URLEncoder.encode("mps-test/demo/merge-out.mp4", "utf-8");
            output.put("OutputObject", outPutObject);
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException("input URL encode failed");
        }
        output.put("TemplateId", "<transcode templateId>");

        // Construct data for video clipping.
        JSONObject clip = new JSONObject();
        // Cut the video from 1.000s to 5.030s.
        clip.put("TimeSpan", "{\"Seek\":\"00:00:01.000\",\"Duration\":\"5.30\"}");
        // Cut the video from 1.000s to 5.030s that remains from the end of the video.
        //clip.put("TimeSpan", "{\"Seek\":\"00:00:01.000\",\"End\":\"5.30\"}");
        // Specifies whether to edit the first clip of the video. Valid values: true and false. A value of true specifies that the video clips are merged for a transcoding job after editing. A value of false specifies that the video clips are merged for a transcoding job before editing.
        clip.put("ConfigToClipFirstPart", true);

        output.put("Clip", clip);
        // The OSS path of the configuration file must be an HTTP URL.
        output.put("MergeConfigUrl", "http://bucket-name.oss-cn-shanghai.aliyuncs.com/mps-test/demo/mergeConfigfile");

        outputs.add(output);

        com.aliyun.mts20140618.Client client = MergeClipJobs.createClient();
        com.aliyun.mts20140618.models.SubmitJobsRequest submitJobsRequest = new com.aliyun.mts20140618.models.SubmitJobsRequest()
                // The job input.
                .setInput(input.toJSONString())
                // The job output configuration.
                .setOutputs(outputs.toJSONString())
                // The OSS bucket in which the output file is stored.
                .setOutputBucket("exampleBucket")
                // The region in which the OSS bucket resides.
                .setOutputLocation("oss-cn-shanghai")
                // The ID of the pipeline.
                .setPipelineId("dd3dae411e704030b921e52698e5****");
        com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
        try {
            // Write your own code to display the response of the API operation if necessary.
            client.submitJobsWithOptions(submitJobsRequest, runtime);
        } catch (TeaException error) {
            // Handle exceptions with caution in actual business scenarios and do not ignore the exceptions in your project. In this example, exceptions are provided for reference only. 
            // The error message.
            System.out.println(error.getMessage());
            // The URL for troubleshooting.
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        } catch (Exception _error) {
            TeaException error = new TeaException(_error.getMessage(), _error);
            // Handle exceptions with caution in actual business scenarios and do not ignore the exceptions in your project. In this example, exceptions are provided for reference only. 
            // The error message.
            System.out.println(error.getMessage());
            // The URL for troubleshooting.
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        }
    }

    /**
     * Embed opening parts at the beginning of the input video or add ending parts to the end of the input video.
     * @return
     * @throws Exception
     */
    public static void openAndTailJob() throws Exception {

        // Construct output parameters.
        JSONArray outputs = new JSONArray();

        // Configure the job input. Make sure that the media file used as the job input resides in the same region as the client.
        JSONObject input = new JSONObject();
        input.put("Bucket", "<your bucket name>");
        input.put("Location", "oss-cn-shanghai");

        // Configure the job output.
        JSONObject output = new JSONObject();
        try {
            input.put("Object", URLEncoder.encode("mps-test/demo/test.mp4", "utf-8"));
            String outPutObject = URLEncoder.encode("mps-test/demo/merge-out.mp4", "utf-8");
            output.put("OutputObject", outPutObject);
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException("input URL encode failed");
        }
        output.put("TemplateId", "<transcode templateId>");

        JSONArray openingList = new JSONArray();
        JSONObject opening = new JSONObject();
        opening.put("OpenUrl", "http://bucket-name.oss-cn-shanghai.aliyuncs.com/" + URLEncoder.encode("mps-test/demo/open.mp4", "utf-8"));
        opening.put("Start", "3");
        opening.put("Width", "680");
        opening.put("Height", "480");
        openingList.add(opening);

        JSONArray tailSlateList = new JSONArray();
        JSONObject tailSlate = new JSONObject();
        // Objects specified by URLs of the opening and ending parts must be UTF-8-encoded. 
        tailSlate.put("TailUrl", "http://bucket-name.oss-cn-shanghai.aliyuncs.com/" + URLEncoder.encode("mps-test/demo/tail.mp4", "utf-8"));
        tailSlate.put("BlendDuration", "2");
        tailSlate.put("Width", "680");
        tailSlate.put("Height", "480");
        tailSlate.put("IsMergeAudio", true);
        tailSlate.put("BgColor", "White");
        tailSlateList.add(tailSlate);

        output.put("OpeningList", openingList);
        output.put("TailSlateList", tailSlateList);
        outputs.add(output);

        com.aliyun.mts20140618.Client client = MergeClipJobs.createClient();
        com.aliyun.mts20140618.models.SubmitJobsRequest submitJobsRequest = new com.aliyun.mts20140618.models.SubmitJobsRequest()
                // The job input.
                .setInput(input.toJSONString())
                // The job output configuration.
                .setOutputs(outputs.toJSONString())
                // The OSS bucket in which the output file is stored.
                .setOutputBucket("exampleBucket")
                // The region in which the OSS bucket resides.
                .setOutputLocation("oss-cn-shanghai")
                // The ID of the pipeline.
                .setPipelineId("dd3dae411e704030b921e52698e5****");
        com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
        try {
            // Write your own code to display the response of the API operation if necessary.
            client.submitJobsWithOptions(submitJobsRequest, runtime);
        } catch (TeaException error) {
            // Handle exceptions with caution in actual business scenarios and do not ignore the exceptions in your project. In this example, exceptions are provided for reference only. 
            // The error message.
            System.out.println(error.getMessage());
            // The URL for troubleshooting.
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        } catch (Exception _error) {
            TeaException error = new TeaException(_error.getMessage(), _error);
            // Handle exceptions with caution in actual business scenarios and do not ignore the exceptions in your project. In this example, exceptions are provided for reference only. 
            // The error message.
            System.out.println(error.getMessage());
            // The URL for troubleshooting.
            System.out.println(error.getData().get("Recommend"));
            com.aliyun.teautil.Common.assertAsString(error.message);
        }
    }
}

Rubriques connexes