Common features for short videos

Updated at:
Copy as MD

Configure timeline parameters when you submit a video editing and composition job. The following examples demonstrate common short video features.

Property descriptions

For more information about the properties in the following examples, see Timeline configuration.

Timeline examples

Convert a landscape video to portrait and add black bars

If the source material in the Timeline is a landscape video, call the Video Composition operation to submit a composition job and set the output to portrait orientation by specifying the ProduceConfig, Width, and Height fields. The system centers the source material based on the dimensions of the source and output videos.

{ "VideoTracks": [{ "VideoTrackClips": [{ "MediaId":"756620ed48c9af022c66ee1cbe2e****" },{ "MediaId":"8f5cdf044b059b3adc7967ba1cbe****" },{ "MediaId":"70dc95c0e31b71edbfe76fa3691c****" }] }] }
Note

To customize the color of the black bars, set "SubType": "Color" in the Effects field. For more information about the Effects parameters, see Effect Type: Background settings.

Convert a landscape video to portrait and add blurred areas

If a media asset in the Timeline is a landscape video, you can render it in portrait style. Call the Video Composition API to submit a composition job and set the Width and Height fields in the ProduceConfig parameter. The system centers the media asset based on the dimensions of the asset and the final video, and blurs the padded areas.

{ "VideoTracks": [{ "VideoTrackClips": [{ "MediaId":"756620ed48c9af022c66ee1cbe2e****", "Effects": [{ "Type": "Background", "SubType": "Blur", "Radius": 0.1 }] }, { "MediaId":"8f5cdf044b059b3adc7967ba1cbe****", "Effects": [{ "Type": "Background", "SubType": "Blur", "Radius": 0.1 }] }, { "MediaId":"70dc95c0e31b71edbfe76fa3691c****", "Effects": [{ "Type": "Background", "SubType": "Blur", "Radius": 0.1 }] }] }] }

Convert a landscape video to portrait with a three-split screen effect

{ "VideoTracks": [{ "VideoTrackClips": [{ "MediaId":"222d9296e8864746a0b6f32dad6e****", "Width": 1, "Height": 0.3333, "X": 0, "Y": 0.3333 },{ "MediaId":"70dc95c0e31b71edbfe76fa3691cs****", "Width": 1, "Height": 0.3333, "X": 0, "Y": 0.3333 },{ "MediaId":"756620ed48c9af022c66ee1cbe2se****", "Width": 1, "Height": 0.3333, "X": 0, "Y": 0.3333 }] },{ "VideoTrackClips": [{ "MediaId":"222d9296e8864746a0b6f32dad6e****", "Width": 1, "Height": 0.3333, "X": 0, "Y": 0 },{ "MediaId":"70dc95c0e31b71edbfe76fa3691cs****", "Width": 1, "Height": 0.3333, "X": 0, "Y": 0 },{ "MediaId":"756620ed48c9af022c66ee1cbe2se****", "Width": 1, "Height": 0.3333, "X": 0, "Y": 0 }] },{ "VideoTrackClips": [{ "MediaId":"222d9296e8864746a0b6f32dad6e****", "Width": 1, "Height": 0.3333, "X": 0, "Y": 0.6666 },{ "MediaId":"70dc95c0e31b71edbfe76fa3691cs****", "Width": 1, "Height": 0.3333, "X": 0, "Y": 0.6666 },{ "MediaId":"756620ed48c9af022c66ee1cbe2se****", "Width": 1, "Height": 0.3333, "X": 0, "Y": 0.6666 }] }], "SubtitleTracks":[ { "SubtitleTrackClips": [ { "Type": "Text", "X": 0, "Y": 200, "Font": "AlibabaPuHuiTi", "Content": "This is the title", "Alignment": "TopCenter", "FontSize": 80, "FontColorOpacity": 1, "1FontColor": "#ffffff", "FontColor": "#FFDEAD", "FontFace": { "Bold": true, "Italic": false, "Underline": false } } ] }, { "SubtitleTrackClips":[ { "Type":"Text", "X": 0, "Y": 200, "Font": "AlibabaPuHuiTi", "Content": "This is the title", "Alignment": "TopCenter", "FontSize": 80, "FontColorOpacity": 1, "FontColor": "#ffffff", "FontFace": { "Bold": true, "Italic": false, "Underline": false } }, { "Type":"Text", "X": 0, "Y": 320, "Font": "KaiTi", "Content": "This is the subtitle", "Alignment": "TopCenter", "FontSize": 45, "FontColor": "#ffffff", "FontFace": { "Bold": false, "Italic": true, "Underline": true } },{ "Type":"Text", "X": 0, "Y": 900, "Font": "AlibabaPuHuiTi", "Content": "This is a banner caption\nYou can add a line feed for multi-line display", "Alignment": "TopCenter", "FontSize": 40, "FontColor": "#ffffff", "FontFace": { "Bold": true, "Italic": false, "Underline": false } } ] } ] }

Flip a video horizontally and vertically

{ "VideoTracks": [ { "VideoTrackClips": [ { "MediaId":"222d9296e8864746a0b6f32dad6e****", "Width": 0.48, "Height": 0.49, "X": 0, "Y": 0, "Effects": [ { "Type": "Text", "FixedX": 0, "FixedY": 0, "FontURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/material/AliHYAiHei.ttf", "Content": "Original video", "Alignment": "TopLeft", "FontSize": 100, "FontColor": "#F5FFFA", "TimelineIn": 0, "TimelineOut": 10, "Outline": 2, "OutlineColour": "#0e0100" } ] } ] }, { "VideoTrackClips": [ { "MediaId":"222d9296e8864746a0b6f32dad6e****", "Width": 0.48, "Height": 0.49, "X": 0.5, "Y": 0, "Effects": [ { "Type": "Flip", "Direction": "horizontal" },{ "Type": "Text", "FixedX": 0.5, "FixedY": 0, "FontURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/material/AliHYAiHei.ttf", "Content": "Horizontal flip", "Alignment": "TopLeft", "FontSize": 100, "FontColor": "#F5FFFA", "TimelineIn": 0, "TimelineOut": 10, "Outline": 2, "OutlineColour": "#0e0100" } ] } ] }, { "VideoTrackClips": [ { "MediaId":"222d9296e8864746a0b6f32dad6e****", "Width": 0.48, "Height": 0.49, "X": 0, "Y": 0.5, "Effects": [ { "Type": "Flip", "Direction": "vertical" },{ "Type": "Text", "FixedX": 0, "FixedY": 0.5, "FontURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/material/AliHYAiHei.ttf", "Content": "Vertical flip", "Alignment": "TopLeft", "FontSize": 100, "FontColor": "#F5FFFA", "TimelineIn": 0, "TimelineOut": 10, "Outline": 2, "OutlineColour": "#0e0100" } ] } ] }, { "VideoTrackClips": [ { "MediaId":"222d9296e8864746a0b6f32dad6e****", "Width": 0.48, "Height": 0.49, "X": 0.5, "Y": 0.5, "Effects": [ { "Type": "Flip", "Direction": "horizontal" },{ "Type": "Flip", "Direction": "vertical" },{ "Type": "Text", "FixedX": 0.5, "FixedY": 0.5, "FontURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/material/AliHYAiHei.ttf", "Content": "Horizontal and vertical flip", "Alignment": "TopLeft", "FontSize": 100, "FontColor": "#F5FFFA", "TimelineIn": 0, "TimelineOut": 10, "Outline": 2, "OutlineColour": "#0e0100" } ] } ] } ] }

Add captions

Set the TimelineIn and TimelineOut fields to specify the start and end times for a caption. If these fields are not set, the caption is displayed throughout the entire video, which is a common approach for global captions.

{ "VideoTracks": [{ "VideoTrackClips": [{ "MediaId":"756620ed48c9af022c66ee1cbe2e****" }, { "MediaId":"8f5cdf044b059b3adc7967ba1cbe****" }, { "MediaId":"70dc95c0e31b71edbfe76fa3691c****" }] }], "SubtitleTracks": [{ "SubtitleTrackClips": [{ "Type": "Text", "X": 0, "Y": 200, "Font": "AlibabaPuHuiTi", "Content": "This is the title", "Alignment": "TopCenter", "FontSize": 80, "FontColorOpacity": 1, "FontColor": "#ffffff", "FontFace": { "Bold": true, "Italic": false, "Underline": false } }, { "Type": "Text", "X": 0, "Y": 320, "Font": "KaiTi", "Content": "This is the subtitle", "Alignment": "TopCenter", "FontSize": 45, "FontColor": "#ffffff", "FontFace": { "Bold": false, "Italic": true, "Underline": true } }, { "Type": "Text", "X": 50, "Y": 740, "Font": "AlibabaPuHuiTi", "Content": "Rotate angle", "FontColor": "#FFD700", "Outline": 4, "Angle": 350, "OutlineColour": "#000000", "FontSize": 60, "FontFace": { "Bold": true, "Italic": false, "Underline": false } }, { "Type": "Text", "X": 0, "Y": 900, "Font": "AlibabaPuHuiTi", "Content": "This is a banner caption\nYou can add a line feed for multi-line display", "Alignment": "TopCenter", "FontSize": 40, "FontColor": "#ffffff", "FontFace": { "Bold": true, "Italic": false, "Underline": false } }, { "Type": "Text", "X": 0, "Y": 1000, "Font": "KaiTi", "Content": "Set the start and end times for the caption", "Alignment": "TopCenter", "FontSize": 40, "FontColor": "#ffffff", "TimelineIn": 5, "TimelineOut": 25, "FontFace": { "Bold": false, "Italic": true, "Underline": false } } ] }] }

Add outline and shadow effects to captions

{ "VideoTracks": [{ "VideoTrackClips": [{ "MediaId":"001d9296e8864746a0b6f32dad6e****" }] }], "SubtitleTracks":[ { "SubtitleTrackClips":[ { "Type":"Text", "X": 0, "Y": 210, "Font": "WenQuanYi Zen Hei Mono", "Content": "This is the subtitle", "Alignment": "TopCenter", "FontSize": 50, "FontColor": "#000000", "TimelineIn": 0, "TimelineOut": 10, "OutlineColour": "#ffffff", "Outline": 2, "FontFace": { "Bold": false, "Italic": false, "Underline": false } }, { "Type":"Text", "X": 0, "Y": 270, "Font": "WenQuanYi Zen Hei Mono", "Content": "This is the title", "Alignment": "TopCenter", "OutlineColour": "#000000", "Outline": 3, "FontSize": 70, "TimelineIn": 0, "TimelineOut": 10, "FontColor": "#ffffff", "FontFace": { "Bold": true, "Italic": false, "Underline": false } }, { "Type": "Text", "Y": 750, "Font": "AlibabaPuHuiTi", "Content": "This is the main title", "Alignment": "TopCenter", "FontSize": 100, "FontColor": "#FFD700", "Outline": 4, "OutlineColour": "#000000", "TimelineIn": 0, "TimelineOut": 10, "FontFace": { "Bold": true, "Italic": false, "Underline": false } }, { "Type": "Text", "Y": 850, "Content": "Custom font file", "Font": "KaiTi", "FontSize": 42, "Outline": 2, "OutlineColour": "#ee00ff", "FontUrl":"https://your-bucket.oss-cn-shanghai.aliyuncs.com/your_font.ttf", "TimelineIn": 0, "TimelineOut": 10, "Alignment": "TopCenter", "FontColor": "#000000", "FontFace": { "Bold": false, "Italic": false, "Underline": false } }, { "Type": "Text", "Y": 900, "Font": "WenQuanYi Zen Hei Mono", "Content": "Shadow effect", "FontColor": "#ffffff", "FontSize": 40, "Outline": 2, "OutlineColour": "#DB7093", "Shadow": 3, "BackColour": "#FFF0F5", "TimelineIn": 0, "TimelineOut": 10, "Alignment": "TopCenter", "FontFace": { "Bold": false, "Italic": false, "Underline": false } }, { "Type": "Text", "Y": 980, "Font": "WenQuanYi Zen Hei Mono", "Content": "Add caption animation", "FontColor": "#ffffff", "FontSize": 50, "TimelineIn": 0, "TimelineOut": 10, "Alignment": "TopCenter", "AaiMotionLoopEffect": "rollleft_display", "FontFace": { "Bold": true, "Italic": false, "Underline": false } } ] } ] }

Set local effects for captions

Add override code to the Content field to apply local effects to captions. The override code works as follows:

  • All override code starts with two backslashes (\\).

  • All local parameter override code must be enclosed in braces ({}). A single pair of braces can contain multiple override codes.

  • The override code affects the subsequent captions. To end the effect, you must add a corresponding closing override code.

{ "VideoTracks": [ { "VideoTrackClips": [ { "MediaId":"333d9296e8864746a0b6f32dad6e****" } ] } ], "SubtitleTracks": [ { "SubtitleTrackClips": [ { "Type": "Text", "X": 0, "Y": 150, "FontURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/material/AliHYAiHei.ttf", "Content": "Set the text color to {\\1c&0801ea&\\3c&f7fcff&}dark red{\\1c\\3c}", "Alignment": "TopCenter", "FontSize": 65, "FontColor": "#F5FFFA", "TimelineIn": 0, "TimelineOut": 10, "Outline": 2, "OutlineColour": "#0e0100" }, { "Type": "Text", "X": 0, "Y": 300, "FontURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/material/AliHYAiHei.ttf", "Content": "Set the font size to {\\fs100}100{\\fs}", "Alignment": "TopCenter", "FontColor": "#F5FFFA", "FontSize": 65, "TimelineIn": 0, "TimelineOut": 10, "Outline": 2, "OutlineColour": "#0e0100" }, { "Type": "Text", "Y": 450, "FontURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/material/AliHYAiHei.ttf", "Content": "Set the {\\bord3\\3c&CD0000&}outline{\\bord\\3c} color and size", "Alignment": "TopCenter", "FontSize": 65, "FontColor": "#F5FFFA", "TimelineIn": 0, "TimelineOut": 10, "Outline": 2, "OutlineColour": "#0e0100" }, { "Type": "Text", "Y": 600, "Content": "Set the {\\bord3\\3c&701919&}opaque background{\\bord\\3c} color and size", "FontURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/material/AliHYAiHei.ttf", "FontSize": 65, "TimelineIn": 0, "TimelineOut": 10, "Alignment": "TopCenter", "FontColor": "#F5FFFA", "BorderStyle": 3, "Outline": 0, "OutlineColour": "#0000CD" }, { "Type": "Text", "Y": 750, "FontURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/material/AliHYAiHei.ttf", "Content": "Set the font to {\\fnKaiTi}SimHei{\\fn}", "FontSize": 65, "TimelineIn": 0, "TimelineOut": 10, "FontColor": "#F5FFFA", "Alignment": "TopCenter", "Outline": 2, "OutlineColour": "#0e0100" }, { "Type": "Text", "Y": 900, "FontURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/material/AliHYAiHei.ttf", "Content": "Apply the {\\b1}bold{\\b0} effect", "FontSize": 65, "TimelineIn": 0, "TimelineOut": 10, "FontColor": "#F5FFFA", "Alignment": "TopCenter", "Outline": 2, "OutlineColour": "#0e0100" }, { "Type": "Text", "Y": 1050, "FontURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/material/AliHYAiHei.ttf", "Content": "Apply the {\\i1}italic{\\i0} effect", "FontSize": 65, "TimelineIn": 0, "TimelineOut": 10, "FontColor": "#F5FFFA", "Alignment": "TopCenter", "Outline": 2, "OutlineColour": "#0e0100" }, { "Type": "Text", "Y": 1200, "FontURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/material/AliHYAiHei.ttf", "Content": "Apply the {\\u1}underline{\\u0} effect", "FontColor": "#F5FFFA", "FontSize": 65, "TimelineIn": 0, "TimelineOut": 10, "Alignment": "TopCenter", "Outline": 2, "OutlineColour": "#0e0100" }, { "Type": "Text", "Y": 1350, "FontURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/material/AliHYAiHei.ttf", "Content": "Apply the {\\s1}strikethrough{\\s0} effect", "FontColor": "#F5FFFA", "FontSize": 65, "TimelineIn": 0, "TimelineOut": 10, "Alignment": "TopCenter", "Outline": 2, "OutlineColour": "#0e0100" }, { "Type": "Text", "Y": 1500, "FontURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/material/AliHYAiHei.ttf", "Content": "Apply the {\\1c&00FF00&\\b1\\fs100\\i1}combined{\\1c\\b0\\fs\\i0} effect", "FontColor": "#F5FFFA", "FontSize": 65, "TimelineIn": 0, "TimelineOut": 10, "Alignment": "TopCenter", "Outline": 2, "OutlineColour": "#0e0100" } ] } ] }

Detailed description of override parameters:

Override parameter

Description

Example of the Content parameter

  • \\1c&[BBGGRR]&

  • \\2c&[BBGGRR]&

  • \\3c&[BBGGRR]&

1c, 2c, and 3c specify the colors of the font, border, and shadow, respectively. [BBGGRR] is the hexadecimal BGR value of the color, which is the reverse of the RGB color order.

"Set the color to {\\1c&00FF7F&}green{\\1c}"

  • \\bord[width]

  • \\xbord[width]

  • \\ybord[width]

bord, xbord, and ybord specify the widths of the border, the border along the x-axis, and the border along the y-axis, respectively. The unit is pixel.

"Set the {\\bord3\\3c&EBCE87&}outline width{\\bord\\3c}, color, and size"

\\b1 \\b0

b1 applies the bold effect. b0 cancels the bold effect.

"Apply the {\\b1}bold{\\b0} effect",

\\i1 \\i0

i1 applies the italic effect. i0 cancels the italic effect.

"Apply the {\\i1}italic{\\i0} effect"

\\u1 \\u0

u1 applies the underline effect. u0 cancels the underline effect.

"This applies the underline effect."

\\s1 \\s0

s1 applies the strikethrough effect. s0 cancels the strikethrough effect.

"Apply the {\\s1}strikethrough{\\s0} effect"

\\fs[font size]

The font size of the caption. The unit is pixel.

"Set the font size to {\\fs100}100{\\fs}"

\\fn[font name]

The name of the caption. Custom fonts are not supported.

"Set the font to {\\fnKaiTi}SimHei{\\fn}"

Set automatic caption wrapping

{ "VideoTracks": [ { "VideoTrackClips": [ { "MediaId":"333d9296e8864746a0b6f32dad6e****" } ] } ], "SubtitleTracks": [ { "SubtitleTrackClips": [ { "Type": "Text", "X": 0, "Y": 400, "FontURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/material/AliHYAiHei.ttf", "Content": "If automatic wrapping or scaling is not set, the caption may exceed the video canvas", "Alignment": "TopCenter", "FontSize": 100, "FontColor": "#F5FFFA", "TimelineIn": 0, "TimelineOut": 10, "Outline": 2, "OutlineColour": "#0e0100" }, { "Type": "Text", "X": 0, "Y": 900, "FontURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/material/AliHYAiHei.ttf", "Content": "Automatic wrapping is triggered when the caption exceeds the video dimensions", "AdaptMode": "AutoWrap", "Alignment": "TopCenter", "FontSize": 100, "FontColor": "#F5FFFA", "TimelineIn": 0, "TimelineOut": 10, "Outline": 2, "OutlineColour": "#0e0100" }, { "Type": "Text", "X": 0, "Y": 1400, "FontURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/material/AliHYAiHei.ttf", "Content": "Automatic scaling is triggered when the caption exceeds the video dimensions", "AdaptMode": "AutoScale", "Alignment": "TopCenter", "FontSize": 100, "FontColor": "#F5FFFA", "TimelineIn": 0, "TimelineOut": 10, "Outline": 2, "OutlineColour": "#0e0100" } ] } ] }

Add GIF stickers

Configure the DyncFrames field to set the frame rate of the animated image.

{ "VideoTracks": [{ "VideoTrackClips": [{ "MediaId":"756620ed48c9af022c66ee1cbe2e****" },{ "MediaId":"8f5cdf044b059b3adc7967ba1cbe****" },{ "MediaId":"70dc95c0e31b71edbfe76fa3691c****" }] },{ "VideoTrackClips": [{ "MediaId":"333d9296e8864746a0b6f32dad6e****", "Type": "image", "Duration": 10, "TimelineIn": 0, "DyncFrames": 10, "X": 50, "Y": 1300, "Effects": [{ "Type": "Scale", "Width": 200, "Height": 200 }] },{ "MediaId":"ea9a6f9bdb68419abfd36a7113cf****", "Type": "image", "Duration": 10, "TimelineIn": 10, "DyncFrames": 10, "X": 800, "Y": 400, "Effects": [{ "Type": "Scale", "Width": 200, "Height": 200 }] },{ "MediaId":"3f7e62d41a334dec9ac802b0f165****", "Type": "image", "Duration": 10, "TimelineIn": 20, "DyncFrames": 10, "X": 100, "Y": 400, "Effects": [{ "Type": "Scale", "Width": 200, "Height": 200 }] }] }] }

Global effects and filters

To apply effects and filters to the entire video, add them to the EffectTrack property. You do not need to set TimelineIn and TimelineOut. The effects are rendered throughout the entire video.

{ "VideoTracks": [{ "VideoTrackClips": [{ "MediaId":"756620ed48c9af022c66ee1cbe2e****" }, { "MediaId":"8f5cdf044b059b3adc7967ba1cbe****" }, { "MediaId":"70dc95c0e31b71edbfe76fa3691c****" }] }], "EffectTracks": [{ "EffectTrackItems": [{ "Type": "Filter", "SubType": "PL2" }] }] }

Set a global background and a global logo

Configure "Type": "GlobalImage" to display an image throughout the entire video. You do not need to configure Duration.

{ "VideoTracks": [{ "VideoTrackClips": [{ "MediaId":"222d9296e8864746a0b6f32dad6e****", "Type": "GlobalImage" }] }, { "VideoTrackClips": [{ "MediaId":"001d9296e8864746a0b6f32dad4e****", "Effects": [{ "Type": "Volume", "Gain": 0 }] }, { "MediaId":"333d9296e8864746a0b6f32dad5e****", "Effects": [{ "Type": "Volume", "Gain": 0 }] }, { "MediaId":"444d9296e8864746a0b6f32dad7e****", "Effects": [{ "Type": "Volume", "Gain": 0 }] }, { "MediaId":"555d9296e8864746a0b6f32dad8e****", "Effects": [{ "Type": "Volume", "Gain": 0 }] }, { "MediaId":"8f5cdf044b059b3adc7967ba1cbe****" }] }, { "VideoTrackClips": [{ "MediaId":"756620ed48c9af022c66ee1cbe2e****", "Type": "GlobalImage", "X": 0.1, "Y": 0.1, "Width": 247, "Height": 74 }] }] }