我需要在视频中添加两个文本。第一个文本在前 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)
运行上面的代码没有出现任何错误,但在输出文件中,仅应用了第二个绘制文本。
绘制文本应放入其中-vf(使用“ [in]/ [out]”是可选的):
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\nRun Code Online (Sandbox Code Playgroud)\n\n\xe2\x86\xb3 10.47 绘制文本:ffmpeg 文档
\n| 归档时间: |
|
| 查看次数: |
3485 次 |
| 最近记录: |