All Products
Search
Document Center

Image overlay

Last Updated: Jul 11, 2019

Overview

We have introduced video editing, its overall process, and the two methods of using the media editing service in Overview. Media editing is essentially initiated and implemented by the media editing service. The timeline is the key data processed by the media editing service and also the core object in video editing. The internal parameters of the timeline can be organized in multiple ways to cope with different business scenarios.

Parameter description

Parameter Description
Coordinates of the image overlaid on the output video X indicates the horizontal distance between the upper-left corner of the image and the upper-left corner of the output video.
Y indicates the vertical distance between the upper-left corner of the image and the upper-left corner of the output video.
Note: The value can represent a percentage or the number of pixels. If the value is within [0~0.9999], it indicates the percentage of the horizontal or vertical offset distance of the image relative to the width or height of the output video. X indicates the percentage relative to the width, and Y indicates the percentage relative to the height. If the value is an integer greater than or equal to 8, it indicates the number of pixels.
Size of the image overlaid on the output video Width indicates the width of the image overlaid on the output video.
Height indicates the height of the image overlaid on the output video.
Note: The value can represent a percentage or the number of pixels. If the value is within [0~0.9999], it indicates the percentage of the width or height of the image relative to that of the output video. Width indicates the percentage relative to the width, and Height indicates the percentage relative to the height. If the value is an integer greater than or equal to 8, it indicates the number of pixels.
Time interval when the image is overlaid on the output video TimelineIn indicates the start time of the image relative to the output video.
TimelineOut indicates the end time of the image relative to the output video.

Examples

The following examples show how timeline data is organized for image overlay.

Full-time overlay

This action overlays an image on a video from the start time to the end time of the entire video. You do not need to set the TimelineIn or TimelineOut parameter. The position of the image in the output video is specified by X and Y. The size of the image in the output video is specified by Width and Height. For example:

  • Overlay on a single video
  1. {
  2. "VideoTracks": [
  3. {
  4. "VideoTrackClips": [
  5. {
  6. "MediaId": "222d9296e8864746a0b6f32dad6e1a3d"
  7. }
  8. ]
  9. }
  10. ],
  11. "ImageTracks": [
  12. {
  13. "ImageTrackClips": [
  14. {
  15. "ImageId": "001d9296e8864746a0b6f32dad6e1001",
  16. "Width": 0.1345,
  17. "Height": 0.1678,
  18. "X": 0.1234,
  19. "Y": 0.1234
  20. },
  21. {
  22. "ImageId": "002d9296e8864746a0b6f32dad6e1002",
  23. "Width": 0.1345,
  24. "Height": 0.1678,
  25. "X": 0.7234,
  26. "Y": 0.7234
  27. }
  28. ]
  29. }
  30. ]
  31. }
  • Overlay on multiple videos
  1. {
  2. "VideoTracks": [
  3. {
  4. "VideoTrackClips": [
  5. {
  6. "MediaId": "222d9296e8864746a0b6f32dad6e1a3d"
  7. },
  8. {
  9. "MediaId": "333d9296e8864746a0b6f32dad6e1a3d"
  10. }
  11. ]
  12. }
  13. ],
  14. "ImageTracks": [
  15. {
  16. "ImageTrackClips": [
  17. {
  18. "ImageId": "001d9296e8864746a0b6f32dad6e1001",
  19. "Width": 0.1345,
  20. "Height": 0.1678,
  21. "X": 0.1234,
  22. "Y": 0.1234
  23. },
  24. {
  25. "ImageId": "002d9296e8864746a0b6f32dad6e1002",
  26. "Width": 0.1345,
  27. "Height": 0.1678,
  28. "X": 0.7234,
  29. "Y": 0.7234
  30. }
  31. ]
  32. }
  33. ]
  34. }

Overlay in the specified time interval

This action overlays an image on a video in the specified time interval of the video. The position of the image in the output video is specified by X and Y. The size of the image in the output video is specified by Width and Height. The following examples describe how to overlay two images on one or more videos from the 2nd second to the 100th second.

Note: The output video refers to the finally produced video.

  • Overlay on a single video
  • If the TimelineIn parameter is not set, the image is overlaid from the start time of the video by default.
  • If the TimelineOut parameter is not set, the image remains overlaid until the video ends by default.
  • If the TimelineOut value exceeds the total duration of a single video, the excess time interval is automatically ignored. That is, the image remains overlaid until the video ends.
  1. {
  2. "VideoTracks": [
  3. {
  4. "VideoTrackClips": [
  5. {
  6. "MediaId": "222d9296e8864746a0b6f32dad6e1a3d"
  7. }
  8. ]
  9. }
  10. ],
  11. "ImageTracks": [
  12. {
  13. "ImageTrackClips": [
  14. {
  15. "ImageId": "001d9296e8864746a0b6f32dad6e1001",
  16. "Width": 0.1345,
  17. "Height": 0.1678,
  18. "X": 0.1234,
  19. "Y": 0.1234,
  20. "TimelineIn":2,
  21. "TimelineOut":100
  22. },
  23. {
  24. "ImageId": "002d9296e8864746a0b6f32dad6e1002",
  25. "Width": 0.1345,
  26. "Height": 0.1678,
  27. "X": 0.7234,
  28. "Y": 0.7234,
  29. "TimelineIn":2,
  30. "TimelineOut":100
  31. }
  32. ]
  33. }
  34. ]
  35. }
  • Overlay on multiple videos

  • If the TimelineIn parameter is not set, the image is overlaid from the start time of the first video by default.

  • If the TimelineOut parameter is not set, the image remains overlaid until the last video ends by default.

  • If the TimelineOut value exceeds the total duration of the video track consisting of multiple videos, a black screen is displayed in the excess time interval.

If a video track consists of multiple video mezzanine files in different resolutions, the output video is generated as follows:

  • The width of the output video is the maximum width of the video mezzanine files.
  • The height of the output video is the maximum height of the video mezzanine files.
  • The video image is processed in padding + scaling mode. First, black borders are added to the video image to ensure that the aspect ratio remains unchanged. Then, the video image is scaled up to the width and height of the output video.
  • The duration of the output video equals that of the video track.
  1. {
  2. "VideoTracks": [
  3. {
  4. "VideoTrackClips": [
  5. {
  6. "MediaId": "222d9296e8864746a0b6f32dad6e1a3d"
  7. },
  8. {
  9. "MediaId": "333d9296e8864746a0b6f32dad6e1a3d"
  10. }
  11. ]
  12. }
  13. ],
  14. "ImageTracks": [
  15. {
  16. "ImageTrackClips": [
  17. {
  18. "ImageId": "001d9296e8864746a0b6f32dad6e1001",
  19. "Width": 0.1345,
  20. "Height": 0.1678,
  21. "X": 0.1234,
  22. "Y": 0.1234,
  23. "TimelineIn":2,
  24. "TimelineOut":100
  25. },
  26. {
  27. "ImageId": "002d9296e8864746a0b6f32dad6e1002",
  28. "Width": 0.1345,
  29. "Height": 0.1678,
  30. "X": 0.7234,
  31. "Y": 0.7234,
  32. "TimelineIn":2,
  33. "TimelineOut":100
  34. }
  35. ]
  36. }
  37. ]
  38. }