简体   繁体   English

如何使用 ffmpeg-python 在 filter_() 中使用高级选项?

[英]How to use advanced options in filter_() using ffmpeg-python?

I am using the ffmpeg-python wrapper.我正在使用ffmpeg-python包装器。

I'd like to mimic this ffmpeg command via this wrapper.我想通过这个包装器模仿这个 ffmpeg 命令。

ffmpeg -i multiaudio.avi -map 0:a:0 multiaudio_test_a01.wav

What this does, is to take the first audio track from the video and save it as separat audio file with the best quality possible.这样做的目的是从视频中获取第一个音轨并将其保存为具有最佳质量的单独音频文件。 More information to the advanced option "map": ffmpeg map documentation有关高级选项“地图”的更多信息: ffmpeg 地图文档

Now using the wrapper I tried something like:现在使用包装器我尝试了类似的东西:

    (ffmpeg
 .input(filepath)
 .filter_('map', map='0:a:0')
 .output(str(os.path.splitext(filepath)[0]) + "_test_a01.wav")
 .run()
 )

Now the important line, that keeps throwing errors is this one:现在重要的一行,不断抛出错误是这一行:

.filter_('map', map='0:a:0')

Could someone please tell me, how I need to rewrite this line of code to make it work?有人可以告诉我,我需要如何重写这行代码才能使其工作?

EDIT: Error Message编辑:错误信息

Error initializing complex filters. Invalid argument [...] raise Error('ffmpeg', out, err) ffmpeg._run.Error: ffmpeg error (see stderr output for detail)

Thank you.谢谢你。

As the ffmpeg paramameter "-map" is an advanced option and not a filter, the parameter needs to be specified for the output like so:由于 ffmpeg 参数“-map”是高级选项而不是过滤器,因此需要为输出指定参数,如下所示:

(ffmpeg
 .input(filepath)
 .output(str(os.path.splitext(filepath)[0]) + "_test_a01.wav", map="0:a:0")
 .run()
 )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM