Intelligent Media Production lets you use advanced templates for video editing to create complex motion graphics and advanced media effects. This topic describes how to create and use advanced templates.
Create an advanced template
Upload via the console
Export an After Effects (AE) project as a template file in .zip format using VE Exporter. For more information, see Advanced template creation process.
Upload the template file in the Template Factory console.
Create using OpenAPI
Call the AddTemplate operation to create a template. Set the `config` parameter to the Object Storage Service (OSS) URL of the advanced template.
AddTemplateRequest request = new AddTemplateRequest();
request.setType("VETemplate");
request.setName("AdvancedTemplateTest");
request.setConfig("{\"oss_url\":\"http://your-bucket.oss-cn-shanghai.aliyuncs.com/object.zip\"}");
AddTemplateResponse response = iceClient.addTemplate(request);
System.out.println("templateId : " + response.getBody().getTemplate().getTemplateId());The oss_url value shown for the advanced template is an example. Set the parameter as required.
Use an advanced template
Using the console
To use an advanced template for video editing, see Use an advanced template for online editing.
Using OpenAPI
Retrieve template information.
Call the GetTemplate operation and set the
TemplateIdparameter to retrieve the template information.GetTemplateRequest request = new GetTemplateRequest(); request.setTemplateId("****20b48fb04483915d4f2cd8ac****"); GetTemplateResponse response = iceClient.getTemplate(request); GetTemplateResponseBody.GetTemplateResponseBodyTemplate template = response.getBody().getTemplate(); System.out.println("templateId : " + template.getTemplateId()); System.out.println("clipsParam : " + template.getClipsParam());The following example shows a sample response:
{ "RequestId":"******11-DB8D-4A9A-875B-275798******", "Template":{ "TemplateId":"****20b48fb04483915d4f2cd8ac****", "Name":"AdvancedTemplateTest", "Type":"VETemplate", "Status":"Available", "ModifiedSource":"OpenAPI", "CreateSource":"OpenAPI", "Config":"{\"oss_url\":\"http://your-bucket.oss-cn-shanghai.aliyuncs.com/object.zip\"}", "ClipsParam":"{\"Text7\":\"text\",\"Text6\":\"text\",\"Text5\":\"text\",\"Text4\":\"text\",\"Text3\":\"text\",\"Text2\":\"text\",\"Text1\":\"text\",\"Text0\":\"text\",\"Media3\":\"mediaId\",\"Media2\":\"mediaId\",\"Media1\":\"mediaId\",\"Media0\":\"mediaId\"}", "PreviewMedia":"", "CoverURL":"" } }NoteYou can also use system-provided templates. The procedure is similar to using a custom template. For more information about system-provided templates, see Public template library - Advanced templates.
As required, replace the
textandmediaIdfields in theClipsParamparameter that was returned in the previous step.{ "Text0":"Caption0", "Text1":"Caption1", "Text2":"Caption2", "Text3":"Caption3", "Text4":"Caption4", "Text5":"Caption5", "Text6":"Caption6", "Text7":"Caption7", "Media0":"****20b48fb04483915d4f2cd8ac****", "Media1":"****20b48fb04483915d4f2cd8ac****", "Media2":"****20b48fb04483915d4f2cd8ac****", "Media3":"****20b48fb04483915d4f2cd8ac****" }NoteClipsParamis a parameter for the production service. You can replace `text` with your text content and `mediaId` with a media asset ID or its OSS URL. Videos and images are supported. You can use a combination of IDs and URLs.If you set only some fields in the
ClipsParamparameter, unspecified captions are empty by default, and unspecified media assets default to the original assets in the template.You can set fonts for captions and adaptation modes for videos and images. For more information, see Extended features.
You can call the synthesis service.
Call the SubmitMediaProducingJob operation to submit a video editing and production job. Set the
TemplateIdandClipsParamparameters.SubmitMediaProducingJobRequest request = new SubmitMediaProducingJobRequest(); request.setTemplateId("****20b48fb04483915d4f2cd8ac****"); request.setClipsParam("{\"Text7\":\"Caption7\",\"Text6\":\"Caption6\",\"Text5\":\"Caption5\",\"Text4\":\"Caption4\",\"Text3\":\"Caption3\",\"Text2\":\"Caption2\",\"Text1\":\"Caption1\",\"Text0\":\"Caption0\",\"Media3\":\"****20b48fb04483915d4f2cd8ac****\",\"Media2\":\"****20b48fb04483915d4f2cd8ac****\",\"Media1\":\"****20b48fb04483915d4f2cd8ac****\",\"Media0\":\"****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());
Extended features
Set adaptation modes for videos and images
You can use .adapt_type to set the scaling mode for videos and images. The valid values are:
0: No adaptation.
1: Center and fill.
2: Fit and center.
3: Non-proportional scaling.
{
"Text7":"Caption7",
"Text6":"Caption6",
"Text5":"Caption5",
"Text4":"Caption4",
"Text3":"Caption3",
"Text2":"Caption2",
"Text1":"Caption1",
"Text0":"Caption0",
"Media3":"https://your-bucket.oss-cn-shanghai.aliyuncs.com/object01.jpg",
"Media2":"https://your-bucket.oss-cn-shanghai.aliyuncs.com/object02.jpg",
"Media1":"https://your-bucket.oss-cn-shanghai.aliyuncs.com/object03.jpg",
"Media0":"https://your-bucket.oss-cn-shanghai.aliyuncs.com/object04.jpg",
"Media3.adapt_type":0,
"Media2.adapt_type":1,
"Media1.adapt_type":2,
"Media0.adapt_type":3
}Change caption fonts
You can use .font_file to set the caption font. You can also specify an OSS URL to use your own font. For a list of fonts, see Font list.
{
"Text7.font_file":"SimSun",
"Text6.font_file":"Yuanti",
"Text5.font_file":"https://your-bucket.oss-cn-shanghai.aliyuncs.com/your-font1.ttf",
"Text4.font_file":"https://your-bucket.oss-cn-shanghai.aliyuncs.com/your-font2.ttf",
"Text7":"Caption7",
"Text6":"Caption6",
"Text5":"Caption5",
"Text4":"Caption4",
"Text3":"Caption3",
"Text2":"Caption2",
"Text1":"Caption1",
"Text0":"Caption0",
"Media3":"https://your-bucket.oss-cn-shanghai.aliyuncs.com/object01.jpg",
"Media2":"https://your-bucket.oss-cn-shanghai.aliyuncs.com/object02.jpg",
"Media1":"https://your-bucket.oss-cn-shanghai.aliyuncs.com/object03.jpg",
"Media0":"https://your-bucket.oss-cn-shanghai.aliyuncs.com/object04.jpg"
}Other settings
The ClipsParam parameter also supports the following settings. These settings allow you to edit media assets during the video editing process:
{
// Media asset
"Media1": "a8f5f167f44f4964e6c998dee827110c",
"Media1.loop": 1, // Valid for video/GIF assets. 0: Use the default loop logic of the engine. 1: Loop. 2: Do not loop.
"Media1.volume": 0.5, // Valid for video assets. The volume must be greater than or equal to 0. The standard range is 0 to 1. The default value is 0.
"Media1.adapt_type": 0, // Adaptation mode. 0: No adaptation. 1: cover (center and fill the space). 2: contain (fit and center). 3: fill (non-proportional scaling). 4: transform (use the matrix specified by the transform field). The default value is 1.
"Media1.transform": [a,c,e,b,d,f], // Row matrix: [scale, skewX, transX, skewY, scaleY, transY]. This is a local coordinate system matrix for the original image. The default is an identity matrix.
"Media1.clip_start": 0.0, // The start time for video clipping. If you do not need to clip the video, do not pass this parameter. clip_end must be greater than clip_start.
"Media1.clip_end": 10.0, // The end time for video clipping. A value greater than 0 indicates that the end of the video is clipped. A value less than or equal to 0 indicates that the end is not clipped.
// Caption
"Text1":"TestCaption",
"Text1.adapt": true, // Specifies whether to enable text adaptation. This is valid only for text box-type text. By default, the adaptation mode from the template design is used.
"Text1.fill": "#FFFFFF", // Text fill color.
"Text1.stroke": "#FFFFFF", // Text stroke color.
"Text1.stroke_width": 0.0, // Stroke width.
"Text1.stroke_over_fill": false, // Specifies whether the stroke is rendered over the fill.
"Text1.size": 10, // Font size in pixels.
"Text1.font_file": "SimSun" // Font family name.
}