全部產品
Search
文件中心

ApsaraVideo VOD:常見Timeline樣本

更新時間:Jul 13, 2024

通過配置Timeline提交剪輯合成作業時,您需要根據實際業務需求配置此參數。通過閱讀本文,您可以瞭解視頻混剪、字幕製作和圖片相簿的Timeline樣本。

屬性說明

以下樣本中的屬性詳情,請參見Timeline配置說明

視頻混剪

視頻添加置中字幕

通過設定"Alignment": "TopCenter"實現頂部置中,同時設定Y值指定字幕和螢幕上側距離。

{
  "VideoTracks": [
    {
      "VideoTrackClips": [
        {
          "MediaId": "4bcf9b4d7cf14dc7b83b0e801cbe****",
          "Effects": [
            {
              "Type": "Text",
              "X": 20,
              "Y": 34,
              "Font": "WenQuanYi Zen Hei Mono",
              "Content": "Top Center 時間軸是將素材按照視頻創意進行編排和特效設計的產物",
              "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 -時間軸主要包含軌道、素材、效果3種對象",
              "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 - 時間軸是將素材按照視頻創意進行編排和特效設計的產物。時間軸主要包含軌道、素材、效果3種對象",
              "Alignment": "BottomCenter",
              "FontSize": 26,
              "FontColor": "#000000"
            }
          ]
        }
      ]
    }
  ]
}
說明
  • Alignment取值:BottomLeft、BottomCenter、BottomRight、CenterLeft、CenterCenter、CenterRight、TopLeft、TopCenter、TopRight。
  • 當Effects中包含Alignment屬性時,字幕的X、Y座標表示margin。

視頻加浮水印——指定浮水印位置、開始和結束時間

{
    "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
                }
            ]
        }
    ]
}

視頻加浮水印——無需設定Duration(浮水印時間長度自適應)

通過使用ImageTracks方式設定浮水印,無需設定Duration,浮水印時間長度自適應。

{
    "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
                }
            ]
        }
    ]
}

視頻畫中畫

{
    "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
                }
            ]
        }
    ]
}

多視頻合成並添加轉場和背景音樂

{
    "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****"
                }
            ]
        }
    ]
}

圖片相簿疊加兩個音頻,音頻同時播放

{
    "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****",
                   
                }
            ]
        }
    ]
}

音頻迴圈播放

{
    "VideoTracks": [
        {
            "VideoTrackClips": [
                {
                    "MediaId":"756620ed48c9af022c66ee1cbe2e****",
                }
            ]
        }
    ],
    "AudioTracks": [
        {
            "AudioTrackClips": [
                {
                    "MediaId":"756620ed48c9af022c66ee1cbe2e****",
                    "LoopMode": true,
                    "In": 42,
                    "Out": 58,
                    "TimelineIn": 5,
                    "TimelineOut": 30,
                    "Comment": "將音頻42s~58s剪輯出來,在時間軸5s~30s上迴圈播放"
                }
            ]
        }
    ]
}

視頻裁剪——去掉上下黑邊

此處以將解析度為1920×1080的視頻剪掉上下黑邊(黑邊高130)併疊加字幕為例介紹。

{
    "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"
                }
            ]
        }
    ]
}
重要 需要指定輸出尺寸OutputConfig
{
    "MediaId":"8f5cdf044b059b3adc7967ba1cbe****",
    "Width":1920,
    "Height":820
}

使用GIF貼紙

使用GIF貼紙時需要設定DyncFrames(動圖幀率)。

{
    "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
            }]
    }]
}

調色濾鏡

{
  "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
      }]
    }]
  }]
}

音視頻變速

Clip中使用Speed屬性可以修改音視頻播放速率,變速後會修改Clip的時間長度。例如,Clip中Out為10s,Speed為2時,Clip在Timeline中的實際時間長度為5s,則TimelineOut應修改為5。如果TimelineIn、TimelineOut未設定,合成時會根據In、Out、Speed自動計算Clip在時間軸中的位置。

{
  "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
    }]
  }]
}

素材旋轉

通過設定"Type": "Rotate"旋轉素材一定角度,目前僅支援旋轉90°、180°、270°。

  • 視頻軌素材旋轉
    {
      "VideoTracks": [
        {
          "VideoTrackClips": [
            {
              "MediaId":"8f5cdf044b059b3adc7967ba1cbe****",
              "In": 0,
              "Out": 5,
              "Effects": [
                {
                  "Type": "Rotate",
                  "Degree": 90
                }
              ]
            }
          ]
        }
      ]
    }
  • 圖片軌素材旋轉
    {
      "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
                }
              ]
            }
          ]
        }
      ]
    }

視頻軌道中使用全域圖片

在視頻軌中使用全域圖片GlobalImage時,不需要設定圖片時間長度,預設所有視頻軌合并後的時間長度,可以用來在時間軸中設定全域背景或全域浮水印。

  • 設定全域浮水印
    {
        "VideoTracks": [
            {
                "VideoTrackClips": [
                    {
                        "MediaId":"8f5cdf044b059b3adc7967ba1cbe****"
                    }
                ]
            },
            {
                "VideoTrackClips": [
                    {
                        "MediaId":"756620ed48c9af022c66ee1cbe2e****",
                        "Type": "GlobalImage",
                        "X": 0.1,
                        "Y": 0.1,
                        "Width": 247,
                        "Height": 74
                    }
                ]
            }
        ]
    }
  • 設定全域背景
    {
        "VideoTracks": [
            {
                "VideoTrackClips": [
                    {
                        "MediaId":"756620ed48c9af022c66ee1cbe2e****",
                        "Type": "GlobalImage"
                    }
                ]
            },
            {
                "VideoTrackClips": [
                    {
                        "MediaId":"8f5cdf044b059b3adc7967ba1cbe****",
                        "Effects": [
                            {
                                "Type": "Volume",
                                "Gain": 0
                            }
                        ]
                    }
                ]
            }
        ]
    }

視頻軌中設定出點MaxOut

通過設定出點MaxOut截取視頻,規則如下:

  • 如果MaxOut值小於素材原時間長度,素材片段相對於素材的出點將被設定為MaxOut,用於截取素材。
  • 如果MaxOut值大於素材原時間長度,素材片段相對於素材的出點將被設定為素材原時間長度,用於自適應素材出點。
{
    "VideoTracks": [
        {
            "VideoTrackClips": [
            {
                "MediaId":"8f5cdf044b059b3adc7967ba1cbe****",
                "MaxOut": 10
            },{
                "MediaId":"8f5cdf044b059b3adc7967ba1cbe****",
                "Effects": [{
                "Type": "Scale",
                "Width": 0.8,
                "Height": 0.8
            }]
        }]
    }]
}
說明
  • 和設定MaxOut不同,如果通過設定Out截取視頻且Out值大於素材原時間長度時,會出現靜幀。
  • 如果同時設定MaxOutOut,實際效果會以Out為準,MaxOut的值會失效。

隨機效果

Timeline中支援設定多種隨機效果,例如:隨機截取、隨機濾鏡、隨機特效、隨機轉場。

  • 隨機截取:從原始素材中隨機截取一個指定時間長度的片段插入到時間軸中。
  • 隨機濾鏡:從指定範圍濾鏡或所有濾鏡效果中隨機選取一個。
  • 隨機特效:從指定範圍特效或所有特效效果中隨機選取一個。
  • 隨機轉場:從指定範圍轉場或所有轉場效果中隨機選取一個。
{
    "VideoTracks": [
        {
            "VideoTrackClips": [
                {
                    "MediaId": "8f5cdf044b059b3adc7967ba1cbe****",
                    "TimelineIn": 0,
                    "Effects": [
                        {
                            "Comment": "從所有轉場類型中隨機選取一個",
                            "Type": "Transition",
                            "SubType": "random",
                            "Duration": 1
                        },
                        {
                            "Comment": "從該素材中隨機截取5s的素材片段",
                            "Type": "Clip",
                            "SubType": "RandomClip",
                            "ClipDuration": 5
                        }
                    ]
                },
                {
                    "MediaId": "8f5cdf044b059b3adc7967ba1cbe****",
                    "TimelineIn": 5,
                    "Effects": [
                        {
                            "Comment": "從open,zoom,disappear中隨機選取一個特效",
                            "Type": "VFX",
                            "SubType": "open,zoom,disappear"
                        }
                    ]
                },
                {
                    "MediaId": "8f5cdf044b059b3adc7967ba1cbe****",
                    "TimelineIn": 10,
                    "Effects": [
                        {
                            "Comment": "pl4,colorfulstarry,flyfire中隨機選取一個濾鏡",
                            "Type": "Filter",
                            "SubType": "pl4,colorfulstarry,flyfire"
                        }
                    ]
                }
            ]
        }
    ]
}

字幕製作

視頻添加換行字幕並設定對齊

通過添加\n\\n實現換行,添加Alignment屬性設定對齊。

{
  "VideoTracks": [
    {
      "VideoTrackClips": [
        {
          "MediaId": "8f5cdf044b059b3adc7967ba1cbe****",
          "Effects": [
            {
              "Type": "Text",
              "X": 20,
              "Y": 34,
              "Font": "WenQuanYi Zen Hei Mono",
              "Content": "在Content中添加\n來實現換行,Alignment設定TopCenter來實現字幕換行後置中對齊",
              "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": "在Content中添加\n來實現換行,Alignment設定TopLeft來實現字幕換行後靠左對齊",
              "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": "在Content中添加\n來實現換行,Alignment設定TopRight來實現字幕換行後靠右對齊",
              "Alignment": "TopRight",
              "FontSize": 26,
              "FontColor": "#000000"
            }
          ]
        }
      ]
    }
  ]
}

字幕特效+花字效果

通過添加EffectColorStyle屬性設定花字效果,同時需要設定描邊寬度和陰影顏色。更多花字效果樣本,請參見花字效果樣本

{
  "VideoTracks": [{
    "VideoTrackClips": [{
      "MediaId": "756620ed48c9af022c66ee1cbe2e****",
      "Effects": [{
        "Type": "Text",
        "X": 33,
        "Y": 34,
        "Font": "WenQuanYi Zen Hei Mono",
        "Content": "brushed_aluminium花字,rotateflip_in入場特效,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": "deep_sea花字,rainbrush_display迴圈特效,快速迴圈",
          "EffectColorStyle": "deep_sea",
          "OutlineColour": "#e9e9e9",
          "BackColour": "#30335c",
          "Outline": 2,
          "Shadow": 2,
          "AaiMotionLoopEffect": "rainbrush_display",
          "Ratio": 2,
          "FontSize": 38,
          "FontColorOpacity": 0.8,
          "FontColor": "#d60e0e"
        }
      ]
    }]
  }]
}
說明 設定字幕特效時,迴圈特效不能與入場、出場特效共存,且入場、出場特效優先順序高於迴圈特效。

直接使用字幕檔案進行剪輯

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

設定字幕純色背景

通過設定"BorderStyle": 3,同時設定邊框寬度Outline和邊框顏色OutlineColour,實現設定字幕純色背景。

{
 "VideoTracks": [{
  "VideoTrackClips": [{
   "MediaId":"8f5cdf044b059b3adc7967ba1cbe****",
   "Effects": [{
    "Type": "Text",
    "X": 33,
    "Y": 34,
    "Content": "設定字幕純色背景",
    "FontSize": 42,
    "BorderStyle": 3,
    "FontColor": "#4B0082",
    "Outline": 3,
    "OutlineColour": "#FFDEAD"
   }]
  }]
 }]
}

圖片相簿

製作不帶字幕的圖片相簿

設定圖片展示順序和每張圖片的持續時間長度Duration建立圖片投影片視頻。

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

製作帶字幕的圖片相簿

設定圖片展示順序和每張圖片的持續時間長度Duration,同時設定Effects屬性,建立帶字幕的圖片投影片視頻。

{
    "VideoTracks": [{
      "VideoTrackClips": [{
        "Type": "image",
        "MediaId": "756620ed48c9af022c66ee1cbe2e****",
        "Effects": [
          {
            "Type": "Text",
            "X": 33,
            "Y": 34,
            "Font": "WenQuanYi Zen Hei Mono",
            "Content": "測試文字",
            "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": "測試文字",
            "FontSize": 26,
            "FontColor": "#000000"
          }
        ],
        "Duration": 5
      }]
    }]
  }