使用FFMPEG,我们如何在黑条区域或视频下方添加字幕?

问题描述

我遵循了以下步骤:

  1. 添加了黑条

    -vf“ scale = 1920:1080:force_original_aspect_ratio = decrease,pad = 1920:1080:(ow-iw)/ 2:(oh-ih)/ 2,setsar = 1”来源:How to add black borders to video

  2. 添加了字幕(将其“刻录”到了视频中)

    ffmpeg -i“ imput.mp4” -lavfi“ subtitles = subtitles.srt:force_style ='Alignment = 0,OutlineColour =&H100000000,BorderStyle = 3,Outline = 1,Shadow = 0,Fontsize = 18,MarginL = 5 ,MarginV = 25'“ -crf 1 -c:副本” output.mp4“来源:ffmpeg subtitles alignment and position

现在,我对如何将字幕置于视频下方或黑屏中感到困惑。

编辑:添加了截图以澄清

Screenshot of the Problem

解决方法

没有带黑条的视频屏幕截图,我们只能猜测哪种方法对您有用。

最容易尝试的方法是将字幕的默认位置设置在底部中央。

这是命令的组合版本,没有所有多余的垃圾:

ffmpeg -i input.mp4 -filter_complex "scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:-1:-1,setsar=1,subtitles=subtitles.srt[v]" -map "[v]" -map 0:a -c:a copy output.mp4

字幕将在底部中央显示标准位置。