If you use the timeline data to submit a production job, you must configure the Timeline parameter. This topic describes how to configure the Timeline parameter for video editing, subtitle creation, and album creation.

Description

For more information about the parameters in the following example, see Timeline: the information about the timeline of an online editing project.

Video editing

Add a subtitle in the center

To add a subtitle in the center at the top of a video, specify "Alignment": "TopCenter" and set Y to the distance between the subtitle text and the top of the screen.

{
  "VideoTracks": [
    {
      "VideoTrackClips": [
        {
          "MediaId": "4bcf9b4d7cf14dc7b83b0e801cbe****",
          "Effects": [
            {
              "Type": "Text",
              "X": 20,
              "Y": 34,
              "Font": "WenQuanYi Zen Hei Mono",
              "Content": "Top Center - A timeline is created when you add materials and configure special effects to create a video. ",
              "Alignment": "TopCenter",
              "FontSize": 26,
              "FontColorOpacity": 1,
              "FontColor": "#ff0000",
              "FontFace": {
                "Bold": true,
                "Italic": false,
                "Underline": false
              }
            },
            {
              "Type": "Text",
              "X": 100,
              "Y": 200,
              "Font": "WenQuanYi Zen Hei Mono",
              "Content": "Center Center - A timeline consists of tracks, materials, and effects.",
              "Alignment": "CenterCenter",
              "FontSize": 26,
              "FontColorOpacity": 0.8,
              "FontColor": "#ff0000"
            },
            {
              "Type": "Text",
              "X": 0.10,
              "Y": 0.1,
              "TimelineIn": 2,
              "TimelineOut": 15,
              "Font": "WenQuanYi Zen Hei Mono",
              "Content": "Bottom Center - A timeline is created when you add materials and configure special effects to create a video. A timeline consists of tracks, materials, and effects.",
              "Alignment": "BottomCenter",
              "FontSize": 26,
              "FontColor": "#000000"
            }
          ]
        }
      ]
    }
  ]
}
Note
  • Valid values of Alignment: BottomLeft, BottomCenter, BottomRight, CenterLeft, CenterCenter, CenterRight, TopLeft, TopCenter, and TopRight.
  • If Alignment is included in the Effects parameter, X indicates the distance between the subtitle text and the left side of the screen, and Y indicates the distance between the subtitle text and the top of the screen.

Add a watermark and specify the location, start time, and end time

{
    "VideoTracks":[
        {
            "VideoTrackClips":[
                {
                    "MediaId":"756620ed48c9af022c66ee1cbe2e****",
                    "Type":"Video",
                    "TimelineIn":0,
                    "TimelineOut":140,
                    "Duration":140
                }
            ]
        },
        {
            "VideoTrackClips":[
                {
                    "Effects":[
                        {
                            "Type":"Scale",
                            "TimelineIn":0,
                            "TimelineOut":100,
                            "Width":0.416,
                            "Height":0.2347
                        }
                    ],
                    "MediaId":"8f5cdf044b059b3adc7967ba1cbe****",
                    "Type":"Image",
                    "TimelineIn":0,
                    "TimelineOut":100,
                    "Duration":100,
                    "X":0.584,
                    "Y":0
                }
            ]
        }
    ]
}

Add a watermark without specifying the duration

Use ImageTracks to configure a watermark. This way, you do not need to specify a duration. The watermark is displayed in the entire video.

{
    "VideoTracks":[
        {
            "Count":3,
            "VideoTrackClips":[
                {
                    "MediaId":"8f5cdf044b059b3adc7967ba1cbe****",
                    "Type":"Image",
                    "Duration":5
                },
                {
                    "MediaId":"756620ed48c9af022c66ee1cbe2e****",
                    "Type":"Image",
                    "Duration":5
                },
                {
                    "MediaId":"8f5cdf044b059b3adc7967ba1cbe****",
                    "Type":"Image",
                    "Duration":5
                }
            ]
        }
    ],
    "ImageTracks": [
        {
            "ImageTrackClips": [
                {
                    "ImageId": "756620ed48c9af022c66ee1cbe2e****",
                    "Width" : 200,
                    "Height" : 100,
                    "X" : 100,
                    "Y" : 100
                }
            ]
        }
    ]
}

Configure picture-in-picture

{
    "VideoTracks":[
        {
            "VideoTrackClips":[
                {
                    "MediaId":"756620ed48c9af022c66ee1cbe2e****",
                    "Type":"Video"
                }
            ]
        },
        {
            "VideoTrackClips":[
                {
                    "Effects":[
                        {
                            "Type":"Scale",
                            "TimelineIn":0,
                            "TimelineOut":100,
                            "Width":0.3,
                            "Height":0.4
                        }
                    ],
                    "MediaId":"8f5cdf044b059b3adc7967ba1cbe****",
                    "Type":"Video",
                    "Duration":100,
                    "X":0.5,
                    "Y":0
                }
            ]
        }
    ]
}

Combine multiple videos and add transition effects and background music

{
    "VideoTracks":[
        {
            "VideoTrackClips":[
                {
                    "MediaId":"8f5cdf044b059b3adc7967ba1cbe****",
                    "Effects":[
                        {
                            "Type":"Transition",
                            "SubType":"directional",
                            "Duration":2
                        }
                    ]
                },
                {
                    "MediaId":"756620ed48c9af022c66ee1cbe2e****",
                    "Effects":[
                        {
                            "Type":"Transition",
                            "SubType":"waterdrop",
                            "Duration":1
                        }
                    ]
                },
                {
                    "MediaId":"8f5cdf044b059b3adc7967ba1cbe****"
                }
            ]
        }
    ],
    "AudioTracks":[
        {
            "AudioTrackClips":[
                {
                    "MediaId":"756620ed48c9af022c66ee1cbe2e****"
                }
            ]
        }
    ]
}

Add two audio files to a picture album and configure the audios files to play simultaneously

{
    "VideoTracks":[
        {
            "VideoTrackClips":[
                {
                    "Type":"Image",
                    "MediaId":"8f5cdf044b059b3adc7967ba1cbe****",
                    "Duration":10
                },
                {
                    "Type":"Image",
                    "MediaId":"756620ed48c9af022c66ee1cbe2e****",
                    "Duration":10
                },
                {
                    "Type":"Image",
                    "MediaId":"8f5cdf044b059b3adc7967ba1cbe****",
                    "Duration":10
                },
                {
                    "Type":"Image",
                    "MediaId":"756620ed48c9af022c66ee1cbe2e****",
                    "Duration":10
                }
            ]
        }
    ],
    "AudioTracks":[
        {
            "AudioTrackClips":[
                {
                    "MediaId":"8f5cdf044b059b3adc7967ba1cbe****"
                }
            ]
        },
        {
            "AudioTrackClips":[
                {
                    "MediaId":"756620ed48c9af022c66ee1cbe2e****",
                   
                }
            ]
        }
    ]
}

Configure audio loop playback

{
    "VideoTracks": [
        {
            "VideoTrackClips": [
                {
                    "MediaId":"756620ed48c9af022c66ee1cbe2e****",
                }
            ]
        }
    ],
    "AudioTracks": [
        {
            "AudioTrackClips": [
                {
                    "MediaId":"756620ed48c9af022c66ee1cbe2e****",
                    "LoopMode": true,
                    "In": 42,
                    "Out": 58,
                    "TimelineIn": 5,
                    "TimelineOut": 30,
                    "Comment": "Play the audio from the 42nd to 58th second in a loop from the 5th to 30th second in the timeline."
                }
            ]
        }
    ]
}

Remove black bars

The following sample code provides an example on how to remove the black bars from the top and bottom of a 1920 × 1080 video and add subtitles to the video. The height of the black bars is 130 pixels.

{
    "VideoTracks":[
        {
            "VideoTrackClips":[
                {
                    "MediaId":"756620ed48c9af022c66ee1cbe2e****",
                    "X":0,
                    "Y":0,
                    "Effects":[
                        {
                            "Type":"Crop",
                            "X":0,
                            "Width":1920,
                            "Height":820,
                            "Y":130
                        }
                    ]
                }
            ]
        }
    ],
    "SubtitleTracks":[
        {
            "SubtitleTrackClips":[
                {
                    "Type":"Subtitle",
                    "SubType":"srt",
                    "FileURL":"https://your-bucket.oss-cn-shanghai.aliyuncs.com/object.srt"
                }
            ]
        }
    ]
}
Important The following sample code provides an example on how to configure OutputConfig. OutputConfig specifies the size of the output video.
{
    "MediaId":"8f5cdf044b059b3adc7967ba1cbe****",
    "Width":1920,
    "Height":820
}

Use GIF stickers

To use GIF stickers, you must configure DyncFrames. DyncFrames specifies the frame rate of the stickers.

{
    "VideoTracks": [{
        "VideoTrackClips": [{
            "MediaId":"8f5cdf044b059b3adc7967ba1cbe****"
        }]
    }, {
        "VideoTrackClips": [{
            "MediaId":"756620ed48c9af022c66ee1cbe2e****",
            "Type": "Image",
            "DyncFrames": 8,
            "TimelIneIn": 0.0,
            "TimelIneOut": 50.0,
            "X": 50,
            "Y": 50,
            "Effects": [{
                "Type": "Scale",
                "Height": 100,
                "Width": 100
            }]
    }]
}

Use rendering filters

{
  "VideoTracks": [{
    "VideoTrackClips": [{
      "TimelineIn": 0,
      "Type": "Video",
      "Out": 10,
      "MediaId": "MediaId1",
      "Effects": [{
        "SubType": "color",
        "ExtParams": "effect=color,brightness=80,contrast=0,saturation=0,kelvin_temperature=6000,temperature_ratio=0,tint=0,dark_corner_ratio=0",
        "Type": "Filter",
        "TimelineIn": 0,
        "TimelineOut": 10
      }]
    }]
  }]
}

Configure speed ramping

To change the playback speed of a clip, configure the Speed property. After you configure speed ramping, the duration of the clip is changed. For example, if Out is set to 10 seconds and Speed is set to 2 for a clip, the duration of the clip in the timeline is 5 seconds. In this case, set TimelineOut to 5. If TimelineIn and TimelineOut are left empty, the position of the clip in the timeline is automatically calculated during production based on the values of In, Out, and Speed.

{
  "VideoTracks": [{
    "VideoTrackClips": [{
      "MediaId":"8f5cdf044b059b3adc7967ba1cbe****",
      "Speed": 2,
      "Out": 10,
      "TimelineIn": 0,
      "TimelineOut": 5
    }, {
      "MediaId":"8f5cdf044b059b3adc7967ba1cbe****",
      "Speed": 0.5,
      "In": 10,
      "Out": 20
    }]
  }],
  "AudioTracks": [{
    "AudioTrackClips": [{
      "MediaId":"756620ed48c9af022c66ee1cbe2e****",
      "Speed": 2
    }]
  }]
}

Configure material rotation

To rotate the material, set "Type": "Rotate". You can rotate materials by 90, 180, and 270 degrees.

  • Rotate a material in a video track
    {
      "VideoTracks": [
        {
          "VideoTrackClips": [
            {
              "MediaId":"8f5cdf044b059b3adc7967ba1cbe****",
              "In": 0,
              "Out": 5,
              "Effects": [
                {
                  "Type": "Rotate",
                  "Degree": 90
                }
              ]
            }
          ]
        }
      ]
    }
  • Rotate a material in an image track
    {
      "VideoTracks": [
        {
          "VideoTrackClips": [
            {
              "MediaId":"8f5cdf044b059b3adc7967ba1cbe****",
              "In": 0,
              "Out": 15
            }
          ]
        }
      ],
      "ImageTracks": [
        {
          "ImageTrackClips": [
            {
              "ImageId": "70dc95c0e31b71edbfe76fa3691c****",
              "Width": 0.9,
              "Height": 0.9,
              "X": 0.15,
              "Y": 0.15,
              "Effects": [
                {
                  "Type": "Rotate",
                  "Degree": 90
                }
              ]
            }
          ]
        }
      ]
    }

Add images to the entire video

To add images to the entire video, specify GlobalImage. You do not need to specify the duration. By default, the images are displayed for the total duration of all video tracks after merging. This allows you to configure a global background and global watermark.

  • Configure a global watermark
    {
        "VideoTracks": [
            {
                "VideoTrackClips": [
                    {
                        "MediaId":"8f5cdf044b059b3adc7967ba1cbe****"
                    }
                ]
            },
            {
                "VideoTrackClips": [
                    {
                        "MediaId":"756620ed48c9af022c66ee1cbe2e****",
                        "Type": "GlobalImage",
                        "X": 0.1,
                        "Y": 0.1,
                        "Width": 247,
                        "Height": 74
                    }
                ]
            }
        ]
    }
  • Configure a global background
    {
        "VideoTracks": [
            {
                "VideoTrackClips": [
                    {
                        "MediaId":"756620ed48c9af022c66ee1cbe2e****",
                        "Type": "GlobalImage"
                    }
                ]
            },
            {
                "VideoTrackClips": [
                    {
                        "MediaId":"8f5cdf044b059b3adc7967ba1cbe****",
                        "Effects": [
                            {
                                "Type": "Volume",
                                "Gain": 0
                            }
                        ]
                    }
                ]
            }
        ]
    }

Configure MaxOut for a video track

To clip a video segment from a video track, configure MaxOut. The following rules apply when you clip a video:

  • If the value of MaxOut is smaller than the duration of the original material, MaxOut indicates the time when the material is cut from the original material.
  • If the value of MaxOut is greater than the duration of the original material, the material is cut from the end of the original material.
{
    "VideoTracks": [
        {
            "VideoTrackClips": [
            {
                "MediaId":"8f5cdf044b059b3adc7967ba1cbe****",
                "MaxOut": 10
            },{
                "MediaId":"8f5cdf044b059b3adc7967ba1cbe****",
                "Effects": [{
                "Type": "Scale",
                "Width": 0.8,
                "Height": 0.8
            }]
        }]
    }]
}
Note
  • If you configure Out to cut a video segment and the value of Out is greater than the duration of the original material, static images appear.
  • If you configure MaxOut and Out, Out takes effect and MaxOut becomes invalid.

Use a random effect

ApsaraVideo VOD supports random effects. You can cut a random clip and use a random filter, random special effect, and random transition effect in a timeline.

  • Random clip: randomly select a clip of a specified duration from the original material and add the clip to the timeline.
  • Random filter: randomly select a filter from a specified range or from all filters.
  • Random special effect: randomly select a special effect from a specified range or from all special effects.
  • Random transition effect: randomly select a transition effect from a specified range or from all transition effect.
{
    "VideoTracks": [
        {
            "VideoTrackClips": [
                {
                    "MediaId": "8f5cdf044b059b3adc7967ba1cbe****",
                    "TimelineIn": 0,
                    "Effects": [
                        {
                            "Comment": "Randomly select a transition effect from all transition effects",
                            "Type": "Transition",
                            "SubType": "random",
                            "Duration": 1
                        },
                        {
                            "Comment": "Randomly cut a clip of 5 seconds from the material.",
                            "Type": "Clip",
                            "SubType": "RandomClip",
                            "ClipDuration": 5
                        }
                    ]
                },
                {
                    "MediaId": "8f5cdf044b059b3adc7967ba1cbe****",
                    "TimelineIn": 5,
                    "Effects": [
                        {
                            "Comment": "Randomly select a special effect among open, zoom, and disappear.",
                            "Type": "VFX",
                            "SubType": "open,zoom,disappear"
                        }
                    ]
                },
                {
                    "MediaId": "8f5cdf044b059b3adc7967ba1cbe****",
                    "TimelineIn": 10,
                    "Effects": [
                        {
                            "Comment": "Randomly select a filter among pl4, colorfulstarry, and flyfire.",
                            "Type": "Filter",
                            "SubType": "pl4,colorfulstarry,flyfire"
                        }
                    ]
                }
            ]
        }
    ]
}

Subtitle production

Configure line breaking and alignment

To configure line breaking, add \n or \\n in the subtitle text. To configure the alignment of the subtitle text, specify Alignment.

{
  "VideoTracks": [
    {
      "VideoTrackClips": [
        {
          "MediaId": "8f5cdf044b059b3adc7967ba1cbe****",
          "Effects": [
            {
              "Type": "Text",
              "X": 20,
              "Y": 34,
              "Font": "WenQuanYi Zen Hei Mono",
              "Content": "Add \n to configure a line breaking and set Alignment to TopCenter to center the subtitle text in each line.",
              "Alignment": "TopCenter",
              "FontSize": 26,
              "FontColorOpacity": 1,
              "FontColor": "#ff0000",
              "FontFace": {
                "Bold": true,
                "Italic": false,
                "Underline": false
              }
            },
            {
              "Type": "Text",
              "X": 100,
              "Y": 200,
              "Font": "WenQuanYi Zen Hei Mono",
              "Content": "Add \n to configure a line breaking and set Alignment to TopLeft to align the subtitle text to the left.",
              "Alignment": "TopLeft",
              "FontSize": 26,
              "FontColorOpacity": 0.8,
              "FontColor": "#ff0000"
            },
            {
              "Type": "Text",
              "X": 0.10,
              "Y": 0.1,
              "TimelineIn": 2,
              "TimelineOut": 15,
              "Font": "WenQuanYi Zen Hei Mono",
              "Content": "Add \n to configure a line breaking and set Alignment to TopRight to align the subtitle text to the right.",
              "Alignment": "TopRight",
              "FontSize": 26,
              "FontColor": "#000000"
            }
          ]
        }
      ]
    }
  ]
}

Configure special effects and word art effects for text

To configure a word art effect, specify EffectColorStyle and the stroke width and shadow color. For more word art examples, see Word art effect examples.

{
  "VideoTracks": [{
    "VideoTrackClips": [{
      "MediaId": "756620ed48c9af022c66ee1cbe2e****",
      "Effects": [{
        "Type": "Text",
        "X": 33,
        "Y": 34,
        "Font": "WenQuanYi Zen Hei Mono",
        "Content": "Word art: brushed_aluminium, entrance effect: rotateflip_in, exit effect: slide_down_out",
        "OutlineColour": "#4effcf",
        "BackColour": "#2effc6",
        "Outline": 2,
        "Shadow": 2,
        "EffectColorStyle": "brushed_aluminium",
        "FontSize": 42,
        "AaiMotionInEffect": "rotateflip_in",
        "AaiMotionIn": 1,
        "AaiMotionOutEffect": "slide_down_out",
        "AaiMotionOut": 1,
        "FontFace": {
          "Bold": true,
          "Italic": false,
          "Underline": false
        }
      },
        {
          "Type": "Text",
          "X": 66,
          "Y": 256,
          "Font": "WenQuanYi Zen Hei Mono",
          "Content": "Word art: deep_sea, loop effect: rainbrush_display, quick loop",
          "EffectColorStyle": "deep_sea",
          "OutlineColour": "#e9e9e9",
          "BackColour": "#30335c",
          "Outline": 2,
          "Shadow": 2,
          "AaiMotionLoopEffect": "rainbrush_display",
          "Ratio": 2,
          "FontSize": 38,
          "FontColorOpacity": 0.8,
          "FontColor": "#d60e0e"
        }
      ]
    }]
  }]
}
Note A loop effect does not work together with an entrance or exit effect for a text. If you configure a loop effect and an entrance or exit effect for a text, only the entrance and exit effects take effect.

Use a subtitle file in video editing

{
  "VideoTracks": [
    {
      "VideoTrackClips": [
        {
          "MediaId": "756620ed48c9af022c66ee1cbe2e****"
        },
        {
          "MediaId": "8f5cdf044b059b3adc7967ba1cbe****"
        }
      ]
    }
  ],
  "SubtitleTracks": [
    {
      "SubtitleTrackClips": [
        {
          "Type": "Subtitle",
          "SubType": "srt",
          "FileUrl": "http://your-bucket.oss-cn-shanghai.aliyuncs.com/your-subtitle.srt"
        }
      ]
    }
  ]
}

Configure a text background

To configure a text background, specify "BorderStyle": 3, the background width Outline, and background color OutlineColour.

{
 "VideoTracks": [{
  "VideoTrackClips": [{
   "MediaId":"8f5cdf044b059b3adc7967ba1cbe****",
   "Effects": [{
    "Type": "Text",
    "X": 33,
    "Y": 34,
    "Content": "Configure a text background.",
    "FontSize": 42,
    "BorderStyle": 3,
    "FontColor": "#4B0082",
    "Outline": 3,
    "OutlineColour": "#FFDEAD"
   }]
  }]
 }]
}

Picture album

Create a picture album without subtitles

Create a video based on the slides compiled from pictures and configure the picture sequence and Duration.

{
  "VideoTracks": [
      {
          "VideoTrackClips": [
              {
                "Type": "image",
                "MediaId": "756620ed48c9af022c66ee1cbe2e****",
                "Duration": 3
              },
              {
                "Type": "image",
                "MediaId": "8f5cdf044b059b3adc7967ba1cbe****",
                "Duration": 3
              },
              {
                "Type": "image",
                "MediaId": "70dc95c0e31b71edbfe76fa3691c****",
                "Duration": 3
              }
          ]
      }
  ]
}

Create a picture album with subtitles

Create a video based on the slides compiled from pictures and configure the picture sequence and Duration. Configure Effects to specify the format of the subtitle text.

{
    "VideoTracks": [{
      "VideoTrackClips": [{
        "Type": "image",
        "MediaId": "756620ed48c9af022c66ee1cbe2e****",
        "Effects": [
          {
            "Type": "Text",
            "X": 33,
            "Y": 34,
            "Font": "WenQuanYi Zen Hei Mono",
            "Content": "Test text",
            "FontSize": 26,
            "FontColorOpacity": 1,
            "FontColor": "#000000",
            "FontFace": {
              "Bold": true,
              "Italic": false,
              "Underline": false
            }
          }
        ],
          "Duration": 5
      }, {
        "Type": "image",
        "MediaId": "8f5cdf044b059b3adc7967ba1cbe****",
        "Duration": 5
      }, {
        "Type": "image",
        "MediaId": "70dc95c0e31b71edbfe76fa3691c****",
        "Effects": [
          {
            "Type": "Text",
            "X": 0.7123,
            "Y": 0.7896,
            "TimelineIn": 11,
            "TimelineOut": 13,
            "Font": "WenQuanYi Zen Hei Mono",
            "Content": "Test text",
            "FontSize": 26,
            "FontColor": "#000000"
          }
        ],
        "Duration": 5
      }]
    }]
  }