This topic describes how to configure script-to-video parameters and the advanced settings. This topic also provides examples of SDK calls.
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
To mix video, audio, and image materials to produce multiple videos at a time, see SubmitBatchMediaProducingJob. For more information about the key API request parameters, see the following sections of this topic: InputConfig parameters, EditingConfig parameters, and OutputConfig parameters.
For information about how to query the detailed information about a quick video production job, see GetBatchMediaProducingJob.
InputConfig parameters
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
MediaGroup parameters
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 |
|
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 |
|
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 |
|
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 |
|
Sticker parameters
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.
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:
| 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:
Note The following examples show how the speech tempo is calculated:
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.
| No |
BackgroundMusicConfig | JSON | The configuration related to background music. Supported parameters:
| 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:
| No |
ProcessConfig | The mixing configuration. Supported parameters:
| ||
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.
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.
|
FixedDuration | Float | No | The fixed length of each video. If you specify a fixed length, all produced videos use the fixed length.
|
Width | Integer | Yes | The width of the output video in pixels. |
Height | Integer | Yes | The height of the output video in pixels. |
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:
API request parameters
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.