Details of standard template Config

Updated at:

When you submit a video editing job with a `TemplateId`, the system merges the standard template `Config` with the `ClipsParam` input parameter into a Timeline that determines how the job is processed. The following examples show common standard template Configs and their resulting Timelines.

Example: Standard parameters in a Config

Add a watermark to a video

Config

{
    "VideoTracks": [
        {  
            "VideoTrackClips": [
                {    
                    "MediaId": "$Video"
                }
            ]
        }
    ],
    "ImageTracks": [
        {
            "ImageTrackClips": [
                {
                    "ImageId": "******e01cb05d417c3dbcd1b9******",
                    "Width" : 200,
                    "Height" : 60,
                    "X" : 40,
                    "Y" : 40
                }
            ]
        }
    ]
}

Timeline

{
    "VideoTracks": [
        {  
            "VideoTrackClips": [
                {    
                    "MediaId": "****20b48fb04483915d4f2cd8ac****"
                }
            ]
        }
    ],
    "ImageTracks": [
        {
            "ImageTrackClips": [
                {
                    "ImageId": "******e01cb05d417c3dbcd1b9******",
                    "Width" : 200,
                    "Height" : 60,
                    "X" : 40,
                    "Y" : 40
                }
            ]
        }
    ]
}

Analysis:

  • In a standard template `Config`, parameter fields start with a dollar sign ($), such as "$Video" in the preceding `Config` example.

  • To submit a video editing job, set `TemplateId` to IceSys_SingleVideo_Watermark and specify the Video field in `ClipsParam`. The final merged timeline is shown in the preceding Timeline example.

    http://ice.cn-shanghai.aliyuncs.com/?Action=SubmitMediaProducingJob
    &TemplateID=IceSys_SingleVideo_Watermark
    &ClipsParam={\"Video\":\"****20b48fb04483915d4f2cd8ac****\"}
    &<common parameters>

Add a watermark to a video (Config with default values)

Config

{
    "VideoTracks": [
        {  
            "VideoTrackClips": [
                {    
                    "MediaId": "$Video"
                }
            ]
        }
    ],
    "ImageTracks": [
        {
            "ImageTrackClips": [
                {
                    "ImageId": "******e01cb05d417c3dbcd1b9******",
                    "Width" : 200,
                    "Height" : 60,
                    "X" : "$X:40",
                    "Y" : "$Y:40",
                    "TimelineIn" : "$TimelineIn:0",
                    "TimelineOut" : "$TimelineOut:NULL"
                }
            ]
        }
    ]
}

Timeline

{
    "VideoTracks": [
        {  
            "VideoTrackClips": [
                {    
                    "MediaId": "****20b48fb04483915d4f2cd8ac****"
                }
            ]
        }
    ],
    "ImageTracks": [
        {
            "ImageTrackClips": [
                {
                    "ImageId": "******e01cb05d417c3dbcd1b9******",
                    "Width" : 200,
                    "Height" : 60,
                    "X" : 40,
                    "Y" : 40,
                    "TimelineIn" : 5
                }
            ]
        }
    ]
}

Analysis:

  • A standard template `Config` supports default values. If a parameter field is not specified in the request, the system uses its default value. In the preceding `Config`, "$TimelineIn:0" and "$TimelineOut:NULL" define default values, where the value after the colon (:) is the default.

  • If the default value is `NULL` and you do not include the parameter in the request, the system removes the field from the final Timeline.

  • To submit a video editing job, set `TemplateId` to IceSys_SingleVideo_Watermark and specify the required fields in `ClipsParam`. The final merged timeline is shown in the preceding Timeline example.

    http://ice.cn-shanghai.aliyuncs.com/?Action=SubmitMediaProducingJob
    &TemplateId=IceSys_SingleVideo_Watermark
    &ClipsParam={\"Video\":\"****20b48fb04483915d4f2cd8ac****\",\"TimelineIn\":\"5\"}
    &<common parameters>

Example: Array parameters in a Config

Mute an entire video track

Config

{
    "VideoTracks": [
        {
            "VideoTrackClips": [
                {
                    "Sys_Type" : "ArrayItems",
                    "Sys_ArrayObject" : "$VideoArray",
                    "Sys_Template" : {
                        "MediaId" : "$MediaId",
                        "Effects": [
                            {
                                "Type": "Volume",
                                "Gain": "0"
                            }
                        ]
                    }
                }
            ]
        }
    ]
}

Timeline

{
    "VideoTracks": [
        {
            "VideoTrackClips": [
                {
                    "MediaId" : "******05512043f49f697f7425******",
                    "Effects": [
                        {
                            "Type": "Volume",
                            "Gain": "0",
                        }
                    ]
                },
                {
                    "MediaId" : "******2788e810116a45109f2e******",
                    "Effects": [
                        {
                            "Type": "Volume",
                            "Gain": "0",
                        }
                    ]
                },
                {
                    "MediaId" : "******67f44f4964e6c998dee8******",
                    "Effects": [
                        {
                            "Type": "Volume",
                            "Gain": "0",
                        }
                    ]
                }
            ]
        }
    ]
}

Analysis:

  • The following code from the preceding `Config` example shows an array parameter, which lets you pass a variable number of media assets.

    {
        "Sys_Type" : "ArrayItems",
        "Sys_ArrayObject" : "$VideoArray",
        "Sys_Template" : {
            "MediaId" : "$MediaId",
            "Effects": [
                {
                    "Type": "Volume",
                    "Gain": "0"
                }
            ]
        }
    }

    To submit a video editing job, set `TemplateId` to IceSys_VideoMute and pass the `VideoArray` array in `ClipsParam`. The system traverses `VideoArray`, uses `Sys_Template` to generate each element, and encapsulates them into a new array. The final merged timeline is shown in the preceding Timeline example.

    http://ice.cn-shanghai.aliyuncs.com/?Action=SubmitMediaProducingJob
    &TemplateID=IceSys_VideoMute
    &ClipsParam={\"VideoArray\":[{\"MediaId\":\"******05512043f49f697f7425******\"},{\"MediaId\":\"******05512043f49f697f7425******\"},{\"MediaId\":\"******05512043f49f697f7425******\"}]}
    &<common parameters>
  • If `Sys_Template` contains only one parameter, you can simplify the input by passing values directly without specifying the parameter name for each array element. The final merged timeline is the same as the one in the preceding Timeline example.

    http://ice.cn-shanghai.aliyuncs.com/?Action=SubmitMediaProducingJob
    &TemplateID=IceSys_VideoMute
    &ClipsParam={\"VideoArray\":[\"b3f37e05512043f49f697f7425b9188b\",\"9987d22788e810116a45109f2ea88648\",\"a8f5f167f44f4964e6c998dee827110c\"]}
    &<common parameters>

Add an opening and a closing clip

Config

{
    "VideoTracks": [
        {
            "VideoTrackClips": [
                {
                    "MediaId": "******2788e810116a45109f2e******" // This is the opening video clip.
                },
                {
                    "Sys_Type" : "ArrayItems",
                    "Sys_ArrayObject" : "$VideoArray",
                    "Sys_Template" : {
                        "MediaId" : "$MediaId"
                    }
                },
                {
                    "MediaId": "******67f44f4964e6c998dee8******" // This is the closing video clip.
                }
            ]
        }
    ]
}

Timeline

{
    "VideoTracks": [
        {
            "VideoTrackClips": [
                {
                    "MediaId": "******2788e810116a45109f2e******" // This is the opening video clip.
                },
                {
                    "MediaId": "******05512043f49f697f7425******"
                },
                {
                    "MediaId": "******2788e810116a45109f2e******"
                },
                {
                    "MediaId": "******67f44f4964e6c998dee8******"
                },
                {
                    "MediaId": "******67f44f4964e6c998dee8******" // This is the closing video clip.
                }
            ]
        }
    ]
}

Analysis:

This standard template inserts a fixed opening clip at the beginning and a fixed closing clip at the end of the video track. The array parameter between them accepts a variable number of media assets. To submit a video editing job, set `TemplateId` to IceSys_OpeningEnding and pass the `VideoArray` array in `ClipsParam`.

http://ice.cn-shanghai.aliyuncs.com/?Action=SubmitMediaProducingJob
&TemplateID=IceSys_OpeningEnding
&ClipsParam={\"VideoArray\":[\"******05512043f49f697f7425******\",\"******2788e810116a45109f2e******\",\"******67f44f4964e6c998dee8******\"]}
&<common parameters>

To create the Timeline, the system traverses `VideoArray` and uses `Sys_Template` to generate each element, encapsulating them into a new array. The resulting initial Timeline has an abnormal format because the middle item in `VideoTrackClips` becomes a nested clip array, as shown below:

{
    "VideoTracks": [
        {
            "VideoTrackClips": [
                {
                    "MediaId": "******2788e810116a45109f2e******" // This is the opening video clip.
                },
                [
                    {
                        "MediaId": "******05512043f49f697f7425******"
                    },
                    {
                        "MediaId": "******2788e810116a45109f2e******"
                    },
                    {
                        "MediaId": "******67f44f4964e6c998dee8******"
                    }
                ],
                {
                    "MediaId": "******67f44f4964e6c998dee8******" // This is the closing video clip.
                }
            ]
        }
    ]
}

To handle this, Intelligent Media Services performs fault tolerance processing by extracting elements from the nested array and flattening them into a one-dimensional array. The final merged timeline is shown in the preceding Timeline example.

Related topics