You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在ffmpeg-python中用字典参数调用format=gray滤镜

解决ffmpeg-python中用字典传参实现format=gray滤镜的问题

对应的filter_name就是format,但需要调整你的filter_options参数键为pix_fmt,修正后的代码如下:

filter_options = {'pix_fmt': 'gray'}

(
    ffmpeg.input(img_seq_template, framerate=framerate, **input_options)
    .filter(filter_name="format", **filter_options)
    .output(filename=output_path, **output_options)
    .run(overwrite_output=True)
)

原因说明:

  • ffmpeg命令行中的-vf format="gray"本质是调用format滤镜,指定pix_fmt(像素格式)参数为gray,format="gray"是format=pix_fmt=gray的简写形式。
  • 在ffmpeg-python中用字典传参时,必须明确指定滤镜的参数名(不能用命令行的简写形式),因此参数键要写pix_fmt而非format,而滤镜名称filter_name就是format。

内容的提问来源于stack exchange,提问作者user19551045

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.21 13:16:17