通过配置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
}]
}]
}