Get started
This topic describes how to use the IMS SDK to perform batch video production by calling the SubmitMediaProducingJob API.
Key concepts
Batch video production
Batch video production generates multiple unique videos by combining a small set of audio and video clips with different voiceover variations.
Use cases
Short video platforms often use deduplication algorithms to prevent content theft. To run a marketing campaign across multiple channels or accounts, you must create unique variations of your video ads. The batch video production feature automates this process. By customizing the timeline parameter in your SubmitMediaProducingJob API call, you can generate different video outputs to meet your needs.
Billing
Submitting an editing and production job may incur charges for multiple billable items. For more information, see intelligent production.
How it works
-
Combine video, audio, image, and subtitle clips into a finished video by submitting editing jobs with different timeline parameter configurations using the SubmitMediaProducingJob API.
-
A timeline is where you arrange clips and design effects for your video project. A timeline consists of three main objects: tracks, clips, and effects. For more information, see Timeline configuration.
-
The intelligent production feature supports editing and production, effect rendering, and template-based production for live streams, video-on-demand (VOD), and OSS clips. For more information, see Overview of intelligent production.
Before you begin
-
You have activated IMS.
-
You have created a RAM user and obtained its AccessKey pair. For more information, see Create and authorize a RAM user.
Step 1: Create an OSS bucket
Log on to the OSS console and click Buckets > Create Bucket. For the region, select China (Shanghai). Note the bucket name, as it is required for the sample code and will serve as the output destination for the edited videos.
For the creation mode, select Custom Creation.
Step 2: Run the batch video production code
-
Set up your environment:
-
Operating system: Windows 8.1 or later, macOS, or Linux.
-
IntelliJ IDEA: 2020.1 or later.
-
JDK: 1.8 or later.
-
-
Create a new Maven project to run the code.
-
Import the required third-party dependencies.
NoteThe server-side SDK version in the following sample code is for reference only. To get the latest version, see server-side SDK.
<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> </dependencies> -
Configure your AccessKey ID and AccessKey Secret. For more information, see Manage credentials. For other authentication methods, see Manage credentials.
NoteFor more ways to manage your credentials, see Manage credentials.
-
Create a new Java class and paste the following sample code.
-
Replace the bucket placeholder in the code with the name of the bucket you created in Step 1.
-
Run the code to generate the videos. The code performs the following workflow:
Generate a timeline > submit a video production job > poll the job status > print logs to the console.
public static void main(String[] args) throws Exception { BatchProduce batchProduce = new BatchProduce(); batchProduce.initClient(); batchProduce.run(); }SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. start job. jobid: 150de5f285c942b0894f1150ad5e6d50, outputMediaUrl: http://oushu-test-shanghai.oss-cn-shanghai.aliyuncs.com/ice_output/e0852f92dd2041e19e0739f4a7cee064.mp4 waiting job finished... jobId: 150de5f285c942b0894f1150ad5e6d50, status:Init jobId: 150de5f285c942b0894f1150ad5e6d50, status:Init jobId: 150de5f285c942b0894f1150ad5e6d50, status:Init jobId: 150de5f285c942b0894f1150ad5e6d50, status:Init jobId: 150de5f285c942b0894f1150ad5e6d50, status:Init jobId: 150de5f285c942b0894f1150ad5e6d50, status:Init jobId: 150de5f285c942b0894f1150ad5e6d50, status:Processing jobId: 150de5f285c942b0894f1150ad5e6d50, status:Processing jobId: 150de5f285c942b0894f1150ad5e6d50, status:Processing jobId: 150de5f285c942b0894f1150ad5e6d50, status:Success all job finished. Process finished with exit code 0 -
When the job status changes to Success, the outputMediaUrl provides the URL of the generated video. Because the bucket is private, you cannot open this URL directly. Instead, you must copy a signed URL from the OSS console to preview the video.
From the Buckets list, select your bucket. Choose File Management > File List and open the ice_output/ directory. Select the target .mp4 file. In the details panel, enable HTTPS, set an expiration time, and click Copy Object URL to get the signed URL.
-
The produceCount variable specifies the number of videos to generate. Modify this produceCount value to output a different number of videos. You can also replace the sample text and video clips with your own content. For more information, see the Timeline configuration documentation.
References
Next steps
-
To mix and edit videos or images by modifying the timeline, see Video and image mixing.
-
To process audio by modifying the timeline, see Audio processing.
-
To work with subtitles and subtitle templates by modifying the timeline, see Subtitles and subtitle templates.
-
To apply transitions, effects, and filters by modifying the timeline, see Transitions, effects, and filters.
-
To incorporate intelligent processing results into video production by modifying the timeline, see Use intelligent processing results in video production.
-
To configure other settings by modifying the timeline, see Other settings.