简体   繁体   中英

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

I am using the ffmpeg-python wrapper.

I'd like to mimic this ffmpeg command via this wrapper.

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

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
 .input(filepath)
 .output(str(os.path.splitext(filepath)[0]) + "_test_a01.wav", map="0:a:0")
 .run()
 )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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