首页 > 解决方案 > 如何在 FFMPEG 的同一命令中使用 -vf 和 -filter_complex

问题描述

我正在使用以下命令在 mac 上将视频转换为 FFMPEG 中的 gif:

ffmpeg -i screenAnimation2.mov -i palette.png -lavfi paletteuse -r "12" -s 300x200 -loop 2 screenAnimation2.gif 

效果很好,但我只想指定宽度并保持纵横比,这可以使用缩放过滤器来完成:

ffmpeg -i screenAnimation2.mov -i palette.png -lavfi paletteuse -r "12" -vf "scale=300:-1" -loop 2 screenAnimation2.gif 

但是,这会输出错误:

Filtergraph 'scale=300:-1' was specified through the -vf/-af/-filter option for output stream 0:0, which is fed from a complex filtergraph.
-vf/-af/-filter and -filter_complex cannot be used together for the same stream.

有没有办法结合2个过滤器?或者也许是一种获得正确高度值并避免使用比例过滤器的方法?

标签: bashffmpeggif

解决方案


您可以将它们组合在一个复杂的过滤器中:

-lavfi 'paletteuse,scale=300:-1'

推荐阅读