全部产品
Search
文档中心

视频点播:短视频常用功能

更新时间:Oct 16, 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 \\b0

b1为加粗,b0为取消加粗。

"这里设置{\\b1}加粗{\\b0}效果",

\\i1 \\i0

i1为斜体,i0为取消斜体。

"这里设置{\\i1}斜体{\\i0}效果"

\\u1 \\u0

u1为加下划线,u0为取消下划线。

"这里设置{\\u1}下划线{\\u0}效果"

\\s1 \\s0

s1为加文本删除线,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 }] }] }