All Products
Search
Document Center

Intelligent Media Services:Subtitles and subtitle templates

Last Updated:Dec 03, 2024

This topic describes how to edit the Timeline parameters in the SubmitMediaProducingJob operation to process subtitles and subtitle templates.

Usage notes

  • Intelligent production supports editing and compositing, effect rendering, and templates for live streams, VOD files, and material files from Object Storage Service (OSS). For more information, see Intelligent production overview.

  • You can produce a video from one or more videos, audio files, images, and subtitle materials by configuring Timeline parametersand calling the SubmitMediaProducingJob operation.

  • A timeline is created when you add materials and configure effects to create a video. A timeline consists of tracks, materials, and effects. For more information, see Timeline configurations.

  • For more information about how to use the IMS SDK to edit audio and video files, see Preparations.

Add subtitles to a video

Note
  1. Subtitles can be added to a video by creating a separate track (SubtitleTracks) or by setting under Effects.

  2. You can define the start and end times of subtitles by using the TimelineIn and TimelineOut parameters. If you do not specify the two parameters, subtitles in the subtitle track are generated to match the duration of the entire video. By default, subtitles that are added under Effects are generated to match the duration of the video clip to which Effects belongs.

  3. You can use \N or \n to display subtitles in multiple lines.

Effect

Timeline example

{
	"VideoTracks": [{
		"VideoTrackClips": [{
			"MediaURL": "https://ice-document-materials.oss-cn-shanghai.aliyuncs.com/test_media/h3.mp4",
			"Effects": [{
				"Type": "Background",
				"SubType": "Blur",
				"Radius": 0.1
			}]
		}]
	}],
	"SubtitleTracks": [{
		"SubtitleTrackClips": [{
			"Type": "Text",
			"X": 0,
			"Y": 200,
			"Content": "Heading",
			"Alignment": "TopCenter",
			"FontSize": 80,
			"FontColorOpacity": 1,
			"EffectColorStyle": "CS0003-000011",
			"FontFace": {
				"Bold": true
			}
		}, {
			"Type": "Text",
			"X": 0,
			"Y": 320,
			"Font": "KaiTi",
			"Content": "Subheading",
			"Alignment": "TopCenter",
			"FontSize": 45,
			"FontColor": "#ffffff",
			"FontFace": {
				"Italic": true,
				"Underline": true
			}
		}, {
			"Type": "Text",
			"X": 50,
			"Y": 740,
			"Font": "AlibabaPuHuiTi",
			"Content": "Rotation",
			"FontColor": "#FFD700",
			"Outline": 4,
			"Angle": 350,
			"OutlineColour": "#000000",
			"FontSize": 60,
			"FontFace": {
				"Bold": true
			}
		}, {
			"Type": "Text",
			"X": 0,
			"Y": 900,
			"Font": "AlibabaPuHuiTi",
			"Content": "Subtitles\nYou can add line breaks to display subtitles in multiple lines.",
			"Outline": 1,
			"OutlineColour": "000000",
			"Alignment": "TopCenter",
			"FontSize": 40,
			"FontColor": "#ffffff",
			"FontFace": {
				"Bold": true,
				"Italic": false,
				"Underline": false
			}
		}, {
			"Type": "Text",
			"X": 0,
			"Y": 1000,
			"Font": "KaiTi",
			"Content": "Start and end times of subtitles",
			"Alignment": "TopCenter",
			"FontSize": 40,
			"FontColor": "#ffffff",
			"TimelineIn": 5,
			"TimelineOut": 25,
			"FontFace": {
				"Bold": false,
				"Italic": true,
				"Underline": false
			}
		}]
	}]
}

Configure the font size, system font, custom font, stroke, shadow, and subtitle rotation angle

Note
  1. FontSize indicates the font size of the subtitles. If you add subtitles under Effects, we recommend that you use FixedFontSize to set the font size so that the subtitles do not change with the video size.

  2. Font specifies the system font and FontURL specifies the path to the OSS object that stores custom fonts. If both the parameters are set, the system preferentially uses FontURL to render the subtitles.

  3. You can use parameters such as Outline, OutlineColour, Shadow, and BackColour to generate simple single-layer stroke and shadow effects. To implement complex multi-layer stroke effects, refer to the example of configuring custom word art in Example 3.

  4. You can use Angle to adjust the rotation angle of the subtitles in the counterclockwise direction.

Effect

Timeline example

{
  "VideoTracks": [
    {
      "VideoTrackClips": [
        {
          "MediaURL": "https://ice-document-materials.oss-cn-shanghai.aliyuncs.com/test_media/h2.mp4",
          "Effects": [
            {
              "Type": "Background",
              "SubType": "Blur",
              "Radius": 0.1
            }
          ]
        }
      ]
    }
  ],
  "SubtitleTracks": [
    {
      "SubtitleTrackClips": [
        {
          "Type": "Text",
          "X": 0,
          "Y": 200,
          "Content": "Heading in font size of 80",
          "Alignment": "TopCenter",
          "FontSize": 80,
          "FontColorOpacity": 1,
          "EffectColorStyle": "CS0003-000023",
          "FontFace": {
            "Bold": true
          }
        },
        {
          "Type": "Text",
          "X": 0,
          "Y": 320,
          "Font": "KaiTi",
          "Content": "Subheading in italics",
          "Alignment": "TopCenter",
          "FontSize": 45,
          "FontColor": "#ffffff",
          "FontFace": {
            "Italic": true,
            "Underline": true
          }
        },
        {
          "Type": "Text",
          "X": 50,
          "Y": 740,
          "Font": "AlibabaPuHuiTi",
          "Content": "Rotation",
          "FontColor": "#FFD700",
          "Outline": 4,
          "Angle": 350,
          "OutlineColour": "#000000",
          "FontSize": 60,
          "FontFace": {
            "Bold": true
          }
        },
        {
          "Type": "Text",
          "X": 0,
          "Y": 900,
          "Content": "Banner subtitle in a custom font \nAdd a black stroke with a width of 1",
          "FontUrl": "https://ice-document-materials.oss-cn-shanghai.aliyuncs.com/test_media/font/fangzhengfangsong.ttf",
          "Outline": 1,
          "OutlineColour": "000000",
          "Alignment": "TopCenter",
          "FontSize": 40,
          "FontColor": "#ffffff",
          "FontFace": {
            "Bold": true,
            "Italic": false,
            "Underline": false
          }
        },
        {
          "Type": "Text",
          "X": 20,
          "Y": 20,
          "Font": "KaiTi",
          "Content": "Add \n shadow \n effects",
          "Alignment": "BottomRight",
          "FontSize": 40,
          "FontColor": "#ffffff",
          "Shadow": 3,
          "BackColour": "#000000",
          "FontFace": {
            "Bold": false,
            "Italic": true,
            "Underline": false
          }
        }
      ]
    }
  ]
}

Configure word art

Note
  1. You can use the EffectColorStyleId field to configure word art effects with ease. For information about the effects, see Word art effects.

  2. To customize how your subtitles look like, you can use the SubtitleEffects field to configure multiple layers of stroke and shadow effects. For more information, see SubtitleEffect.

Effect

Timeline example

{
  "VideoTracks": [
    {
      "VideoTrackClips": [
        {
          "MediaUrl": "https://ice-document-materials.oss-cn-shanghai.aliyuncs.com/test_media/h3.mp4",
          "In": 0,
          "Out": 8
        }
      ]
    }
  ],
  "SubtitleTracks": [
    {
      "SubtitleTrackClips": [
        {
          "TimelineIn": 0,
          "TimelineOut": 2,
          "Type": "Text",
          "Y": 0.2,
          "Font": "WenQuanYi Zen Hei Mono",
          "Content": "Smart editing",
          "Alignment": "TopCenter",
          "FontSize": 200,
          "FontColor": "#FFFFFF",
          "SubtitleEffects": [
            {
              "Color": "#0420B6",
              "Type": "Shadow",
              "XBord": 0.07,
              "YBord": 0.07,
              "YShift": 0.06
            },
            {
              "Color": "#F2213F",
              "Type": "Shadow",
              "XBord": 0.07,
              "YBord": 0.07,
              "YShift": 0.03
            },
            {
              "Color": "#000000",
              "Type": "Shadow",
              "XShift": 0.01,
              "YShift": 0.01
            },
            {
              "Color": "#000000",
              "Type": "Outline",
              "XBord": 0.01,
              "YBord": 0.01
            }
          ]
        },
        {
          "TimelineIn": 0,
          "TimelineOut": 2,
          "Type": "Text",
          "Y": 0.6,
          "Content": "Advanced word art",
          "Alignment": "TopCenter",
          "FontSize": 150,
          "EffectColorStyle": "CS0001-000011"
        },
        {
          "TimelineIn": 2,
          "TimelineOut": 5,
          "Type": "Text",
          "X": 0.1,
          "Y": 0.1,
          "Content": "System word art",
          "FontSize": 150,
          "EffectColorStyle": "CS0001-000004"
        },
        {
          "TimelineIn": 2,
          "TimelineOut": 5,
          "Type": "Text",
          "X": 0.1,
          "Y": 0.3,
          "Content": "System word art",
          "FontSize": 150,
          "EffectColorStyle": "CS0001-000005"
        },
        {
          "TimelineIn": 2,
          "TimelineOut": 5,
          "Type": "Text",
          "X": 0.1,
          "Y": 0.5,
          "Content": "System word art",
          "FontSize": 150,
          "EffectColorStyle": "CS0001-000014"
        },
        {
          "TimelineIn": 2,
          "TimelineOut": 5,
          "Type": "Text",
          "X": 0.1,
          "Y": 0.7,
          "Content": "System word art",
          "FontSize": 150,
          "EffectColorStyle": "CS0001-000007"
        },
        {
          "TimelineIn": 2,
          "TimelineOut": 5,
          "Type": "Text",
          "X": 0.6,
          "Y": 0.1,
          "Content": "System word art",
          "FontSize": 150,
          "EffectColorStyle": "CS0002-000002"
        },
        {
          "TimelineIn": 2,
          "TimelineOut": 5,
          "Type": "Text",
          "X": 0.6,
          "Y": 0.3,
          "Content": "System word art",
          "FontSize": 150,
          "EffectColorStyle": "CS0002-000004"
        },
        {
          "TimelineIn": 2,
          "TimelineOut": 5,
          "Type": "Text",
          "X": 0.6,
          "Y": 0.5,
          "Content": "System word art",
          "FontSize": 150,
          "EffectColorStyle": "CS0002-000009"
        },
        {
          "TimelineIn": 2,
          "TimelineOut": 5,
          "Type": "Text",
          "X": 0.6,
          "Y": 0.7,
          "Content": "System word art",
          "FontSize": 150,
          "EffectColorStyle": "CS0002-000016"
        },
        {
          "Comment": "Add a shadow effect on the left side",
          "TimelineIn": 5,
          "TimelineOut": 8,
          "Type": "Text",
          "FontSize": 150,
          "Content": "Custom word art",
          "Y": 0.1,
          "Alignment": "TopCenter",
          "Font": "HappyZcool-2016",
          "FontColor": "#F688AA",
          "SubtitleEffects": [
            {
              "Color": "#F5D2CC",
              "Type": "Shadow",
              "XBord": 0,
              "YBord": 0,
              "XShift": -0.04,
              "Opacity": 1
            }
          ]
        },
        {
          "Comment": "Add a shadow effect on the right side",
          "TimelineIn": 5,
          "TimelineOut": 8,
          "Type": "Text",
          "FontSize": 150,
          "Content": "Custom word art",
          "Y": 0.3,
          "Alignment": "TopCenter",
          "Font": "HappyZcool-2016",
          "FontColor": "#F688AA",
          "SubtitleEffects": [
            {
              "Color": "#A33952",
              "Type": "Shadow",
              "XBord": 0,
              "YBord": 0,
              "XShift": 0.04,
              "Opacity": 1
            },
            {
              "Color": "#F5D2CC",
              "Type": "Shadow",
              "XBord": 0,
              "YBord": 0,
              "XShift": -0.04,
              "Opacity": 1
            }
          ]
        },
        {
          "Comment": "Add the first layer of a glow effect",
          "TimelineIn": 5,
          "TimelineOut": 8,
          "Type": "Text",
          "FontSize": 150,
          "Content": "Custom word art",
          "Y": 0.5,
          "Alignment": "TopCenter",
          "Font": "HappyZcool-2016",
          "FontColor": "#F688AA",
          "SubtitleEffects": [
            {
              "Color": "#FFFFA0",
              "Type": "Shadow",
              "Blur": 0.08,
              "XBord": 0.08,
              "YBord": 0.08
            },
            {
              "Color": "#A33952",
              "Type": "Shadow",
              "XBord": 0,
              "YBord": 0,
              "XShift": 0.04,
              "Opacity": 1
            },
            {
              "Color": "#F5D2CC",
              "Type": "Shadow",
              "XBord": 0,
              "YBord": 0,
              "XShift": -0.04,
              "Opacity": 1
            }
          ]
        },
        {
          "Comment": "Add the second layer of a glow effect",
          "TimelineIn": 5,
          "TimelineOut": 8,
          "Type": "Text",
          "FontSize": 150,
          "Content": "Custom word art",
          "Y": 0.7,
          "Alignment": "TopCenter",
          "Font": "HappyZcool-2016",
          "FontColor": "#F688AA",
          "SubtitleEffects": [
            {
              "Color": "#F688AA",
              "Type": "Shadow",
              "Blur": 0.3,
              "XBord": 0.15,
              "YBord": 0.15
            },
            {
              "Color": "#FFFFA0",
              "Type": "Shadow",
              "Blur": 0.08,
              "XBord": 0.08,
              "YBord": 0.08
            },
            {
              "Color": "#A33952",
              "Type": "Shadow",
              "XBord": 0,
              "YBord": 0,
              "XShift": 0.04,
              "Opacity": 1
            },
            {
              "Color": "#F5D2CC",
              "Type": "Shadow",
              "XBord": 0,
              "YBord": 0,
              "XShift": -0.04,
              "Opacity": 1
            }
          ]
        }
      ]
    }
  ]
}

Configure effects for part of subtitles

Note

You can add overwriting code to the Content field to configure effects for part of subtitles. Take note of the following items when you add overwriting code:

  • All overwriting code must begin with two backslashes (\\).

  • All overwriting code must be enclosed in braces ({ }). You can include multiple lines of code in a pair of braces.

  • The overwriting code applies to subtitles. To restore the original configurations, add the corresponding code to cancel the overwriting.

The following table describes the parameters in the overwriting code.

Parameter

Description

Example of Content

  • \\1c&[BBGGRR]&

  • \\2c&[BBGGRR]&

  • \\3c&[BBGGRR]&

  • 1c, 2c, and 3c are the colors of the font, border, and shadow.

  • [BBGGRR] specifies the hexadecimal BGR value. BGR is the reverse of the RGB color order.

"{\\1c&00FF7F&}Green{\\1c} text"

  • \\bord [Width]

  • \\xbord [Width]

  • \\ybord [Width]

bord, xbord, and ybord are the border width, border width along the x-axis, and border width along the y-axis. Unit: pixels.

"Text {\\bord3\\3c&EBCE87&} stroke{\\bord\\3c}"

\\b1 \\b0

b1 indicates bold, and b0 indicates no bold effect.

"{\\b1}Bold{\\b0} text",

\\i1 \\i0

i1 indicates italic and i0 indicates no italic effect.

"{\\i1}Italicize{\\i0} text"

\\u1 \\u0

u1 indicates underlining and u0 indicates no underlining.

"{\\u1}Underline{\\u0} text"

\\s1 \\s0

s1 indicates strikethrough and s0 indicates no strikethrough.

"{\\s1}Strikethrough{\\s0} text"

\\fs[Font size]

The font size of the subtitle. Unit: pixels.

"Size {\\fs100}100{\\fs} text"

\\fn[Font]

The font of the subtitle. You cannot specify a custom font.

"{\\fnKaiTi}Heiti{\\fn} text"

Effect

Timeline example

{
  "VideoTracks": [
    {
      "VideoTrackClips": [
        {
          "MediaURL": "https://ice-document-materials.oss-cn-shanghai.aliyuncs.com/test_media/v1.mp4"
        }
      ]
    }
  ],
  "SubtitleTracks": [
    {
      "SubtitleTrackClips": [
        {
          "Type": "Text",
          "X": 0,
          "Y": 150,
          "Font": "FZKai-Z03S",
          "Content": "{\\1c&0801ea&\\3c&f7fcff&}Crimson{\\1c\\3c} text", 
          "Alignment": "TopCenter",
          "FontSize": 65,
          "FontColor": "#F5FFFA",
          "TimelineIn": 0,
          "TimelineOut": 10,
          "Outline": 2,
          "OutlineColour": "#0e0100"
        },
        {
          "Type": "Text",
          "X": 0,
          "Y": 300,
          "Font": "FZKai-Z03S",
          "Content": "Size {\\fs}100{\\fs100} text",
          "Alignment": "TopCenter",
          "FontColor": "#F5FFFA",
          "FontSize": 65,
          "TimelineIn": 0,
          "TimelineOut": 10,
          "Outline": 2,
          "OutlineColour": "#0e0100"
        },
        {
          "Type": "Text",
          "Y": 450,
          "Font": "FZKai-Z03S",
          "Content": "Text {\\bord3\\3c&CD0000&}stroke{\\bord\\3c}",
          "Alignment": "TopCenter",
          "FontSize": 65,
          "FontColor": "#F5FFFA",
          "TimelineIn": 0,
          "TimelineOut": 10,
          "Outline": 2,
          "OutlineColour": "#0e0100"
        },
        {
          "Type": "Text",
          "Y": 600,
          "Content": "Text {\\bord3\\3c&701919&}background{\\bord\\3c}",
          "Font": "FZKai-Z03S",
          "FontSize": 65,
          "TimelineIn": 0,
          "TimelineOut": 10,
          "Alignment": "TopCenter",
          "FontColor": "#F5FFFA",
          "BorderStyle": 3,
          "Outline": 0,
          "OutlineColour": "#0000CD"
        },
        {
          "Type": "Text",
          "Y": 750,
          "Font": "FZKai-Z03S",
          "Content": "{\\fnKaiTi}KaiTi{\\fn} font",
          "FontSize": 65,
          "TimelineIn": 0,
          "TimelineOut": 10,
          "FontColor": "#F5FFFA",
          "Alignment": "TopCenter",
          "Outline": 2,
          "OutlineColour": "#0e0100"
        },
        {
          "Type": "Text",
          "Y": 900,
          "Font": "FZKai-Z03S",
          "Content": "{\\b1}Bold {\\b0} text",
          "FontSize": 65,
          "TimelineIn": 0,
          "TimelineOut": 10,
          "FontColor": "#F5FFFA",
          "Alignment": "TopCenter",
          "Outline": 2,
          "OutlineColour": "#0e0100"
        },
        {
          "Type": "Text",
          "Y": 1050,
          "Font": "FZKai-Z03S",
          "Content": "{\\i1}Italicize{\\i0} text",
          "FontSize": 65,
          "TimelineIn": 0,
          "TimelineOut": 10,
          "FontColor": "#F5FFFA",
          "Alignment": "TopCenter",
          "Outline": 2,
          "OutlineColour": "#0e0100"
        },
        {
          "Type": "Text",
          "Y": 1200,
          "Font": "FZKai-Z03S",
          "Content": "{\\u1}Underline{\\u0} text",
          "FontColor": "#F5FFFA",
          "FontSize": 65,
          "TimelineIn": 0,
          "TimelineOut": 10,
          "Alignment": "TopCenter",
          "Outline": 2,
          "OutlineColour": "#0e0100"
        },
        {
          "Type": "Text",
          "Y": 1350,
          "Font": "FZKai-Z03S",
          "Content": "{\\s1}Strikethrough{\\s0} text",
          "FontColor": "#F5FFFA",
          "FontSize": 65,
          "TimelineIn": 0,
          "TimelineOut": 10,
          "Alignment": "TopCenter",
          "Outline": 2,
          "OutlineColour": "#0e0100"
        },
        {
          "Type": "Text",
          "Y": 1500,
          "Font": "FZKai-Z03S",
          "Content": "Effect {\\1c&00FF00&\\b1\\fs100\\i1}combination{\\1c\\b0\\fs\\i0}",
          "FontColor": "#F5FFFA",
          "FontSize": 65,
          "TimelineIn": 0,
          "TimelineOut": 10,
          "Alignment": "TopCenter",
          "Outline": 2,
          "OutlineColour": "#0e0100"
        }
      ]
    }
  ]
}

Configure auto line wrapping

Note
  1. To ensure that subtitles are fully displayed, you can set AdaptMode to AutoWrap to enable auto line wrapping when the subtitle exceeds the window range. In addition, you can specify TextWidth in absolute pixels or as a percentage of the playback window to control line wrapping within a defined width range.

  2. The setting of "AdaptMode": "AutoWrapAtSpaces" ensures that line breaks do not appear in the middle of English words.

Effect

Timeline example

{
  "VideoTracks": [
    {
      "VideoTrackClips": [
        {
          "MediaURL": "https://ice-document-materials.oss-cn-shanghai.aliyuncs.com/test_media/v1.mp4"
        }
      ]
    }
  ],
  "SubtitleTracks": [
    {
      "SubtitleTrackClips": [
        {
          "Type": "Text",
          "X": 0,
          "Y": 200,
          "Font": "FZKai-Z03S",
          "Content": "If you do not set auto line wrapping, the subtitle will exceed the playback window if the text is too long.",
          "Alignment": "TopCenter",
          "FontSize": 70,
          "FontColor": "#F5FFFA",
          "Outline": 2,
          "OutlineColour": "#0e0100"
        },
        {
          "Type": "Text",
          "X": 0,
          "Y": 600,
          "Font": "FZKai-Z03S",
          "Content": "Auto line wrapping is triggered when the text exceeds the playback window.",
          "AdaptMode": "AutoWrap",
          "Alignment": "TopCenter",
          "FontSize": 70,
          "FontColor": "#F5FFFA",
          "Outline": 2,
          "OutlineColour": "#0e0100"
        },
        {
          "Type": "Text",
          "X": 0,
          "Y": 1000,
          "Font": "FZKai-Z03S",
          "Content": "Set TextWidth to enable auto line wrapping within a given width range.",
          "TextWidth": 0.7,
          "AdaptMode": "AutoWrap",
          "Alignment": "TopCenter",
          "FontSize": 70,
          "FontColor": "#F5FFFA",
          "Outline": 2,
          "OutlineColour": "#0e0100"
        },
        {
          "Type": "Text",
          "X": 0,
          "Y": 1400,
          "Content": "Subtitles only automatically wrap at spaces.",
          "AdaptMode": "AutoWrapAtSpaces",
          "Alignment": "TopCenter",
          "FontSize": 70,
          "FontColor": "#F5FFFA",
          "Outline": 2,
          "OutlineColour": "#0e0100"
        }
      ]
    }
  ]
}

Configure subtitle alignment

  • The positioning of subtitles varies with the alignment mode. The following table describes the alignment modes and default positions.

    Alignment

    Alignment mode

    Default position

    TopLeft

    Left alignment

    The upper-left corner.

    TopCenter

    Center alignment

    The upper center.

    TopRight

    Right alignment

    The upper-right corner.

    CenterLeft

    Left alignment

    Centered horizontally, but the text is aligned to the left.

    CenterCenter

    Center alignment

    Centered horizontally and vertically.

    CenterRight

    Right alignment

    Centered horizontally, but the text is aligned to the right.

    BottomLeft

    Left alignment

    The bottom-left corner.

    BottomCenter

    Center alignment

    The bottom center.

    BottomRight

    Right alignment

    The bottom-right corner.

  • The following table describes three alignment modes, Left, Center, and Right, with which you can precisely position your subtitles.

    Alignment

    Alignment mode

    Positioning benchmark point

    Left

    Left alignment

    The upper-left vertex of subtitle text box.

    Center

    Center alignment

    The midpoint of the upper border of the subtitle text box.

    Right

    Right alignment

    The upper-right vertex of the subtitle text box.

  • The following figure shows the different positioning benchmark points for different alignment modes.

    image

Effect

Timeline example

{
    "VideoTracks": [
        {
            "VideoTrackClips": [
                {
                    "MediaURL": "https://ice-document-materials.oss-cn-shanghai.aliyuncs.com/test_media/h3.mp4"
                }
            ]
        }
    ],
    "SubtitleTracks": [
        {
            "SubtitleTrackClips": [
                {
                    "Type": "Text",
                    "Font": "FZKai-Z03S",
                    "Content": "Alignment\nTopLeft",
                    "Alignment": "TopLeft",
                    "FontSize": 70,
                    "FontColor": "#F5FFFA",
                    "Outline": 2,
                    "OutlineColour": "#0e0100",
                    "TimelineIn": 0,
                    "TimelineOut": 4
                },
                {
                    "Type": "Text",
                    "Font": "FZKai-Z03S",
                    "Content": "Alignment\nTopCenter",
                    "Alignment": "TopCenter",
                    "FontSize": 70,
                    "FontColor": "#F5FFFA",
                    "Outline": 2,
                    "OutlineColour": "#0e0100",
                    "TimelineIn": 0,
                    "TimelineOut": 4
                },
                {
                    "Type": "Text",
                    "Font": "FZKai-Z03S",
                    "Content": "Alignment\nTopRight",
                    "Alignment": "TopRight",
                    "FontSize": 70,
                    "FontColor": "#F5FFFA",
                    "Outline": 2,
                    "OutlineColour": "#0e0100",
                    "TimelineIn": 0,
                    "TimelineOut": 4
                },
                {
                    "Type": "Text",
                    "Font": "FZKai-Z03S",
                    "Content": "Alignment\nCenterLeft",
                    "Alignment": "CenterLeft",
                    "FontSize": 70,
                    "FontColor": "#F5FFFA",
                    "Outline": 2,
                    "OutlineColour": "#0e0100",
                    "TimelineIn": 0,
                    "TimelineOut": 4
                },
                {
                    "Type": "Text",
                    "Font": "FZKai-Z03S",
                    "Content": "Alignment\nCenterCenter",
                    "Alignment": "CenterCenter",
                    "FontSize": 70,
                    "FontColor": "#F5FFFA",
                    "Outline": 2,
                    "OutlineColour": "#0e0100",
                    "TimelineIn": 0,
                    "TimelineOut": 4
                },
                {
                    "Type": "Text",
                    "Font": "FZKai-Z03S",
                    "Content": "Alignment\nCenterRight",
                    "Alignment": "CenterRight",
                    "FontSize": 70,
                    "FontColor": "#F5FFFA",
                    "Outline": 2,
                    "OutlineColour": "#0e0100",
                    "TimelineIn": 0,
                    "TimelineOut": 4
                },
                {
                    "Type": "Text",
                    "Font": "FZKai-Z03S",
                    "Content": "Alignment\nBottomLeft",
                    "Alignment": "BottomLeft",
                    "FontSize": 70,
                    "FontColor": "#F5FFFA",
                    "Outline": 2,
                    "OutlineColour": "#0e0100",
                    "TimelineIn": 0,
                    "TimelineOut": 4
                },
                {
                    "Type": "Text",
                    "Font": "FZKai-Z03S",
                    "Content": "Alignment\nBottomCenter",
                    "Alignment": "BottomCenter",
                    "FontSize": 70,
                    "FontColor": "#F5FFFA",
                    "Outline": 2,
                    "OutlineColour": "#0e0100",
                    "TimelineIn": 0,
                    "TimelineOut": 4
                },
                {
                    "Type": "Text",
                    "Font": "FZKai-Z03S",
                    "Content": "Alignment\nBottomRight",
                    "Alignment": "BottomRight",
                    "FontSize": 70,
                    "FontColor": "#F5FFFA",
                    "Outline": 2,
                    "OutlineColour": "#0e0100",
                    "TimelineIn": 0,
                    "TimelineOut": 4
                }
            ]
        },
        {
            "SubtitleTrackClips": [
                {
                    "Type": "Text",
                    "Font": "FZKai-Z03S",
                    "Content": "Alignment\nLeft",
                    "X": 100,
                    "Y": 500,
                    "Alignment": "TopLeft",
                    "FontSize": 70,
                    "FontColor": "#F5FFFA",
                    "Outline": 2,
                    "OutlineColour": "#0e0100",
                    "TimelineIn": 4,
                    "TimelineOut": 8
                },
                {
                    "Type": "Text",
                    "Font": "FZKai-Z03S",
                    "Content": "Alignment\nCenter",
                    "X": 950,
                    "Y": 500,
                    "Alignment": "Center",
                    "FontSize": 70,
                    "FontColor": "#F5FFFA",
                    "Outline": 2,
                    "OutlineColour": "#0e0100",
                    "TimelineIn": 4,
                    "TimelineOut": 8
                },
                {
                    "Type": "Text",
                    "Font": "FZKai-Z03S",
                    "X": 1820,
                    "Y": 500,
                    "Content": "Alignment\nRight",
                    "Alignment": "Right",
                    "FontSize": 70,
                    "FontColor": "#F5FFFA",
                    "Outline": 2,
                    "OutlineColour": "#0e0100",
                    "TimelineIn": 4,
                    "TimelineOut": 8
                }
            ]
        }
    ]
}

Configure subtitle effects

Note
  1. You can specify a time to display the entrance and exit effects of subtitles and specify the speed of the loop effect.

  2. The entrance/exit effect and loop effect cannot be used at the same time.

Effect

Timeline example

{
  "VideoTracks": [
    {
      "VideoTrackClips": [
        {
          "MediaURL": "https://ice-document-materials.oss-cn-shanghai.aliyuncs.com/test_media/v1.mp4"
        }
      ]
    }
  ],
  "SubtitleTracks": [
    {
      "SubtitleTrackClips": [
        {
          "Type": "Text",
          "X": 0,
          "Y": 200,
          "Font": "HappyZcool-2016",
          "Content": "Entrance effect for 2 seconds",
          "Alignment": "TopCenter",
          "FontSize": 70,
          "FontColor": "#F5FFFA",
          "Outline": 2,
          "OutlineColour": "#0e0100",
          "AaiMotionInEffect": "rotateflip_in",
          "AaiMotionIn": 2
        },
        {
          "Type": "Text",
          "X": 0,
          "Y": 600,
          "Font": "HappyZcool-2016",
          "Content": "Exit effect for 2 seconds",
          "AdaptMode": "AutoWrap",
          "Alignment": "TopCenter",
          "FontSize": 70,
          "FontColor": "#F5FFFA",
          "Outline": 2,
          "OutlineColour": "#0e0100",
          "AaiMotionOutEffect": "slide_down_out",
          "AaiMotionOut": 2
        },
        {
          "Type": "Text",
          "X": 0,
          "Y": 1000,
          "Font": "HappyZcool-2016",
          "Content": "Loop effect at a 2x speed",
          "TextWidth": 0.7,
          "AdaptMode": "AutoWrap",
          "Alignment": "TopCenter",
          "FontSize": 70,
          "FontColor": "#F5FFFA",
          "Outline": 2,
          "OutlineColour": "#0e0100",
          "AaiMotionLoopEffect": "rainbrush_display",
          "Ratio": 2
        },
        {
          "Type": "Text",
          "X": 0,
          "Y": 1400,
          "Font": "HappyZcool-2016",
          "Content": "Entrance and exit effects",
          "AdaptMode": "AutoWrapAtSpaces",
          "Alignment": "TopCenter",
          "FontSize": 70,
          "FontColor": "#F5FFFA",
          "Outline": 2,
          "OutlineColour": "#0e0100",
          "AaiMotionInEffect": "zoomin_i",
          "AaiMotionIn": 2,
          "AaiMotionOutEffect": "dissolve_out",
          "AaiMotionOut": 2
        }
      ]
    }
  ]
}

Configure the subtitle background

Note

You can use the Box field in SubtitleEffects to add a solid color background for your subtitles. You can also configure word art, line wrapping, and other styles.

Effect

Timeline example

{
  "VideoTracks": [
    {
      "VideoTrackClips": [
        {
          "MediaURL": "https://ice-document-materials.oss-cn-shanghai.aliyuncs.com/test_media/v1.mp4"
        }
      ]
    }
  ],
  "SubtitleTracks": [
    {
      "SubtitleTrackClips": [
        {
          "Type": "Text",
          "X": 0,
          "Y": 200,
          "Font": "HappyZcool-2016",
          "Content": "Configure the offset width and height of the solid color background of the subtitle.",
          "AdaptMode": "AutoWrap",
          "Alignment": "TopCenter",
          "FontSize": 70,
          "FontColor": "#F5FFFA",
          "SubtitleEffects": [
            {
              "Type": "Box",
              "Color": "1E90FF",
              "XShift": 20,
              "YShift": -20,
              "Bord": 20
            }
          ]
        }
      ]
    },
    {
      "SubtitleTrackClips": [
        {
          "Type": "Text",
          "X": 0,
          "Y": 600,
          "Font": "HappyZcool-2016",
          "Content": "Configure the opacity of the subtitle background.",
          "AdaptMode": "AutoWrap",
          "Alignment": "TopCenter",
          "FontSize": 70,
          "FontColor": "#F5FFFA",
          "SubtitleEffects": [
            {
              "Type": "Box",
              "Color": "1E90FF",
              "Opacity": "0.5",
              "Bord": 20
            }
          ]
        }
      ]
    },
    {
      "SubtitleTrackClips": [
        {
          "Type": "Text",
          "X": 0,
          "Y": 1000,
          "Font": "HappyZcool-2016",
          "Content": "Configure an effect for the solid color background when the subtitle needs line wrapping.",
          "AdaptMode": "AutoWrap",
          "TextWidth": 0.6,
          "Alignment": "TopCenter",
          "FontSize": 70,
          "FontColor": "#F5FFFA",
          "SubtitleEffects": [
            {
              "Type": "Box",
              "Color": "1E90FF",
              "Bord": 20
            }
          ]
        }
      ]
    },
    {
      "SubtitleTrackClips": [
        {
          "Type": "Text",
          "X": 0,
          "Y": 1400,
          "Font": "HappyZcool-2016",
          "Content": "Configure a solid color background, display effect, and word art for the subtitle.",
          "AdaptMode": "AutoWrapAtSpaces",
          "Alignment": "TopCenter",
          "FontSize": 70,
          "EffectColorStyle": "CS0003-000006",
          "AaiMotionInEffect": "zoomin_i",
          "AaiMotionIn": 2,
          "AaiMotionOutEffect": "dissolve_out",
          "AaiMotionOut": 2,
          "SubtitleEffects": [
            {
              "Type": "Box",
              "Color": "1E90FF",
              "Bord": 20
            }
          ]
        }
      ]
    }
  ]
}

Configure text bubbles

Note
  1. You can use BubbleStyleId to specify the ID of a bubble style. For more information about bubble styles, see Bubble texts.

  2. You can set BubbleWidth and BubbleHeight to adjust the width and height of the bubble text. X and Y indicate the coordinates of the upper-left corner of the bubble text relative to the upper-left corner of the video, respectively.

  3. The Box style in SubtitleEffects allows you to add images to achieve a custom bubble effect. In this style, you need to specify Width and Height to indicate the width and height of the original image of the bubble, and specify TextArea to define the position and size of the text box relative to the bubble. The four fields in TextArea indicate the coordinates of the upper-left corner of the bubble text box relative to the bubble, and the width and height of the text box relative to the bubble.

  4. When you use the bubble text feature, the text is automatically wrapped and scaled in the bubble.

Effect

Timeline example

{
  "VideoTracks": [
    {
      "VideoTrackClips": [
        {
          "MediaUrl": "https://ice-document-materials.oss-cn-shanghai.aliyuncs.com/test_media/h3.mp4"
        }
      ]
    }
  ],
  "SubtitleTracks": [
    {
      "SubtitleTrackClips": [
        {
          "TimelineIn": 0,
          "TimelineOut": 4,
          "Type": "Text",
          "X": 0.1,
          "Y": 0,
          "FontSize": 150,
          "BubbleHeight": 0.18,
          "Alignment": "TopCenter",
          "BubbleStyleId": "BS0001-000001"
        },
        {
          "TimelineIn": 0,
          "TimelineOut": 4,
          "Type": "Text",
          "X": 0.1,
          "Y": 0.2,
          "FontSize": 150,
          "BubbleHeight": 0.18,
          "Alignment": "TopCenter",
          "BubbleStyleId": "BS0001-000002"
        },
        {
          "TimelineIn": 0,
          "TimelineOut": 4,
          "Type": "Text",
          "X": 0.1,
          "Y": 0.4,
          "FontSize": 150,
          "BubbleHeight": 0.18,
          "Alignment": "TopCenter",
          "BubbleStyleId": "BS0001-000003"
        },
        {
          "TimelineIn": 0,
          "TimelineOut": 4,
          "Type": "Text",
          "X": 0.1,
          "Y": 0.6,
          "FontSize": 150,
          "BubbleHeight": 0.18,
          "Alignment": "TopCenter",
          "BubbleStyleId": "BS0001-000004"
        },
        {
          "TimelineIn": 0,
          "TimelineOut": 4,
          "Type": "Text",
          "X": 0.1,
          "Y": 0.8,
          "FontSize": 150,
          "BubbleHeight": 0.18,
          "Alignment": "TopCenter",
          "BubbleStyleId": "BS0001-000005"
        },
        {
          "TimelineIn": 0,
          "TimelineOut": 4,
          "Type": "Text",
          "X": 0.6,
          "Y": 0,
          "FontSize": 150,
          "BubbleHeight": 0.18,
          "Alignment": "TopCenter",
          "BubbleStyleId": "BS0002-000001"
        },
        {
          "TimelineIn": 0,
          "TimelineOut": 4,
          "Type": "Text",
          "X": 0.6,
          "Y": 0.2,
          "FontSize": 150,
          "BubbleHeight": 0.18,
          "Alignment": "TopCenter",
          "BubbleStyleId": "BS0002-000002"
        },
        {
          "TimelineIn": 0,
          "TimelineOut": 4,
          "Type": "Text",
          "X": 0.6,
          "Y": 0.4,
          "FontSize": 150,
          "BubbleHeight": 0.18,
          "Alignment": "TopCenter",
          "BubbleStyleId": "BS0002-000003"
        },
        {
          "TimelineIn": 0,
          "TimelineOut": 4,
          "Type": "Text",
          "X": 0.6,
          "Y": 0.6,
          "FontSize": 150,
          "BubbleHeight": 0.18,
          "Alignment": "TopCenter",
          "BubbleStyleId": "BS0002-000004"
        },
        {
          "TimelineIn": 0,
          "TimelineOut": 4,
          "Type": "Text",
          "X": 0.6,
          "Y": 0.8,
          "FontSize": 150,
          "BubbleHeight": 0.18,
          "Alignment": "TopCenter",
          "BubbleStyleId": "BS0002-000005"
        },
        {
          "TimelineIn": 4,
          "TimelineOut": 8,
          "Type": "Text",
          "Content": "Custom bubble text",
          "FontColor": "#000000",
          "X": 0.1,
          "Y": 0.3,
          "BubbleWidth": 0.8,
          "Alignment": "TopCenter",
          "SubtitleEffects": [
            {
              "Type": "Box",
              "Width": 1050,
              "Height": 250,
              "TextArea": "0.1,0.2,0.8,0.6",
              "ImageURL": "https://ice-document-materials.oss-cn-shanghai.aliyuncs.com/test_media/image/round_rectangle.png"
            }
          ]
        }
      ]
    }
  ]
}

Configure subtitle scrolling

Note

You can set ScrollStartY and ScrollEndY to specify the start and end positions of subtitle scrolling. You can also use ScrollSpeed to define the speed at which subtitles scroll. Unit: pixels.

Effect

Timeline example

{
  "VideoTracks": [
    {
      "VideoTrackClips": [
        {
          "MediaURL": "https://ice-document-materials.oss-cn-shanghai.aliyuncs.com/test_media/v1.mp4",
          "Effects": [
            {
              "Type": "Text",
              "TimelineIn": 0,
              "TimelineOut": 18,
              "Content": "Alibaba Cloud Intelligent Media Services (IMS) is an all-in-one service that focuses on media collection, media asset management, content production, and content delivery. It is suitable for live streaming and video-on-demand (VOD) scenarios. IMS provides broadcast-level, intelligent, flexible, and diverse professional capabilities and provides a mature low-code terminal SDK integration solution for complex business scenarios. \n\n\n\nIMS delivers the following features:\n\nHigh professionalism: IMS provides broadcast-level, high-performance, and standardized service capabilities. \n\nHigh flexibility: IMS provides features that cover the entire process. No repeated authorization is required. IMS allows you to orchestrate tasks in a visualized manner and features high efficiency and fault tolerance. \n\nIntelligence: IMS provides systematic AI services in scenarios such as media collection, management, production, processing, and playback. \n\nDiversity: IMS supports multiple delivery forms, including platform as a service (PaaS), PaaS+, and software as a service (SaaS).
              "FontSize": 70,
              "FontColorOpacity": 1,
              "Spacing": 0,
              "LineSpacing": 10,
              "AdaptMode": "AutoWrap",
              "X": 0.1,
              "TextWidth": 0.8,
              "EffectColorStyle": "CS0003-000010",
              "ScrollStartY": 1000,
              "ScrollSpeed": 75,
              "ScrollEndY": 192
            }
          ]
        },
        {
          "MediaURL": "https://ice-document-materials.oss-cn-shanghai.aliyuncs.com/test_media/v1.mp4"
        }
      ]
    }
  ]
}

Use FECanvas to enable consistent font size of subtitles in videos of different resolutions

Note

FontSize specifies the number of pixels occupied by the height of a subtitle text in a video. By default, when the same FontSize is applied to videos of different resolutions, the resulting proportions are often inconsistent. For example, a FontSize of 100 may appear large in a 480P video but relatively small in a 720P video. To maintain a consistent font size of subtitles in videos of different resolutions, you can configure FECanvas in Timeline.

Effect

Timeline example

{
    "FECanvas": {
        "Height": 1280,
        "Width": 720
      },
    "VideoTracks": [
      {
        "VideoTrackClips": [
          {
            "MediaURL": "https://ice-document-materials.oss-cn-shanghai.aliyuncs.com/test_media/h2.mp4",
            "Effects": [
              {
                "Type": "Background",
                "SubType": "Blur",
                "Radius": 0.1
              }
            ]
          }
        ]
      }
    ],
    "SubtitleTracks": [
      {
        "SubtitleTrackClips": [
          {
            "Type": "Text",
            "X": 0,
            "Y": 200,
            "Content": "Heading in font size of 80",
            "Alignment": "TopCenter",
            "FontSize": 80,
            "FontColorOpacity": 1,
            "EffectColorStyle": "CS0003-000023",
            "FontFace": {
              "Bold": true
            }
          },
          {
            "Type": "Text",
            "X": 0,
            "Y": 320,
            "Font": "KaiTi",
            "Content": "Subheading in italics",
            "Alignment": "TopCenter",
            "FontSize": 45,
            "FontColor": "#ffffff",
            "FontFace": {
              "Italic": true,
              "Underline": true
            }
          },
          {
            "Type": "Text",
            "X": 50,
            "Y": 740,
            "Font": "AlibabaPuHuiTi",
            "Content": "Rotation",
            "FontColor": "#FFD700",
            "Outline": 4,
            "Angle": 350,
            "OutlineColour": "#000000",
            "FontSize": 60,
            "FontFace": {
              "Bold": true
            }
          },
          {
            "Type": "Text",
            "X": 0,
            "Y": 900,
            "Content": "Banner subtitle in a custom font \nAdd a black stroke with a width of 1",
            "FontUrl": "https://ice-document-materials.oss-cn-shanghai.aliyuncs.com/test_media/font/fangzhengfangsong.ttf",
            "Outline": 1,
            "OutlineColour": "000000",
            "Alignment": "TopCenter",
            "FontSize": 40,
            "FontColor": "#ffffff",
            "FontFace": {
              "Bold": true,
              "Italic": false,
              "Underline": false
            }
          },
          {
            "Type": "Text",
            "X": 20,
            "Y": 20,
            "Font": "KaiTi",
            "Content": "Add \n shadow \n effects",
            "Alignment": "BottomRight",
            "FontSize": 40,
            "FontColor": "#ffffff",
            "Shadow": 3,
            "BackColour": "#000000",
            "FontFace": {
              "Bold": false,
              "Italic": true,
              "Underline": false
            }
          }
        ]
      }
    ]
  }