<p>不确定你是否明白了这一点。。。但这里有一种方法对我很有效</p>
<p><strong>Tip1:</strong>使用库“编码任何过滤器”的先决条件是
理解ffmpeg命令行语法</p>
<p><strong>Tip2:</strong>通常,<code>ffmpeg.filter()</code>将筛选器名称作为第一个参数。然后是所有过滤条件。此函数用于将下游流返回到刚刚创建的过滤器节点</p>
<p>例如:在问题的ffmpeg命令行示例中。。。阅读它告诉我,您希望缩放视频,然后应用boxblur过滤器,然后进行裁剪</p>
<p>因此,您可以用<code>ffmpeg-python</code>术语将其表示为</p>
<pre><code># create a stream object, Note that any supplied kwargs are passed to ffmpeg verbatim
my_vid_stream = ffmpeg.input(input_file, "lavfi")
# The input() returns a stream object has what is called 'base_object' which represents the outgoing edge of an upstream node and can be used to create more downstream nodes. That is what we will do. This stream base_object has two properties, audio and video .. assign the video stream to a new variable, we will be creating filters to only video stream, as indicated by [0:v] in ffmpeg command line.
my_vid_stream = mystream.video
# ffmpeg.filter() takes the upstream node followed by the name of the filter, followed by the configuration of the filter
# first filter you wanted to apply is 'scale' filter. So...
my_vid_stream = ffmpeg.filter(my_vid_stream,"scale","ih*16/9:-1")
# next to the upstream node create a new filter which does the boxblur operation per your specs. so ..
my_vid_stream = ffmpeg.filter(my_vid_stream,"boxblur", "min(h\,w)/20:luma_power=1:chroma_radius=min(cw\,ch)/20:chroma_power=1[bg];[bg][0:v]overlay=(W-w)/2:(H-h)/2")
# finally apply the crop filter to it's upstream node and assign the output stream back to the same variable. so ...
my_vid_stream = ffmpeg.filter(my_vid_stream, "crop", h="iw*9/16")
# now generate the output node and write it to an output file.
my_vid_stream = ffmpeg.output(my_vid_stream,output_file)
## to see your pipeline in action. call the ffmpeg.run(my_vid_stream)
</code></pre>
<p>希望这有助于您或其他努力有效利用此库的人</p>