通過配置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
值大于素材原時長時,會出現靜幀。 - 如果同時設置
MaxOut
和Out
,實際效果會以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
}]
}]
}