This topic provides examples of common Timeline configurations for text overlays when you edit videos using OpenAPI. These examples include overlaying text for the full duration of a video and overlaying text in a specified region.
Related APIs
Parameters
Parameter | Description |
Text coordinates |
The value can be a percentage or a pixel value:
|
Text properties |
|
Time range for the text overlay |
|
Timeline examples
Full-duration text overlay
A full-duration text overlay appears from the beginning to the end of the video. You do not need to specify TimelineIn and TimelineOut. The position of the text in the output video is determined by X and Y. The following code provides an example:
{
"VideoTracks": [
{
"VideoTrackClips": [
{
"MediaId": "ea9a6f9bdb68419abfd36a7113cf****",
"Effects": [
{
"Type": "Text",
"X": 31,
"Y": 93,
"Font": "WenQuanYi Zen Hei Mono",
"Content": "Test text",
"FontSize": 26,
"FontColorOpacity": 0.2,
"FontColor": "#000000",
"FontFace": {
"Bold": true,
"Italic": false,
"Underline": false
}
},
{
"Type": "Text",
"X": 30,
"Y": 92,
"Font": "WenQuanYi Zen Hei Mono",
"Content": "Test text",
"FontSize": 26,
"FontColorOpacity": 1,
"FontColor": "#FFFFFF"
},
{
"Type": "Text",
"X": 0.8123,
"Y": 0.7896,
"Font": "WenQuanYi Zen Hei Mono",
"Content": "Test text",
"FontSize": 26,
"FontColorOpacity": 0.2,
"FontColor": "#000000"
},
{
"Type": "Text",
"X": 0.8223,
"Y": 0.7796,
"Font": "WenQuanYi Zen Hei Mono",
"Content": "Test text",
"FontSize": 26,
"FontColorOpacity": 1,
"FontColor": "#FFFFFF"
}
]
}
]
}
]
}Specified-region text overlay
A specified-region text overlay displays text on a video within a specific time range. The position of the text in the output video is determined by X and Y. The following code provides an example of how to overlay text on a video from 0 to 5 seconds and from 5 to 10 seconds:
If
TimelineInis not set, the default value is 0.If you do not set
TimelineOut, the overlay continues to the end of the video by default.If the value of
TimelineOutexceeds the video duration, the overlay ends at the end of the video track.
{
"VideoTracks": [
{
"VideoTrackClips": [
{
"MediaId": "ea9a6f9bdb68419abfd36a7113cf****",
"Effects": [
{
"Type": "Text",
"X": 31,
"Y": 93,
"TimelineIn": 0,
"TimelineOut": 5,
"Font": "WenQuanYi Zen Hei Mono",
"Content": "Test text",
"FontSize": 26,
"FontColorOpacity": 0.2,
"FontColor": "#000000",
"FontFace": {
"Bold": true,
"Italic": false,
"Underline": false
}
},
{
"Type": "Text",
"X": 30,
"Y": 92,
"TimelineIn": 0,
"TimelineOut": 5,
"Font": "WenQuanYi Zen Hei Mono",
"Content": "Test text",
"FontSize": 26,
"FontColorOpacity": 1,
"FontColor": "#FFFFFF"
},
{
"Type": "Text",
"X": 1124,
"Y": 516,
"TimelineIn": 5,
"TimelineOut": 10,
"Font": "WenQuanYi Zen Hei Mono",
"Content": "Test text",
"FontSize": 26,
"FontColorOpacity": 0.2,
"FontColor": "#000000"
},
{
"Type": "Text",
"X": 1123,
"Y": 515,
"TimelineIn": 5,
"TimelineOut": 10,
"Font": "WenQuanYi Zen Hei Mono",
"Content": "Test text",
"FontSize": 26,
"FontColorOpacity": 1,
"FontColor": "#FFFFFF"
}
]
}
]
}
]
}Word art styles
Word art is a special text caption style based on banner text effects. The following code provides an example:
{
"VideoTracks": [
{
"VideoTrackClips": [
{
"MediaId": "MediaId1",
"Effects": [
{
"Type": "Text",
"X": 33,
"Y": 34,
"Font": "WenQuanYi Zen Hei Mono",
"Content": "Word art with shadow and outline - First line of test text",
"OutlineColour": "#ee00ff",
"BackColour": "#CE1212",
"EffectColorStyle": "skyline",
"Angle": 300,
"Outline": 2,
"Shadow": 3,
"FontSize": 42,
"FontColorOpacity": 1,
"FontColor": "#000000",
"FontFace": {
"Bold": true,
"Italic": false,
"Underline": false
}
},
{
"Type": "Text",
"X": 66,
"Y": 256,
"Font": "WenQuanYi Zen Hei Mono",
"Content": "Second line of text",
"EffectColorStyle": "golden",
"Angle": 60,
"FontSize": 38,
"FontColorOpacity": 0.8,
"FontColor": "#d60e0e"
},
{
"Type": "Text",
"X": 0.7123,
"Y": 0.7896,
"TimelineIn": 5,
"TimelineOut": 20,
"Font": "WenQuanYi Zen Hei Mono",
"Content": "Third line of text",
"FontSize": 26,
"FontColor": "#000000"
}
]
}
]
}
]
}Word art parameters
Parameters | Type | Description |
EffectColorStyle | string | The type of the word art style. For more information about word art styles and effects, see Word art effect examples. |
OutlineColour | string | The outline color. The color is a 6-digit hexadecimal RGB value in the #xxyyzz format. |
BackColour | string | The shadow color. The color is a 6-digit hexadecimal RGB value in the #xxyyzz format. |
Shadow | int | The pixel value of the shadow depth for the word art. The default value is 0. The recommended ratio of shadow depth to font size is 2:25. For example, if the font size is 25, set the shadow depth to 2. |
Outline | int | The pixel value of the outline width for the word art. The default value is 0. The recommended ratio of outline width to font size is 2:25. For example, if the font size is 25, set the outline width to 2. |
Spacing | int | The spacing between characters, in pixels. |
Angle | float | The pre-rotation angle of the subtitle line, in degrees. The value must be in the range of [0, 360]. |