我正在寻找一种使用FFmpeg的方法来裁剪图像以删除所有白色像素;像Photoshop的“裁剪空白”。
我尝试环顾四周,但没有找到解决方案,这是我要寻找的示例:
我应该如何获得此修改?
答案 0 :(得分:3)
使用negate反转图像颜色,并使用cropdetect查找裁切参数:
ffmpeg -loop 1 -i input.png -frames:v 3 -vf "negate,cropdetect=limit=0:round=0" -f null -
...
[Parsed_cropdetect_1 @ 0x5581f7287580] x1:198 x2:1255 y1:472 y2:968 w:1058 h:496 x:198 y:472 pts:3 t:0.120000 crop=1056:496:200:472
根据需要用ffplay
测试:
ffplay -vf crop=1056:496:200:472 input.png
然后使用crop:
ffmpeg -i input.png -vf crop=1056:496:200:472 output.png
有关Bash shell示例的信息,请参见ffmpeg get value from cropdetect,以提取用于脚本用法的cropdetect值。