Create and use regular templates

更新时间:
复制 MD 格式

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

  1. Log on to the Intelligent Media Services (IMS) console.

  2. In the left-side navigation pane, choose Intelligent Production > Online Editing to open the Online Editing page.

  3. 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

  1. 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"
                        }
                    }
                ]
            }
        ]
    }
  2. 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

  1. Log on to the Intelligent Media Services (IMS) console.

  2. In the left-side navigation pane, choose Intelligent Production > Template Factory to open the Template Factory page.

  3. Use a regular template for online editing.

    1. Click the Regular Templates tab.

    2. Find the desired template and click Use Template in the Actions column.

    3. 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

  1. 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 ClipsParam parameter.

      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 ClipsParam parameter:

      {
       "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 ID returned when you created the template in Step 2.

      The ClipsParam field in the response is as follows:

      {"1":"text","2":"mediaId","3":"mediaId","4":"mediaId","5":"mediaId"}
      Note

      You 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.

  2. Replace the placeholder text and mediaId values in the ClipsParam parameter 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"
    }
    Note

    ClipsParam is a parameter for the production service. Replace text with your desired caption text and mediaId with a media asset ID or an OSS URL for a video or image. You can use a mix of both.

  3. Submit a production task.

    Call the SubmitMediaProducingJob operation to submit an editing and production task. Pass the template ID and ClipsParam.

    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());