ffmpeg 给视频自动加黑边
时间:2021-12-29 12:01:10 +0800 CST 浏览:807

测试文件

# 生成一个720x576 sar不是1:1的视频
ffmpeg -i input.mp4 -s 720x576 -aspect 4:3 -vf "crop=720:576:0:0" -c:v libx264 -c:a copy -t 30 input_720x576.mp4

方法1

ffmpeg -i input_720x576.mp4 -vf "scale='min(720,trunc((576*dar+0.5)/2)*2)':'min(576,trunc((720/dar+0.5)/2)*2)':flags=lanczos,pad=720:576:(ow-iw)/2:(oh-ih)/2:#000000,setsar='r=1/1'" output.mp4
# 快速预览效果
ffplay -vf "scale='min(720,trunc((576*dar+0.5)/2)*2)':'min(576,trunc((720/dar+0.5)/2)*2)':flags=lanczos,pad=720:576:(ow-iw)/2:(oh-ih)/2:#000000,setsar='r=1/1'" input_720x576.mp4

方法2

ffmpeg -i input_720x576.mp4 -vf "scale='trunc(ih*dar/2)*2:trunc(ih/2)*2',setsar=1/1,scale=w=720:h=576:force_original_aspect_ratio=1,pad=720:576:(ow-iw)/2:(oh-ih)/2:#000000" -y -t 30 output.mp4
# 快速预览效果
ffplay -vf "scale='trunc(ih*dar/2)*2:trunc(ih/2)*2',setsar=1/1,scale=w=720:h=576:force_original_aspect_ratio=1,pad=720:576:(ow-iw)/2:(oh-ih)/2:#000000" input_720x576.mp4


如果这篇文章对你有所帮助,可以通过下边的“打赏”功能进行小额的打赏。

本网站部分内容来源于互联网,如有侵犯版权请来信告知,我们将立即处理。


来说两句吧