All Products
Search
Document Center

Intelligent Media Services:Script-to-video

Last Updated:Dec 12, 2024

This topic describes how to configure script-to-video parameters and the advanced settings. This topic also provides examples of SDK calls.

Note
  • Before you read this topic, we recommend that you read the content related to script-to-video in Use the intelligent and quick video production feature.

  • Terms:

    • Global broadcast mode: You can match multiple voice-over scripts with random script nodes to edit multiple videos at a time.

    • Group broadcast mode: You can split a voice-over script into multiple clips and match them with script nodes to achieve better effects.

  • The following regions support the script-to-video feature: China (Beijing), China (Shanghai), China (Hangzhou), and China (Shenzhen).

Usage notes

InputConfig parameters

Note

You can configure InputConfig parameters to specify basic materials such as videos, voice-over scripts, background music, and stickers.

Parameter

Type

Description

Required

Supported mode

MediaGroupArray

List<MediaGroup>

Configure the script-to-video mode. Specify materials. You can configure group names or a material list.

Group name: A group name can be up to 50 characters in length and emojis are not supported.

Material list: Specify the IDs or Object Storage Service (OSS) URLs of materials.

You can specify at most 40 material groups. Each group can contain at most 200 materials.

Yes

  • Global broadcast mode

  • Group broadcast mode

TitleArray

List<String>

An array of titles. A title is randomly selected each time the system produces a video.

You can specify at most 50 titles. Each title can be up to 50 characters in length.

No

  • Global broadcast mode

  • Group broadcast mode

SpeechTextArray

List<String>

An array of voice-over scripts. A voice-over script is randomly selected each time the system produces a video.

You can specify at most 50 voice-over scripts. Each voice-over script can be up to 1,000 characters in length.

No

  • Global broadcast mode

StickerArray

List<Sticker>

An array of stickers. A sticker is randomly selected each time the system produces a video.

You can specify at most 50 stickers.

No

  • Global broadcast mode

  • Group broadcast mode

BackgroundMusicArray

List<String>

An array of background music materials. A background music material is randomly selected each time the system produces a video.

You can specify at most 50 background music materials by specifying their IDs or OSS URLs.

No

  • Global broadcast mode

  • Group broadcast mode

BackgroundImageArray

List<String>

An array of background images. A background image material is randomly selected each time the system produces a video.

You can specify at most 50 background images by specifying their IDs or OSS URLs.

No

  • Global broadcast mode

  • Group broadcast mode

MediaGroup parameters

Note

Refer to the Supported mode column in the following table to check the MediaGroup parameters supported by the global broadcast mode and group broadcast mode.

Parameter

Type

Description

Required

Supported mode

GroupName

String

The material group name.

The name can be up to 50 characters in length and emojis are not supported.

Yes

  • Global broadcast mode

  • Group broadcast mode

MediaArray

List<String>

A list of materials. You can specify the IDs or URLs of materials.

You can specify at most 40 material groups. Each group can contain at most 200 materials.

Yes

  • Global broadcast mode

  • Group broadcast mode

SpeechTextArray

List<String>

An array of voice-over scripts. A voice-over script is randomly selected each time the system produces a video.

You can specify at most 50 voice-over scripts. Each voice-over script can be up to 1,000 characters in length.

No

  • Group broadcast mode

Duration

Float

The length of the truncated video clip in the current group. The default value is 5 seconds. Specify this parameter only when you leave the SpeechTextArray parameter empty.

No

  • Group broadcast mode

Sticker parameters

Note

The global broadcast mode and group broadcast mode support the same Sticker parameters.

Parameter

Type

Description

Required

MediaId

String

The ID of a sticker, logo, or watermark image.

You must specify at least one of the parameters.

When you specify both parameters, the MediaId parameter is used.

MediaURL

String

The URL of a sticker, logo, or watermark image. You can specify an OSS URL.

X

Float

For more information, see the description of the X parameter in the "VideoTrackClip" section of the Timeline configurations topic.

No

Y

Float

For more information, see the description of the Y parameter in the "VideoTrackClip" section of the Timeline configurations topic.

No

Width

Float

For more information, see the description of the Width parameter in the "VideoTrackClip" section of the Timeline configurations topic.

No

Height

Float

For more information, see the description of the Height parameter in the "VideoTrackClip" section of the Timeline configurations topic.

No

DynamicFrames

Integer

The number of frames of an animated sticker.

No. This parameter is required only when an animated sticker is specified.

Global broadcast mode - examples

{
  "MediaGroupArray": [
    {
      "GroupName": "UseMediaId",
      "MediaArray": [
        "****9d46c886b45481030f6e****",
        "****c886810b4549d4630f6e****"
      ]
    },
    {
      "GroupName": "UseOssUrl",
      "MediaArray": [
        "http://test-bucket.oss-cn-shanghai.aliyuncs.com/test1.mp4",
        "http://test-bucket.oss-cn-shanghai.aliyuncs.com/test2.png"
      ]
    }
  ],
  "TitleArray": [
    "Freshippo Opens a Store in Huilongguan",
    "Freshippo Opens a Store"
  ],
  "SpeechTextArray": [
    "Freshippo opens a store near the shopping mall. Today is the first day of opening. Come and have fun in Freshippo. The store is not large but the prices of snacks and drinks are low, which attract many customers waiting in the queue.",
    "Freshippo opens a store near the shopping mall. Today is the first day of opening. Come and have fun."
  ],
  "StickerArray": [
    {
      "MediaId": "****9d46c8b4548681030f6e****",
      "X": 10,
      "Y": 100,
      "Width": 300,
      "Height": 300
    },
    {
      "MediaURL": "http://test-bucket.oss-cn-shanghai.aliyuncs.com/test3.png",
      "X": 10,
      "Y": 100,
      "Width": 300,
      "Height": 300
    }
  ],
  "BackgroundMusicArray": [
    "****b4549d46c88681030f6e****",
    "****549d46c88b4681030f6e****",
    "http://test-bucket.oss-cn-shanghai.aliyuncs.com/test4.mp3"
  ],
  "BackgroundImageArray": [
    "****6c886b4549d481030f6e****",
    "****9d46c8548b4681030f6e****",
    "http://test-bucket.oss-cn-shanghai.aliyuncs.com/test1.png"
  ]
}

Group broadcast mode - examples

{
  "MediaGroupArray": [{
    "GroupName": "start",
    "MediaArray": ["https://ice-*****-test.oss-cn-*****.aliyuncs.com/0-test-batch-editing-materials/1.jpeg", "https://ice-auto-test.oss-cn-shanghai.aliyuncs.com/0-test-batch-editing-materials/highway.mp4"],
    "Duration": 5
  },
    {
      "GroupName": "group1",
      "MediaArray": ["https://ice-*****-test.oss-cn-*****.aliyuncs.com/0-test-batch-editing-materials/160134%2B9859695-2032aa5c-2803-47cd-bf65-8a40d66598db.png", "https://ice-auto-test.oss-cn-shanghai.aliyuncs.com/0-test-batch-editing-materials/cloud.mp4"],
      "SpeechTextArray": ["Freshippo opens a store near the shopping mall. Today is the first day of opening.", "Today is the first day of the new Freshippo store."]
    },
    {
      "GroupName": "group2",
      "MediaArray": ["https://ice-*****-test.oss-cn-*****.aliyuncs.com/0-test-batch-editing-materials/normal%20video.mp4", "https://ice-auto-test.oss-cn-shanghai.aliyuncs.com/0-test-batch-editing-materials/3.jpeg"],
      "SpeechTextArray": ["The store is not large but the prices of snacks and drinks are low, which attract many customers waiting in the queue.", "So many customers and products"]
    },
    {
      "GroupName": "group3",
      "MediaArray": ["https://ice-*****-test.oss-cn-*****.aliyuncs.com/0-test-batch-editing-materials/young_sunset_walk.mp4"],
      "SpeechTextArray": ["Come and have a look", "Come and have a look"]
    },
    {
      "GroupName": "end",
      "MediaArray": ["https://ice-*****-test.oss-cn-*****.aliyuncs.com/0-test-batch-editing-materials/media_type_as_video.jpg", "https://ice-auto-test.oss-cn-shanghai.aliyuncs.com/0-test-batch-editing-materials/highway.mp4"],
      "Duration": 5
    }
  ],
  "TitleArray": [
    "Freshippo Opens a Store in Huilongguan",
    "Freshippo Opens a Store"
  ],
  "StickerArray": [
    {
      "MediaId": "****9d46c8b4548681030f6e****",
      "X": 10,
      "Y": 100,
      "Width": 300,
      "Height": 300
    },
    {
      "MediaURL": "http://test-bucket.oss-cn-*****.aliyuncs.com/test3.png",
      "X": 10,
      "Y": 100,
      "Width": 300,
      "Height": 300
    }
  ],
  "BackgroundMusicArray": [
    "****b4549d46c88681030f6e****",
    "****549d46c88b4681030f6e****",
    "http://test-bucket.oss-cn-*****.aliyuncs.com/test4.mp3"
  ],
  "BackgroundImageArray": [
    "****6c886b4549d481030f6e****",
    "****9d46c8548b4681030f6e****",
    "http://test-bucket.oss-cn-*****.aliyuncs.com/test1.png"
  ]
}

EditingConfig parameters

You can configure EditingConfig parameters to specify the volume, location, and other production settings of output videos.

Note

All EditingConfig parameters are supported by the global broadcast mode and group broadcast mode, except for the following parameter.

  • AlignmentMode specified by the ProcessConfig parameter takes effect only in global broadcast mode.

Parameter

Type

Description

Required

MediaConfig

JSON

The configuration related to the input video.

Supported parameters:

  • Volume: the volume of the input video. Valid values: [0, 10.0]. You can specify a decimal. Example: 0.5.

  • MediaMetaDataArray: an array of material metadata. Each MediaMetaData contains the following parameters:

    • Media: the ID or OSS URL of the material. The value must be same as that of the corresponding InputConfig parameter.

    • GroupName: the name of the group to which the material belongs.

    • TimeRangeList: the range of start positions and end positions. You can specify multiple pairs of start position and end position to truncate a material into multiple clips. A TimeRange contains the following parameters:

      • In: the start position.

      • Out: the end position.

No

TitleConfig

JSON

The configuration related to titles. You can configure subtitle parameters. For more information, see the "Banner text" section of the Effect configurations topic.

No

SpeechConfig

JSON

The configuration related to voice-over scripts.

Supported parameters:

  • Volume: Specify the volume of the voice-over audio. Valid values: [0, 10.0]. You can specify a decimal. Example: 0.5.

  • AsrConfig: You can configure subtitle parameters. For more information, see the "Banner text" section of the Effect configurations topic.

  • Voice: Specify one or more voices. If multiple voices are specified, a voice is randomly selected when the system produces a video. Example: "zhimiao_emo,zhilun".

  • SpeechRate: Specify the speed at which the speaker speaks. Valid values: -500 to 500. Default value: 0.

    • A value of -500 indicates that the speech tempo is 0.5 times the original speech tempo. A value of 0 indicates that the original speech tempo is used. A value of 500 indicates that the speech tempo is 2 times the original speech tempo.

Note

The following examples show how the speech tempo is calculated:

  • 0.8: (1-1/0.8)/0.002 = -125

  • 1.2: (1-1/1.2)/0.001 = 166

If the speed is less than 1x, use the coefficient 0.002.

If the speed is greater than 1x, use the coefficient 0.001.

The actual calculation result is rounded to the nearest integer.

  • Style: Specify the style of the voice. By default, this parameter is left empty. If you specify both the Voice and Style parameters, the Voice parameter is used. Valid values:

    • "Gentle"

    • "Serious"

    • "Entertainment"

No

BackgroundMusicConfig

JSON

The configuration related to background music.

Supported parameters:

  • Volume: the volume of the background music. Valid values: [0, 10.0]. You can specify a decimal. Example: 0.5.

  • Style: the style of the background music. By default, this parameter is left empty. If background music settings are already configured in the InputConfig, this parameter does not take effect. Valid values:

    • "bgm-beauty"

    • "bgm-chinese-style"

    • "bgm-cuisine"

    • "bgm-dynamic"

    • "bgm-quirky"

    • "bgm-relaxing"

    • "bgm-romantic"

    • "bgm-upbeat"

No

BackgroundImageConfig

JSON

The configuration related to background images. If background image settings are already configured in the InputConfig, this parameter does not take effect.

Supported parameters:

  • SubType: the background type. Valid values:

    • "Color": solid color.

    • "Blur": blurred background.

  • Radius: the blurred radius. This parameter takes effect only when the SubType parameter is set to Blur. Valid values: [0.01, 1].

  • Color: the background color. The value is a hexadecimal number that indicates the RGB color. This parameter takes effect only when the SubType parameter is set to Color. Example: #000000.

No

ProcessConfig

The mixing configuration.

Supported parameters:

  • SingleShotDuration: Specify the length of a clip. The system automatically splits a long video into multiple clips when you edit the long video.

  • AllowVfxEffect: Specify whether to allow virtual effects. The default value is false.

  • VfxEffectProbability: Specify the probability that the virtual effect is applied to each video clip. The default value is 0.5. Valid values: 0.0 to 1.0. You can specify a value that is accurate to two decimal places.

  • AllowTransition: Specify whether to allow the transition effect. The default value is false.

  • TransitionList: Specify a list of custom transition effects. When the AllowTransition parameter is set to true, the system randomly selects a transition effect from the list. Example: ["directional", "linearblur"].

  • UseUniformTransition: Specify whether to use the same transition effect throughout an output video. The default value is true.

  • AlignmentMode: Set the alignment mode for videos and voice-over scripts. This parameter takes effect only in global broadcast mode. Valid values:

    • "AutoSpeed": Adjust the video track based on the length of the audio track. This is the default value.

    • "Cut": Truncate the video track based on the length of the audio track.

ProduceConfig

JSON

The configuration related to editing and mixing. For more information, see the "EditingProduceConfig" section of the Editing and production parameters topic.

No

Examples

{
  "MediaConfig": {
    "Volume": 0 // By default, video materials are muted.
  },
  "TitleConfig": {
    "Alignment": "TopCenter",
    "AdaptMode": "AutoWrap",
    "Font": "Alibaba PuHuiTi 2.0 95 ExtraBold",
    "SizeRequestType": "Nominal",
    "Y": 0.1, // The coordinate of the title in the Y axis when the portrait mode is used to produce videos.
    "Y": 0.05, // The coordinate of the title in the Y axis when the landscape mode is used to produce videos.
    "Y": 0.08 // The coordinate of the title in the Y axis when the square mode is used to produce videos.
  },
  "SpeechConfig": {
    "Volume": 1,  // By default, the original volume setting of the voice-over is used.
    "SpeechRate": 0,
    "Voice": null,
    "Style": null,
    "AsrConfig": {
      "Alignment": "TopCenter",
      "AdaptMode": "AutoWrap",
      "Font": "Alibaba PuHuiTi 2.0 65 Medium",
      "SizeRequestType": "Nominal",
      "Spacing": -1,
      "Y": 0.8, // The coordinate of the subtitle in the Y axis when the portrait mode is used to produce videos.
      "Y": 0.9, // The coordinate of the subtitle in the Y axis when the landscape mode is used to produce videos.
      "Y": 0.85 // The coordinate of the subtitle in the Y axis when the square mode is used to produce videos.
    }
  },
  "BackgroundMusicConfig": {
    "Volume": 0.2,   // By default, the volume of background music is set to 20%.
    "Style": null
  },
  "ProcessConfig": {
    "SingleShotDuration": 3,      // The length of each video clip.
    "AllowVfxEffect": false,  // Specifies whether special effects can be used.
    "AllowTransition": false,	  // Specifies whether transitions can be used.
    "AlignmentMode": "AutoSpeed"  // This parameter takes effect only in global broadcast mode.
  }
}

OutputConfig parameters

You can configure the OutputConfig parameter to specify the URL, naming rule, width, height, and number of videos that are produced.

Note

The OutputConfig parameters supported by the global broadcast mode and group broadcast mode are the same.

Parameter

Type

Required

Description

MediaURL

String

Required when you want to store the output videos in OSS

The URL of the output video. The URL must contain a placeholder.

Example: http://xxx.oss-cn-shanghai.aliyuncs.com/xxx_{index}.mp4

StorageLocation

String

Required when you want to store the output videos in ApsaraVideo VOD (VOD)

The URL of the videos stored in VOD.

Example: outin-xxxxxx.oss-cn-shanghai.aliyuncs.com

FileName

String

Required when you want to store the output videos in VOD

The name of the output video. The name must contain a placeholder.

Example: xxx_{index}.mp4

GeneratePreviewOnly

Boolean

No and the default value is false.

If you set the GeneratePreviewOnly parameter to true, the current job generates a timeline only for preview and no video is produced. In this scenario, you do not need to specify the URL of the output video.

After the quick video production job is complete, you can call the GetBatchMediaProducingJob operation to query the result of the job. The returned task list contains the ID of the edit project (projectId). You can call the GetEditingProject operation to obtain the timeline for preview.

Count

Integer

No and the default value is 1.

The number of videos to produce. The maximum value is 100.

MaxDuration

Float

No

The maximum length of each video.

  • If the voice-over script setting is specified, the TTS length shall prevail. In this case, this parameter does not take effect.

  • You do not need to specify this parameter in group broadcast mode.

  • You can specify only one of the following parameters: FixedDuration and MaxDuration.

  • For more information about the length rules, see the "Processing logic" section of this topic.

FixedDuration

Float

No

The fixed length of each video. If you specify a fixed length, all produced videos use the fixed length.

  • This parameter is not supported in group broadcast mode.

  • In global broadcast mode, you can specify this parameter when the SpeechTextArray parameter is left empty.

  • You can specify only one of the following parameters: FixedDuration and MaxDuration.

  • For more information about the length rules, see the "Processing logic" section of this topic.

Width

Integer

Yes

The width of the output video in pixels.

Height

Integer

Yes

The height of the output video in pixels.

Video

JSONObject

No

Settings related to output video streams, such as Crf and Codec.

Examples

{
 	"MediaURL": "http://xxx.oss-cn-shanghai.aliyuncs.com/xxx_{index}.mp4",
 	"Count": 20,
 	"MaxDuration": 15,
 	"Width": 1080,
 	"Height": 1920,
 	"Video": {"Crf": 27},
        "GeneratePreviewOnly":false
}

Examples of SDK calls

Prerequisites

The Intelligent Media Services (IMS) server SDK is installed. For more information, see Preparations.

Sample code

The following sample code provides examples of the global broadcast mode:

View sample code

package com.example;

import java.util.*;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import com.aliyun.ice20201109.Client;
import com.aliyun.ice20201109.models.*;
import com.aliyun.teaopenapi.models.Config;


/**
 *  Add the following Maven dependencies:
 *   <dependency>
 *      <groupId>com.aliyun</groupId>
 *      <artifactId>ice20201109</artifactId>
 *      <version>2.3.0</version>
 *  </dependency>
 *  <dependency>
 *      <groupId>com.alibaba</groupId>
 *      <artifactId>fastjson</artifactId>
 *      <version>1.2.9</version>
 *  </dependency>
 */
public class ScriptBatchEditingService {

    static final String regionId = "<service-region>"; // IDs of regions that support intelligent image-text matching: cn-shanghai, cn-beijing, and cn-hangzhou.
    static final String bucket = "<your-bucket>";
    private Client iceClient;

    public static void main(String[] args) throws Exception {
        ScriptBatchEditingService scriptBatchEditingService = new ScriptBatchEditingService();
        scriptBatchEditingService.initClient();
        scriptBatchEditingService.runExample();
    }

    public void initClient() throws Exception {
        // The AccessKey pair of an Alibaba Cloud account has access permissions on all API operations. We recommend that you use the AccessKey pair of a Resource Access Management (RAM) user to call API operations or perform routine O&M. 
        // In this example, the AccessKey ID and AccessKey secret are obtained from the environment variables. For information about how to configure environment variables to store the AccessKey ID and AccessKey secret, visit https://www.alibabacloud.com/help/en/sdk/developer-reference/v2-manage-access-credentials.
        com.aliyun.credentials.Client credentialClient = new com.aliyun.credentials.Client();

        Config config = new Config();
        config.setCredential(credentialClient);

        // To hard-code your AccessKey ID and AccessKey secret, use the following lines. However, we recommend that you do not hard-code your AccessKey ID and AccessKey secret for security concerns. 
        // config.accessKeyId = <AccessKey ID>;
        // config.accessKeySecret = <AccessKey secret>;
        config.endpoint = "ice." + regionId + ".aliyuncs.com";
        config.regionId = regionId;
        iceClient = new Client(config);
    }

    public void runExample() throws Exception {

        // Video materials
        JSONObject mediaGroup1 = new JSONObject();
        mediaGroup1.put("GroupName", "start");
        mediaGroup1.put("MediaArray", Arrays.asList(
            "http://ice-document-materials.oss-cn-shanghai.aliyuncs.com/test_media/lgh/lgh-start-1.mp4"
        ));

        JSONObject mediaGroup2 = new JSONObject();
        mediaGroup2.put("GroupName", "middle");
        mediaGroup2.put("MediaArray", Arrays.asList(
            "http://ice-document-materials.oss-cn-shanghai.aliyuncs.com/test_media/lgh/lgh-m-1.mp4",
            "http://ice-document-materials.oss-cn-shanghai.aliyuncs.com/test_media/lgh/lgh-m-2.mp4",
            "http://ice-document-materials.oss-cn-shanghai.aliyuncs.com/test_media/lgh/lgh-m-3.mp4"
        ));

        JSONObject mediaGroup3 = new JSONObject();
        mediaGroup3.put("GroupName", "end");
        mediaGroup3.put("MediaArray", Arrays.asList(
            "http://ice-document-materials.oss-cn-shanghai.aliyuncs.com/test_media/lgh/lgh-end-1.mp4"
        ));

        JSONArray mediaGroupArray = new JSONArray();
        mediaGroupArray.add(mediaGroup1);
        mediaGroupArray.add(mediaGroup2);
        mediaGroupArray.add(mediaGroup3);

        // Voice-over scripts
        List<String> speechTextArray = Arrays.asList(
            "Where to play during the holidays? Yunnan Lugu Lake invites you to have a date with the nature. The blue lake is like a mirror, reflecting the unique customs of the women's kingdom of Mosuo, which is picturesque. Boat in the heart of the lake to feel the swaying of Zhucao boats, look up at mountain of goddess, and listen to the ancient and mysterious stories and legends. What are you waiting for? Come to Lugu Lake and enjoy the quiet and charming view.",
            "Are you still planning your vacation? Why not consider a natural feast at Lugu Lake in Yunnan. The lake, which is as a mirror, reflects the unique customs of the women's kingdom of Mosuo, which is poetic and picturesque. You can boat in the heart of the lake to feel the swaying of Zhucao boats, look up at mountain of goddess, and listen to the ancient and mysterious stories and legends. Come to Lugu Lake and enjoy the endless poetry brought by this quiet and charming view."
        );

        // The title of the video
        List<String> titleArray = Arrays.asList(
            "Lugu Lake: Mosuo Customs in Lakes and Mountains",
            "Explore the Secret Land of Lugu Lake",
            "Immersive Experience on Lugu Lake"
        );

        JSONObject inputConfig = new JSONObject();
        inputConfig.put("MediaGroupArray", mediaGroupArray);
        inputConfig.put("SpeechTextArray", speechTextArray);
        inputConfig.put("TitleArray", titleArray);

        // The number of videos produced.
        int produceCount = 4;

        // The width and height of the output videos in portrait mode.
        //int outputWidth = 1080;
        //int outputHeight = 1920;

        //// The width and height of the output videos in landscape mode.
        int outputWidth = 1920;
        int outputHeight = 1080;

        // The OSS URL of the output videos. The URL must contain the {index} placeholder.
        String mediaUrl = "http://" + bucket + ".oss-" + regionId + ".aliyuncs.com/script/output_{index}_w.mp4";

        JSONObject outputConfig = new JSONObject();
        outputConfig.put("MediaURL", mediaUrl);
        outputConfig.put("Count", produceCount);
        outputConfig.put("Width", outputWidth);
        outputConfig.put("Height", outputHeight);

        // Submit the quick video production job.
        SubmitBatchMediaProducingJobRequest request = new SubmitBatchMediaProducingJobRequest();
        request.setInputConfig(inputConfig.toJSONString());
        request.setOutputConfig(outputConfig.toJSONString());

        SubmitBatchMediaProducingJobResponse response = iceClient.submitBatchMediaProducingJob(request);
        String jobId = response.getBody().getJobId();
        System.out.println("Start script batch job, batchJobId: " + jobId);

        // Query the status of the tasks in a round-robin manner until all tasks are complete.
        System.out.println("Waiting job finished...");
        int maxTry = 3000;
        int i = 0;
        while (i < maxTry) {
            Thread.sleep(3000);
            i++;
            GetBatchMediaProducingJobRequest getRequest = new GetBatchMediaProducingJobRequest();
            getRequest.setJobId(jobId);
            GetBatchMediaProducingJobResponse getResponse = iceClient.getBatchMediaProducingJob(getRequest);
            String status = getResponse.getBody().getEditingBatchJob().getStatus();
            System.out.println("BatchJobId: " + jobId + ", status:" + status);

            if ("Failed".equals(status)) {
                System.out.println("Batch job failed. JobInfo: " + JSONObject.toJSONString(getResponse.getBody().getEditingBatchJob()));
                throw new Exception("Produce failed. BatchJobId: " + jobId);
            }

            if ("Finished".equals(status)) {
                System.out.println("Batch job finished. JobInfo: " + JSONObject.toJSONString(getResponse.getBody().getEditingBatchJob()));
                break;
            }
        }
    }
}

API request parameters

View InputConfig

{
  "MediaGroupArray": [{
    "GroupName": "start",
    "MediaArray": [
      "http://ice-document-materials.oss-cn-shanghai.aliyuncs.com/test_media/lgh/lgh-start-1.mp4"
    ]
  },
    {
      "GroupName": "middle",
      "MediaArray": [
        "http://ice-document-materials.oss-cn-shanghai.aliyuncs.com/test_media/lgh/lgh-m-1.mp4",
        "http://ice-document-materials.oss-cn-shanghai.aliyuncs.com/test_media/lgh/lgh-m-2.mp4",
        "http://ice-document-materials.oss-cn-shanghai.aliyuncs.com/test_media/lgh/lgh-m-3.mp4"
      ]
    },
    {
      "GroupName": "end",
      "MediaArray": [
        "http://ice-document-materials.oss-cn-shanghai.aliyuncs.com/test_media/lgh/lgh-end-1.mp4"
      ]
    }
  ],
  "SpeechTextArray": [
    "Where to play during the holidays? Yunnan Lugu Lake invites you to have a date with the nature. The blue lake is like a mirror, reflecting the unique customs of the women's kingdom of Mosuo, which is picturesque. Boat in the heart of the lake to feel the swaying of Zhucao boats, look up at mountain of goddess, and listen to the ancient and mysterious stories and legends. What are you waiting for? Come to Lugu Lake and enjoy the quiet and charming view.",
    "Are you still planning your vacation? Why not consider a natural feast at Lugu Lake in Yunnan. The lake, which is as a mirror, reflects the unique customs of the women's kingdom of Mosuo, which is poetic and picturesque. You can boat in the heart of the lake to feel the swaying of Zhucao boats, look up at mountain of goddess, and listen to the ancient and mysterious stories and legends. Come to Lugu Lake and enjoy the endless poetry brought by this quiet and charming view."
  ],
  "TitleArray": [
    "Lugu Lake: Mosuo Customs in Lakes and Mountains",
    "Explore the Secret Land of Lugu Lake",
    "Immersive Experience on Lugu Lake"
  ]
}

View OutputConfig

{
  "Count": 4,
  "Height": 1080,
  "Width": 1920,
  "MediaURL": "http://<your-bucket>.oss-<region-id>.aliyuncs.com/script/output_{index}_w.mp4"
}

Example

Portrait mode

Landscape mode

Mixing logic and advanced settings

Processing logic

Global broadcast mode:

  • If the input video is a long video, the video is split. During video mixing, the video clips are selected and mixed. The default length of each clip is 3 seconds. You can specify the SingleShotDuration parameter to configure the length of the clips. For more information, see the "EditingConfig parameters" section of this topic.

  • If a sufficient number of global voice-over scripts are provided, try to avoid selecting the same global voice-over script. For example, three broadcast texts are provided to produce five videos. The same voice-over scrip will appear in some videos. However, make sure that the three voice-over scripts are used at least once.

  • Randomly select a video clip from each group based on the sequence of the groups and then mix the clips. If a global voice-over script is provided and the video length is less than the length of the voice-over audio, random video clips are preferably selected from groups other than the first and last ones. The length of the output video equals the length of the voice-over audio.

  • Length rules for output videos:

    • A global voice-over script is provided: Length of the output video = Length of the voice-over audio.

    • No global voice-over script is provided:

      • If the FixedDuration parameter is specified, the length of the output video equals the value of the FixedDuration parameter.

      • If the MaxDuration parameter is specified, the length of the output video equals the product of the SingleShotDuration parameter multiplied by the number of groups (the length of the SpeechTextArray parameter). However, the video length does not exceed the value of the MaxDuration parameter.

Group broadcast mode:

  • Long videos are split in the same way as that in global broadcast mode. Compared with the global broadcast mode, voice-over scripts are added to groups based on the MediaGroup setting in group broadcast mode. Therefore, the SpeechTextArray parameter is added to MediaGroup. In group broadcast mode, you do not need to configure the SpeechText or SpeechTextArray parameters. For more information, see the "InputConfig parameters" section of this topic. If you configure these settings, errors will occur.

  • If the SpeechTextArray parameter is left empty, it indicates that the material group does not have voice-over clips specified. For more information, see the "MediaGroup parameters" section of this topic. Configure the Duration parameter to set the video clip length of the material group. The default length is 5 seconds.

  • You can add multiple voice-over clips to each material group. If all material groups have the same number of voice-over clips (excluding material groups that do not have voice-over clips), the voice-over clips are selected in sequence by default. For example, all material groups all use the Nth voice-over clip. If each material group has a different number of broadcast clips, each material group randomly selects a voice-over clip. Finally, the voice-over clips are mixed into a voice-over script.

Advanced settings

For more information, see Mixing logic and advanced settings for quickly producing videos.

References