This topic describes common timeline configuration examples for image overlay scenarios when you edit videos using the OpenAPI. The examples include full-duration and specified-area image overlays.
Related APIs
Parameters
Parameter | Description |
Coordinates of the image |
The value can be a percentage or a pixel value:
|
Size of the image in the output video |
The value can be a percentage or a pixel value:
|
Time interval for the image overlay |
|
Timeline examples
Full-duration image overlay
A full-duration image overlay is displayed from the beginning to the end of the video. You do not need to specify the TimelineIn and TimelineOut parameters. The X and Y parameters set the position of the image in the output video, and the Width and Height parameters set its size. The following are examples:
Overlay on a single video
{ "VideoTracks": [ { "VideoTrackClips": [ { "MediaId": "222d9296e8864746a0b6f32dad6e****" } ] } ], "ImageTracks": [ { "ImageTrackClips": [ { "ImageId": "001d9296e8864746a0b6f32dad6e****", "Width": 0.1345, "Height": 0.1678, "X": 0.1234, "Y": 0.1234 }, { "ImageId": "002d9296e8864746a0b6f32dad6e****", "Width": 0.1345, "Height": 0.1678, "X": 0.7234, "Y": 0.7234 } ] } ] }Overlay on multiple videos
{ "VideoTracks": [ { "VideoTrackClips": [ { "MediaId": "222d9296e8864746a0b6f32dad6e****" }, { "MediaId": "333d9296e8864746a0b6f32dad6e****" } ] } ], "ImageTracks": [ { "ImageTrackClips": [ { "ImageId": "001d9296e8864746a0b6f32dad6e****", "Width": 0.1345, "Height": 0.1678, "X": 0.1234, "Y": 0.1234 }, { "ImageId": "002d9296e8864746a0b6f32dad6e****", "Width": 0.1345, "Height": 0.1678, "X": 0.7234, "Y": 0.7234 } ] } ] }
Overlay an image on a specified area
You can overlay an image on a video for a specified time interval. The X and Y parameters set the position of the image in the output video, and the Width and Height parameters set its size. The following example shows how to overlay two images on a video from the 2-second mark to the 100-second mark:
The output video is the final composite video.
Overlay on a single video
If
TimelineInis not set, the overlay starts from 0 by default.If
TimelineOutis not set, the overlay is displayed until the video ends by default.If the
TimelineOutvalue exceeds the end of the video (which is the duration for a single video), the excess time is ignored and the end of the video track is used as the boundary.
{ "VideoTracks": [ { "VideoTrackClips": [ { "MediaId": "222d9296e8864746a0b6f32dad6e****" } ] } ], "ImageTracks": [ { "ImageTrackClips": [ { "ImageId": "001d9296e8864746a0b6f32dad6e****", "Width": 0.1345, "Height": 0.1678, "X": 0.1234, "Y": 0.1234, "TimelineIn":2, "TimelineOut":100 }, { "ImageId": "002d9296e8864746a0b6f32dad6e****", "Width": 0.1345, "Height": 0.1678, "X": 0.7234, "Y": 0.7234, "TimelineIn":2, "TimelineOut":100 } ] } ] }Overlay an image on multiple videos
If
TimelineInis not set, the overlay starts from 0 by default.If
TimelineOutis not set, it defaults to the end of the video.If the value of
TimelineOutexceeds the total duration of the video track, a black screen is displayed for the excess duration.
If a video track contains multiple source videos with different resolutions:
The width of the output video is the maximum width among the source videos.
The height of the output video is the maximum height among the source videos.
The frame is processed using padding and scaling. Black bars are added to maintain the aspect ratio, and the frame is then scaled proportionally to the width and height of the output video.
The duration of the output video is the duration of the video track.
{ "VideoTracks": [ { "VideoTrackClips": [ { "MediaId": "222d9296e8864746a0b6f32dad6e****" }, { "MediaId": "333d9296e8864746a0b6f32dad6e****" } ] } ], "ImageTracks": [ { "ImageTrackClips": [ { "ImageId": "001d9296e8864746a0b6f32dad6e****", "Width": 0.1345, "Height": 0.1678, "X": 0.1234, "Y": 0.1234, "TimelineIn":2, "TimelineOut":100 }, { "ImageId": "002d9296e8864746a0b6f32dad6e****", "Width": 0.1345, "Height": 0.1678, "X": 0.7234, "Y": 0.7234, "TimelineIn":2, "TimelineOut":100 } ] } ] }