如何在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
相关产品推荐
相关产品推荐

