ffmpeg 如何向一个输入视频添加多个绘图文本

Rav*_*ven 6 ffmpeg

我需要在视频中添加两个文本。第一个文本在前 6 秒内显示在右下角,第二个文本在最后 3 秒内显示在视频中央。

下面是我的代码:

ffmpeg -i input.mp4 -vf drawtext="text='Stack Overflow': fontcolor=white: borderw=2: fontfile=Arial Black: fontsize=w*0.04: x=(w-text_w)-(w*0.04): y=(h-text_h)-(w*0.04): enable='between(t,0,6)'", -vf drawtext="text='Stack Overflow': fontcolor=white: borderw=2: fontfile=Arial Black: fontsize=w*0.04: x=(w-text_w)/2: y=(h-text_h)/2: enable='between(t,7,10)'" -codec:a copy output2.mp4
Run Code Online (Sandbox Code Playgroud)

运行上面的代码没有出现任何错误,但在输出文件中,仅应用了第二个绘制文本。

l'L*_*L'l 7

绘制文本应放入其中-vf(使用“ [in]/ [out]”是可选的):

\n\n
ffmpeg -i input.m4 -vf "[in]drawtext=text=\'Stack Overflow\': \\\nfontcolor=white: borderw=2: fontfile=Arial Black: fontsize=w*0.04: \\\nx=(w-text_w)-(w*0.04): y=(h-text_h)-(w*0.04): enable=\'between(t,0,6)\', \\\ndrawtext=text=\'Stack Overflow\': fontcolor=white: borderw=2: \\\nfontfile=Arial Black: fontsize=w*0.04: x=(w-text_w)/2: y=(h-text_h)/2: \\\nenable=\'between(t,7,10)\'[out]" -codec:a copy output2.mp4\n
Run Code Online (Sandbox Code Playgroud)\n\n

\xe2\x86\xb3 10.47 绘制文本:ffmpeg 文档

\n