A regular template is based on the timeline of a video editing project and contains multiple media assets stitched together across layers. You can use regular templates to convert text and images into videos, create photo albums, generate intros and outros, and apply default watermarks.
Create a regular template
Create via the console
-
Log on to the Intelligent Media Services (IMS) console.
-
In the left-side navigation pane, choose to open the Online Editing page.
-
After you edit and save a video editing project, click Generate Template on the editing page, or click Export Template in the Actions column on the project list page to create a regular template.
To learn how to edit a template, see Designer guide for regular templates.
Create via an API
-
Customize the regular template config.
A regular template config is based on the timeline of an Online Editing project and offers significant flexibility. To customize your template, familiarize yourself with the config structure. For more information, see Details of a regular template config.
The following example shows the config for a video stitching template. For more examples, see Config examples for common regular templates.
{ "VideoTracks": [ { "VideoTrackClips": [ { "Sys_Type" : "ArrayItems", "Sys_ArrayObject" : "$VideoArray", "Sys_Template" : { "MediaId" : "$MediaId" } } ] } ] } -
Create a regular template.
Call the AddTemplate operation and pass the template config.
AddTemplateRequest request = new AddTemplateRequest(); request.setType("Timeline"); // Set Type to "Timeline" for a regular template. request.setName("Regular Template Test"); request.setConfig("{\"VideoTracks\":[{\"VideoTrackClips\":[{\"Sys_Type\":\"ArrayItems\",\"Sys_ArrayObject\":\"$VideoArray\",\"Sys_Template\":{\"MediaId\":\"$MediaId\"}}]}]}"); AddTemplateResponse response = iceClient.addTemplate(request); System.out.println("templateId : " + response.getBody().getTemplate().getTemplateId());A successful call returns a template ID. You can use this ID to submit a production task.
Use a regular template
Use via the console
-
Log on to the Intelligent Media Services (IMS) console.
-
In the left-side navigation pane, choose to open the Template Factory page.
-
Use a regular template for online editing.
-
Click the Regular Templates tab.
-
Find the desired template and click Use Template in the Actions column.
-
Enter a project name and click OK. Follow the prompts to start editing the project. For more information about how to edit a project (regular editing), see Editing features.
-
Use via an API
-
Get the template information.
-
From the console
If the template was created in the console, find it in the Template Factory. In the Actions column, click Edit Template. Then, use the Dynamic material management feature to construct the
ClipsParamparameter.Construct the parameter as follows: use the ID Naming value as the key, and the replacement text or media asset ID as the value. The following example shows the generated
ClipsParamparameter:{ "1": "Replaced subtitle text", "2": "****20b48fb04483915d4f2cd8ac****", "3": "****20b48fb04483915d4f2cd8ac****", "4": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/your-video1.mp4", "5": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/your-video2.mp4" } -
By calling an API
Call the GetTemplate operation to retrieve the template information. Pass the
template IDreturned when you created the template in Step 2.The
ClipsParamfield in the response is as follows:{"1":"text","2":"mediaId","3":"mediaId","4":"mediaId","5":"mediaId"}NoteYou can also use a preset template. The process is similar and is not detailed here. For available preset templates, see Regular templates in the public template library.
-
-
Replace the placeholder
textandmediaIdvalues in theClipsParamparameter from the example above.{ "1": "Replaced subtitle text", "2": "****20b48fb04483915d4f2cd8ac****", "3": "****20b48fb04483915d4f2cd8ac****", "4": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/your-video1.mp4", "5": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/your-video2.mp4" }NoteClipsParamis a parameter for the production service. Replacetextwith your desired caption text andmediaIdwith a media asset ID or an OSS URL for a video or image. You can use a mix of both. -
Submit a production task.
Call the SubmitMediaProducingJob operation to submit an editing and production task. Pass the
template IDandClipsParam.SubmitMediaProducingJobRequest request = new SubmitMediaProducingJobRequest(); request.setTemplateId("Your TemplateId"); request.setClipsParam("{\"1\":\"Replaced subtitle\",\"2\":\"****20b48fb04483915d4f2cd8ac****\",\"3\":\"****20b48fb04483915d4f2cd8ac****\",\"4\":\"****20b48fb04483915d4f2cd8ac****\",\"5\":\"****20b48fb04483915d4f2cd8ac****\"}"); request.setOutputMediaConfig("{\"MediaURL\":\"http://your-bucket.oss-cn-shanghai.aliyuncs.com/object.mp4\"}"); SubmitMediaProducingJobResponse response = iceClient.submitMediaProducingJob(request); System.out.println("jobid : " + response.getBody().getJobId());