All Products
Search
Document Center

Text 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 text overlaid on the output video X indicates the horizontal distance between the upper-left corner of the text and the upper-left corner of the output video.
Y indicates the vertical distance between the upper-left corner of the text 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 text 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.
Text attributes Content indicates the text content.
Font indicates the font used by the text. If this parameter is not set, the default value SimSun is used. Currently, the following fonts are supported:
SimSun
WenQuanYi Zen Hei
WenQuanYi Zen Hei Mono
WenQuanYi Zen Hei Sharp
Yuanti SC Bold
Yuanti SC Light
Yuanti SC Regular
FontSize indicates the size of the font. Unit: pixels. If this parameter is not set, the default value 20 is used.
FontColor indicates the color of the font, in hexadecimal format. The value starts with a number sign (#), for example, #FFFFFF. If this parameter is not set, the default value #FFFFFF is used.
FontColorOpacity indicates the transparency of the font color. Valid values: [0-1]. A value of 1 indicates that the color is fully opaque. A value of 0 indicates that the color is fully transparent. If this parameter is not set, the default value 1 is used.
FontFace indicates the style of the font and contains the following parameters:
Bold: indicates whether the font is bold. If this parameter is not set, the default value false is used.
Italic: indicates whether the font is italic. If this parameter is not set, the default value false is used.
Underline: indicates whether the font is underlined. If this parameter is not set, the default value false is used.
Time interval when the text is overlaid on the output video TimelineIn indicates the start time of the text relative to the output video.
TimelineOut indicates the end time of the text relative to the output video.

Examples

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

Full-time overlay

This action overlays text 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 text in the output video is specified by X and Y. For example:

  1. {
  2. "VideoTracks": [
  3. {
  4. "VideoTrackClips": [
  5. {
  6. "MediaId": "ea9a6f9bdb68419abfd36a7113cf7a7c",
  7. "Effects": [
  8. {
  9. "Type": "Text",
  10. "X": 31,
  11. "Y": 93,
  12. "Font": "WenQuanYi Zen Hei Mono",
  13. "Content": "Test Text Test Text",
  14. "FontSize": 26,
  15. "FontColorOpacity": 0.2,
  16. "FontColor": "#000000",
  17. "FontFace": {
  18. "Bold": true,
  19. "Italic": false,
  20. "Underline": false
  21. }
  22. },
  23. {
  24. "Type": "Text",
  25. "X": 30,
  26. "Y": 92,
  27. "Font": "WenQuanYi Zen Hei Mono",
  28. "Content": "Test Text Test Text",
  29. "FontSize": 26,
  30. "FontColorOpacity": 1,
  31. "FontColor": "#FFFFFF"
  32. },
  33. {
  34. "Type": "Text",
  35. "X": 0.8123,
  36. "Y": 0.7896,
  37. "Font": "WenQuanYi Zen Hei Mono",
  38. "Content": "Test Text Test Text",
  39. "FontSize": 26,
  40. "FontColorOpacity": 0.2,
  41. "FontColor": "#000000"
  42. },
  43. {
  44. "Type": "Text",
  45. "X": 0.8223,
  46. "Y": 0.7796,
  47. "Font": "WenQuanYi Zen Hei Mono",
  48. "Content": "Test Text Test Text",
  49. "FontSize": 26,
  50. "FontColorOpacity": 1,
  51. "FontColor": "#FFFFFF"
  52. }
  53. ]
  54. }
  55. ]
  56. }
  57. ]
  58. }

Overlay in the specified time interval

This action overlays text on a video in the specified time interval of the video. The position of the text in the output video is specified by X and Y. The following example describes how to overlay text on a video from the 0th second to the 5th second and from the 5th second to the 10th second:

  • If the TimelineIn parameter is not set, the text is overlaid from the start time of the video by default.
  • If the TimelineOut parameter is not set, the text 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 text remains overlaid until the video ends.
  1. {
  2. "VideoTracks": [
  3. {
  4. "VideoTrackClips": [
  5. {
  6. "MediaId": "ea9a6f9bdb68419abfd36a7113cf7a7c",
  7. "Effects": [
  8. {
  9. "Type": "Text",
  10. "X": 31,
  11. "Y": 93,
  12. "TimelineIn": 0,
  13. "TimelineOut": 5,
  14. "Font": "WenQuanYi Zen Hei Mono",
  15. "Content": "Test Text Test Text",
  16. "FontSize": 26,
  17. "FontColorOpacity": 0.2,
  18. "FontColor": "#000000",
  19. "FontFace": {
  20. "Bold": true,
  21. "Italic": false,
  22. "Underline": false
  23. }
  24. },
  25. {
  26. "Type": "Text",
  27. "X": 30,
  28. "Y": 92,
  29. "TimelineIn": 0,
  30. "TimelineOut": 5,
  31. "Font": "WenQuanYi Zen Hei Mono",
  32. "Content": "Test Text Test Text",
  33. "FontSize": 26,
  34. "FontColorOpacity": 1,
  35. "FontColor": "#FFFFFF"
  36. },
  37. {
  38. "Type": "Text",
  39. "X": 1124,
  40. "Y": 516,
  41. "TimelineIn": 5,
  42. "TimelineOut": 10,
  43. "Font": "WenQuanYi Zen Hei Mono",
  44. "Content": "Test Text Test Text",
  45. "FontSize": 26,
  46. "FontColorOpacity": 0.2,
  47. "FontColor": "#000000"
  48. },
  49. {
  50. "Type": "Text",
  51. "X": 1123,
  52. "Y": 515,
  53. "TimelineIn": 5,
  54. "TimelineOut": 10,
  55. "Font": "WenQuanYi Zen Hei Mono",
  56. "Content": "Test Text Test Text",
  57. "FontSize": 26,
  58. "FontColorOpacity": 1,
  59. "FontColor": "#FFFFFF"
  60. }
  61. ]
  62. }
  63. ]
  64. }
  65. ]
  66. }