全部產品
Search
文件中心

ApsaraVideo VOD:短視頻常用功能

更新時間:Jul 13, 2024

通過配置Timeline提交剪輯合成作業時,您需要根據實際業務需求配置此參數。通過閱讀本文,您可以瞭解短視頻常用功能的Timeline樣本。

屬性說明

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

Timeline樣本

視頻橫轉豎——補充上下黑邊

如果Timeline中的素材為橫屏視頻,在調用介面ProduceEditingProjectVideo - 視頻合成提交合成任務時,通過設定參數ProduceConfig中的WidthHeight欄位將成片視頻設定為豎屏樣式,系統會根據素材和成片的寬高設定將素材置中展示。

{ "VideoTracks": [{ "VideoTrackClips": [{ "MediaId":"756620ed48c9af022c66ee1cbe2e****" },{ "MediaId":"8f5cdf044b059b3adc7967ba1cbe****" },{ "MediaId":"70dc95c0e31b71edbfe76fa3691c****" }] }] }
說明 如果您想自訂“黑邊”顏色,需要在Effects欄位中設定"SubType": "Color"。關於Effects具體參數說明,請參見Effect Type:Background 背景設定

視頻橫轉豎——補充上下模糊地區

如果Timeline中的素材為橫屏視頻,在調用介面ProduceEditingProjectVideo - 視頻合成提交合成任務時,通過設定參數ProduceConfig中的WidthHeight欄位將成片視頻設定為豎屏樣式,系統會根據素材和成片的寬高設定將素材置中展示,填充部分進行模糊處理。

{ "VideoTracks": [{ "VideoTrackClips": [{ "MediaId":"756620ed48c9af022c66ee1cbe2e****", "Effects": [{ "Type": "Background", "SubType": "Blur", "Radius": 0.1 }] }, { "MediaId":"8f5cdf044b059b3adc7967ba1cbe****", "Effects": [{ "Type": "Background", "SubType": "Blur", "Radius": 0.1 }] }, { "MediaId":"70dc95c0e31b71edbfe76fa3691c****", "Effects": [{ "Type": "Background", "SubType": "Blur", "Radius": 0.1 }] }] }] }

視頻橫轉豎——三分屏效果

{ "VideoTracks": [{ "VideoTrackClips": [{ "MediaId":"222d9296e8864746a0b6f32dad6e****", "Width": 1, "Height": 0.3333, "X": 0, "Y": 0.3333 },{ "MediaId":"70dc95c0e31b71edbfe76fa3691cs****", "Width": 1, "Height": 0.3333, "X": 0, "Y": 0.3333 },{ "MediaId":"756620ed48c9af022c66ee1cbe2se****", "Width": 1, "Height": 0.3333, "X": 0, "Y": 0.3333 }] },{ "VideoTrackClips": [{ "MediaId":"222d9296e8864746a0b6f32dad6e****", "Width": 1, "Height": 0.3333, "X": 0, "Y": 0 },{ "MediaId":"70dc95c0e31b71edbfe76fa3691cs****", "Width": 1, "Height": 0.3333, "X": 0, "Y": 0 },{ "MediaId":"756620ed48c9af022c66ee1cbe2se****", "Width": 1, "Height": 0.3333, "X": 0, "Y": 0 }] },{ "VideoTrackClips": [{ "MediaId":"222d9296e8864746a0b6f32dad6e****", "Width": 1, "Height": 0.3333, "X": 0, "Y": 0.6666 },{ "MediaId":"70dc95c0e31b71edbfe76fa3691cs****", "Width": 1, "Height": 0.3333, "X": 0, "Y": 0.6666 },{ "MediaId":"756620ed48c9af022c66ee1cbe2se****", "Width": 1, "Height": 0.3333, "X": 0, "Y": 0.6666 }] }], "SubtitleTracks":[ { "SubtitleTrackClips": [ { "Type": "Text", "X": 0, "Y": 200, "Font": "AlibabaPuHuiTi", "Content": "這裡是標題", "Alignment": "TopCenter", "FontSize": 80, "FontColorOpacity": 1, "1FontColor": "#ffffff", "FontColor": "#FFDEAD", "FontFace": { "Bold": true, "Italic": false, "Underline": false } } ] }, { "SubtitleTrackClips":[ { "Type":"Text", "X": 0, "Y": 200, "Font": "AlibabaPuHuiTi", "Content": "這裡是標題", "Alignment": "TopCenter", "FontSize": 80, "FontColorOpacity": 1, "FontColor": "#ffffff", "FontFace": { "Bold": true, "Italic": false, "Underline": false } }, { "Type":"Text", "X": 0, "Y": 320, "Font": "KaiTi", "Content": "這裡是副標題", "Alignment": "TopCenter", "FontSize": 45, "FontColor": "#ffffff", "FontFace": { "Bold": false, "Italic": true, "Underline": true } },{ "Type":"Text", "X": 0, "Y": 900, "Font": "AlibabaPuHuiTi", "Content": "這裡是橫幅字幕\n可以加分行符號進行多行展示", "Alignment": "TopCenter", "FontSize": 40, "FontColor": "#ffffff", "FontFace": { "Bold": true, "Italic": false, "Underline": false } } ] } ] }

視頻水平翻轉、豎直翻轉

{ "VideoTracks": [ { "VideoTrackClips": [ { "MediaId":"222d9296e8864746a0b6f32dad6e****", "Width": 0.48, "Height": 0.49, "X": 0, "Y": 0, "Effects": [ { "Type": "Text", "FixedX": 0, "FixedY": 0, "FontURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/material/AliHYAiHei.ttf", "Content": "原視頻", "Alignment": "TopLeft", "FontSize": 100, "FontColor": "#F5FFFA", "TimelineIn": 0, "TimelineOut": 10, "Outline": 2, "OutlineColour": "#0e0100" } ] } ] }, { "VideoTrackClips": [ { "MediaId":"222d9296e8864746a0b6f32dad6e****", "Width": 0.48, "Height": 0.49, "X": 0.5, "Y": 0, "Effects": [ { "Type": "Flip", "Direction": "horizontal" },{ "Type": "Text", "FixedX": 0.5, "FixedY": 0, "FontURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/material/AliHYAiHei.ttf", "Content": "視頻水平翻轉", "Alignment": "TopLeft", "FontSize": 100, "FontColor": "#F5FFFA", "TimelineIn": 0, "TimelineOut": 10, "Outline": 2, "OutlineColour": "#0e0100" } ] } ] }, { "VideoTrackClips": [ { "MediaId":"222d9296e8864746a0b6f32dad6e****", "Width": 0.48, "Height": 0.49, "X": 0, "Y": 0.5, "Effects": [ { "Type": "Flip", "Direction": "vertical" },{ "Type": "Text", "FixedX": 0, "FixedY": 0.5, "FontURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/material/AliHYAiHei.ttf", "Content": "視頻豎直翻轉", "Alignment": "TopLeft", "FontSize": 100, "FontColor": "#F5FFFA", "TimelineIn": 0, "TimelineOut": 10, "Outline": 2, "OutlineColour": "#0e0100" } ] } ] }, { "VideoTrackClips": [ { "MediaId":"222d9296e8864746a0b6f32dad6e****", "Width": 0.48, "Height": 0.49, "X": 0.5, "Y": 0.5, "Effects": [ { "Type": "Flip", "Direction": "horizontal" },{ "Type": "Flip", "Direction": "vertical" },{ "Type": "Text", "FixedX": 0.5, "FixedY": 0.5, "FontURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/material/AliHYAiHei.ttf", "Content": "視頻水平豎直翻轉", "Alignment": "TopLeft", "FontSize": 100, "FontColor": "#F5FFFA", "TimelineIn": 0, "TimelineOut": 10, "Outline": 2, "OutlineColour": "#0e0100" } ] } ] } ] }

添加字幕

通過配置TimelineInTimelineOut欄位設定字幕的出入場時間,如果未設定,預設字幕從視頻第0秒顯示到視頻結束,常用來設定全域字幕效果。

{ "VideoTracks": [{ "VideoTrackClips": [{ "MediaId":"756620ed48c9af022c66ee1cbe2e****" }, { "MediaId":"8f5cdf044b059b3adc7967ba1cbe****" }, { "MediaId":"70dc95c0e31b71edbfe76fa3691c****" }] }], "SubtitleTracks": [{ "SubtitleTrackClips": [{ "Type": "Text", "X": 0, "Y": 200, "Font": "AlibabaPuHuiTi", "Content": "這裡是標題", "Alignment": "TopCenter", "FontSize": 80, "FontColorOpacity": 1, "FontColor": "#ffffff", "FontFace": { "Bold": true, "Italic": false, "Underline": false } }, { "Type": "Text", "X": 0, "Y": 320, "Font": "KaiTi", "Content": "這裡是副標題", "Alignment": "TopCenter", "FontSize": 45, "FontColor": "#ffffff", "FontFace": { "Bold": false, "Italic": true, "Underline": true } }, { "Type": "Text", "X": 50, "Y": 740, "Font": "AlibabaPuHuiTi", "Content": "角度旋轉", "FontColor": "#FFD700", "Outline": 4, "Angle": 350, "OutlineColour": "#000000", "FontSize": 60, "FontFace": { "Bold": true, "Italic": false, "Underline": false } }, { "Type": "Text", "X": 0, "Y": 900, "Font": "AlibabaPuHuiTi", "Content": "這裡是橫幅字幕\n可以加分行符號進行多行展示", "Alignment": "TopCenter", "FontSize": 40, "FontColor": "#ffffff", "FontFace": { "Bold": true, "Italic": false, "Underline": false } }, { "Type": "Text", "X": 0, "Y": 1000, "Font": "KaiTi", "Content": "設定字幕出入場時間", "Alignment": "TopCenter", "FontSize": 40, "FontColor": "#ffffff", "TimelineIn": 5, "TimelineOut": 25, "FontFace": { "Bold": false, "Italic": true, "Underline": false } } ] }] }

添加字幕描邊、陰影製作效果

{ "VideoTracks": [{ "VideoTrackClips": [{ "MediaId":"001d9296e8864746a0b6f32dad6e****" }] }], "SubtitleTracks":[ { "SubtitleTrackClips":[ { "Type":"Text", "X": 0, "Y": 210, "Font": "WenQuanYi Zen Hei Mono", "Content": "這裡是副標題", "Alignment": "TopCenter", "FontSize": 50, "FontColor": "#000000", "TimelineIn": 0, "TimelineOut": 10, "OutlineColour": "#ffffff", "Outline": 2, "FontFace": { "Bold": false, "Italic": false, "Underline": false } }, { "Type":"Text", "X": 0, "Y": 270, "Font": "WenQuanYi Zen Hei Mono", "Content": "這裡是標題", "Alignment": "TopCenter", "OutlineColour": "#000000", "Outline": 3, "FontSize": 70, "TimelineIn": 0, "TimelineOut": 10, "FontColor": "#ffffff", "FontFace": { "Bold": true, "Italic": false, "Underline": false } }, { "Type": "Text", "Y": 750, "Font": "AlibabaPuHuiTi", "Content": "這裡是大標題", "Alignment": "TopCenter", "FontSize": 100, "FontColor": "#FFD700", "Outline": 4, "OutlineColour": "#000000", "TimelineIn": 0, "TimelineOut": 10, "FontFace": { "Bold": true, "Italic": false, "Underline": false } }, { "Type": "Text", "Y": 850, "Content": "自訂字型檔", "Font": "KaiTi", "FontSize": 42, "Outline": 2, "OutlineColour": "#ee00ff", "FontUrl":"https://your-bucket.oss-cn-shanghai.aliyuncs.com/your_font.ttf", "TimelineIn": 0, "TimelineOut": 10, "Alignment": "TopCenter", "FontColor": "#000000", "FontFace": { "Bold": false, "Italic": false, "Underline": false } }, { "Type": "Text", "Y": 900, "Font": "WenQuanYi Zen Hei Mono", "Content": "陰影製作效果", "FontColor": "#ffffff", "FontSize": 40, "Outline": 2, "OutlineColour": "#DB7093", "Shadow": 3, "BackColour": "#FFF0F5", "TimelineIn": 0, "TimelineOut": 10, "Alignment": "TopCenter", "FontFace": { "Bold": false, "Italic": false, "Underline": false } }, { "Type": "Text", "Y": 980, "Font": "WenQuanYi Zen Hei Mono", "Content": "添加字幕動畫", "FontColor": "#ffffff", "FontSize": 50, "TimelineIn": 0, "TimelineOut": 10, "Alignment": "TopCenter", "AaiMotionLoopEffect": "rollleft_display", "FontFace": { "Bold": true, "Italic": false, "Underline": false } } ] } ] }

設定字幕局部效果

通過在Content欄位中添加覆寫代碼,設定字幕局部效果。覆寫代碼說明如下所示:

  • 所有覆寫代碼均以兩個反斜線(\\)開頭。
  • 所有局部參數覆寫代碼必須在{}中,且一個{}可以包含多個覆寫代碼。
  • 覆寫代碼會作用於其後的字幕上,如果想要結束該覆寫代碼,需要加一個與之對應的結束覆寫代碼來取消該效果。
{ "VideoTracks": [ { "VideoTrackClips": [ { "MediaId":"333d9296e8864746a0b6f32dad6e****" } ] } ], "SubtitleTracks": [ { "SubtitleTrackClips": [ { "Type": "Text", "X": 0, "Y": 150, "FontURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/material/AliHYAiHei.ttf", "Content": "這裡設定{\\1c&0801ea&\\3c&f7fcff&}深紅色{\\1c\\3c}", "Alignment": "TopCenter", "FontSize": 65, "FontColor": "#F5FFFA", "TimelineIn": 0, "TimelineOut": 10, "Outline": 2, "OutlineColour": "#0e0100" }, { "Type": "Text", "X": 0, "Y": 300, "FontURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/material/AliHYAiHei.ttf", "Content": "這裡設定{\\fs100}100號{\\fs}字型", "Alignment": "TopCenter", "FontColor": "#F5FFFA", "FontSize": 65, "TimelineIn": 0, "TimelineOut": 10, "Outline": 2, "OutlineColour": "#0e0100" }, { "Type": "Text", "Y": 450, "FontURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/material/AliHYAiHei.ttf", "Content": "這裡設定{\\bord3\\3c&CD0000&}描邊{\\bord\\3c}顏色和大小", "Alignment": "TopCenter", "FontSize": 65, "FontColor": "#F5FFFA", "TimelineIn": 0, "TimelineOut": 10, "Outline": 2, "OutlineColour": "#0e0100" }, { "Type": "Text", "Y": 600, "Content": "這裡設定{\\bord3\\3c&701919&}不透明背景{\\bord\\3c}顏色和大小", "FontURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/material/AliHYAiHei.ttf", "FontSize": 65, "TimelineIn": 0, "TimelineOut": 10, "Alignment": "TopCenter", "FontColor": "#F5FFFA", "BorderStyle": 3, "Outline": 0, "OutlineColour": "#0000CD" }, { "Type": "Text", "Y": 750, "FontURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/material/AliHYAiHei.ttf", "Content": "這裡設定{\\fnKaiTi}黑體{\\fn}字型", "FontSize": 65, "TimelineIn": 0, "TimelineOut": 10, "FontColor": "#F5FFFA", "Alignment": "TopCenter", "Outline": 2, "OutlineColour": "#0e0100" }, { "Type": "Text", "Y": 900, "FontURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/material/AliHYAiHei.ttf", "Content": "這裡設定{\\b1}加粗{\\b0}效果", "FontSize": 65, "TimelineIn": 0, "TimelineOut": 10, "FontColor": "#F5FFFA", "Alignment": "TopCenter", "Outline": 2, "OutlineColour": "#0e0100" }, { "Type": "Text", "Y": 1050, "FontURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/material/AliHYAiHei.ttf", "Content": "這裡設定{\\i1}斜體{\\i0}效果", "FontSize": 65, "TimelineIn": 0, "TimelineOut": 10, "FontColor": "#F5FFFA", "Alignment": "TopCenter", "Outline": 2, "OutlineColour": "#0e0100" }, { "Type": "Text", "Y": 1200, "FontURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/material/AliHYAiHei.ttf", "Content": "這裡設定{\\u1}底線{\\u0}效果", "FontColor": "#F5FFFA", "FontSize": 65, "TimelineIn": 0, "TimelineOut": 10, "Alignment": "TopCenter", "Outline": 2, "OutlineColour": "#0e0100" }, { "Type": "Text", "Y": 1350, "FontURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/material/AliHYAiHei.ttf", "Content": "這裡設定{\\s1}刪除線{\\s0}效果", "FontColor": "#F5FFFA", "FontSize": 65, "TimelineIn": 0, "TimelineOut": 10, "Alignment": "TopCenter", "Outline": 2, "OutlineColour": "#0e0100" }, { "Type": "Text", "Y": 1500, "FontURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/material/AliHYAiHei.ttf", "Content": "這裡設定{\\1c&00FF00&\\b1\\fs100\\i1}組合{\\1c\\b0\\fs\\i0}效果", "FontColor": "#F5FFFA", "FontSize": 65, "TimelineIn": 0, "TimelineOut": 10, "Alignment": "TopCenter", "Outline": 2, "OutlineColour": "#0e0100" } ] } ] }

覆寫參數詳細說明:

覆寫參數描述Content參數樣本
  • \\1c&[BBGGRR]&
  • \\2c&[BBGGRR]&
  • \\3c&[BBGGRR]&
1c、2c、3c分別為字型、邊框、陰影對應的顏色;[BBGGRR]是十六進位的顏色BGR值,與一般的RGB顏色順序相反。"這裡設定{\\1c&00FF7F&}綠{\\1c}色"
  • \\bord[寬度]
  • \\xbord[寬度]
  • \\ybord[寬度]
bord、xbord、ybord分別為邊框、沿X軸邊框、沿Y軸邊框對應的寬度,單位為像素。"這裡設定{\\bord3\\3c&EBCE87&}描邊寬度{\\bord\\3c}顏色和大小"
\\b1 \\b0b1為加粗,b0為取消加粗。"這裡設定{\\b1}加粗{\\b0}效果",
\\i1 \\i0i1為斜體,i0為取消斜體。"這裡設定{\\i1}斜體{\\i0}效果"
\\u1 \\u0u1為加底線,u0為取消底線。"這裡設定{\\u1}底線{\\u0}效果"
\\s1 \\s0s1為加文本刪除線,s0為取消刪除線。"這裡設定{\\s1}刪除線{\\s0}效果"
\\fs[字型尺寸]字幕大小,單位為像素。"這裡設定{\\fs100}100號{\\fs}文字"
\\fn[字型名稱]字幕名稱,暫不支援設定自訂字型。"這裡設定{\\fnKaiTi}黑體{\\fn}字型"

設定字幕自動換行

{ "VideoTracks": [ { "VideoTrackClips": [ { "MediaId":"333d9296e8864746a0b6f32dad6e****" } ] } ], "SubtitleTracks": [ { "SubtitleTrackClips": [ { "Type": "Text", "X": 0, "Y": 400, "FontURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/material/AliHYAiHei.ttf", "Content": "當不設定字幕自動換行或自動縮放時會超出視頻畫布", "Alignment": "TopCenter", "FontSize": 100, "FontColor": "#F5FFFA", "TimelineIn": 0, "TimelineOut": 10, "Outline": 2, "OutlineColour": "#0e0100" }, { "Type": "Text", "X": 0, "Y": 900, "FontURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/material/AliHYAiHei.ttf", "Content": "當字幕超出視頻尺寸時觸發自動換行", "AdaptMode": "AutoWrap", "Alignment": "TopCenter", "FontSize": 100, "FontColor": "#F5FFFA", "TimelineIn": 0, "TimelineOut": 10, "Outline": 2, "OutlineColour": "#0e0100" }, { "Type": "Text", "X": 0, "Y": 1400, "FontURL": "https://your-bucket.oss-cn-shanghai.aliyuncs.com/material/AliHYAiHei.ttf", "Content": "當字幕超出視頻尺寸時觸發自動縮放", "AdaptMode": "AutoScale", "Alignment": "TopCenter", "FontSize": 100, "FontColor": "#F5FFFA", "TimelineIn": 0, "TimelineOut": 10, "Outline": 2, "OutlineColour": "#0e0100" } ] } ] }

添加GIF貼紙

配置DyncFrames欄位,設定動圖的幀率。

{ "VideoTracks": [{ "VideoTrackClips": [{ "MediaId":"756620ed48c9af022c66ee1cbe2e****" },{ "MediaId":"8f5cdf044b059b3adc7967ba1cbe****" },{ "MediaId":"70dc95c0e31b71edbfe76fa3691c****" }] },{ "VideoTrackClips": [{ "MediaId":"333d9296e8864746a0b6f32dad6e****", "Type": "image", "Duration": 10, "TimelineIn": 0, "DyncFrames": 10, "X": 50, "Y": 1300, "Effects": [{ "Type": "Scale", "Width": 200, "Height": 200 }] },{ "MediaId":"ea9a6f9bdb68419abfd36a7113cf****", "Type": "image", "Duration": 10, "TimelineIn": 10, "DyncFrames": 10, "X": 800, "Y": 400, "Effects": [{ "Type": "Scale", "Width": 200, "Height": 200 }] },{ "MediaId":"3f7e62d41a334dec9ac802b0f165****", "Type": "image", "Duration": 10, "TimelineIn": 20, "DyncFrames": 10, "X": 100, "Y": 400, "Effects": [{ "Type": "Scale", "Width": 200, "Height": 200 }] }] }] }

全域特效、濾鏡

如果需要為整個視頻添加特效、濾鏡,需要在EffectTrack屬性中添加特效,無需設定TimelineInTimelineOut,特效會從第0秒渲染至視頻結束,常用於配置全域特效。

{ "VideoTracks": [{ "VideoTrackClips": [{ "MediaId":"756620ed48c9af022c66ee1cbe2e****" }, { "MediaId":"8f5cdf044b059b3adc7967ba1cbe****" }, { "MediaId":"70dc95c0e31b71edbfe76fa3691c****" }] }], "EffectTracks": [{ "EffectTrackItems": [{ "Type": "Filter", "SubType": "PL2" }] }] }

設定全域背景和全域Logo

通過配置"Type": "GlobalImage"(無需配置Duration),預設將圖片從視頻第0秒顯示到視頻結束。

{ "VideoTracks": [{ "VideoTrackClips": [{ "MediaId":"222d9296e8864746a0b6f32dad6e****", "Type": "GlobalImage" }] }, { "VideoTrackClips": [{ "MediaId":"001d9296e8864746a0b6f32dad4e****", "Effects": [{ "Type": "Volume", "Gain": 0 }] }, { "MediaId":"333d9296e8864746a0b6f32dad5e****", "Effects": [{ "Type": "Volume", "Gain": 0 }] }, { "MediaId":"444d9296e8864746a0b6f32dad7e****", "Effects": [{ "Type": "Volume", "Gain": 0 }] }, { "MediaId":"555d9296e8864746a0b6f32dad8e****", "Effects": [{ "Type": "Volume", "Gain": 0 }] }, { "MediaId":"8f5cdf044b059b3adc7967ba1cbe****" }] }, { "VideoTrackClips": [{ "MediaId":"756620ed48c9af022c66ee1cbe2e****", "Type": "GlobalImage", "X": 0.1, "Y": 0.1, "Width": 247, "Height": 74 }] }] }