All Products
Search
Document Center

ApsaraVideo VOD:Image overlay

Last Updated:Jan 28, 2026

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

  • X: The horizontal distance from the upper-left corner of the image to the upper-left corner of the output video.

  • Y: The vertical distance from the upper-left corner of the image to the upper-left corner of the output video.

The value can be a percentage or a pixel value:

  • If the value is in the range of 0 to 0.9999, it represents a percentage of the output video's width or height. The X value is relative to the width of the output video, and the Y value is relative to the height of the output video.

  • If the value is an integer of 8 or greater, it represents an absolute pixel value.

Size of the image in the output video

  • Width: The width of the image in the output video.

  • Height: The height of the image in the output video.

The value can be a percentage or a pixel value:

  • If the value is in the range of 0 to 0.9999, it represents a percentage of the output video's dimensions. The Width value is relative to the width of the output video, and the Height value is relative to the height of the output video.

  • If the value is an integer of 8 or greater, it represents an absolute pixel value.

Time interval for the image overlay

  • TimelineIn: The in point of the image on the timeline.

  • TimelineOut: The out point of the image on the timeline.

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:

Note

The output video is the final composite video.

  • Overlay on a single video

    • If TimelineIn is not set, the overlay starts from 0 by default.

    • If TimelineOut is not set, the overlay is displayed until the video ends by default.

    • If the TimelineOut value 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 TimelineIn is not set, the overlay starts from 0 by default.

    • If TimelineOut is not set, it defaults to the end of the video.

    • If the value of TimelineOut exceeds 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
                  }
              ]
          }
      ]
    }