答案1
我尝试了我最喜欢的阅读(3 段,最多 80 个字符):-)
lorem-ipsum-generator -l -p 3 -s 1 | fold -w 80 -s > TEXT
然后生成视频:
ffmpeg -loop 1 \
-i Blue-Planet-Earth-1920x1080.jpg
-vf drawtext="fontsize=20:fontcolor=white:fontfile=FreeSans.ttf:textfile=TEXT:y=h-200*t"
-t 8 output.mp4
解释:
文字超出上限,继续向上滚动。
现在任何人都可以生成它。
(感谢 FB!)
答案2
您可以使用字幕过滤高级 SubStation Alpha(ASS)字幕。使用/move
x
标签将允许您通过提供开始和结束坐标来滚动字幕y
。
优于绘制文本过滤器包括更多格式选项和自动换行文本的功能。缺点是,x
坐标y
似乎无法引用文本宽度和高度,因此您必须在标签中手动提供适当的值/move
。
使用以下方式制作的示例 ASS 文件埃吉苏布:
[Script Info]
; Script generated by Aegisub 3.2.2
; http://www.aegisub.org/
Title: Default Aegisub file
ScriptType: v4.00+
WrapStyle: 0
ScaledBorderAndShadow: yes
YCbCr Matrix: None
[Aegisub Project Garbage]
Last Style Storage: Default
[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: Default,Arial,20,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,1,1,5,10,10,10,1
[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,,{\move(190,350,180,-90)}Draw subtitles on top of input video using the libass library.\NTo enable compilation of this filter you need to configure FFmpeg wit{\i1}h --enable-liba{\i0}ss. This filter also requires a build with libavcodec and libavformat to convert the passed subtitles file to ASS (Advanced Substation Alpha) subtitles format.
示例ffmpeg
命令:
ffmpeg -loop 1 -i image.jpg -i audio.mp3 -filter_complex "subtitles=scroll.ass" -c:a copy -shortest output.mkv