Extracing the second audio track of a video file using Python

Viewed 152

Hello Stackoverflow Community,

I recently started to use the python library moviePy, which seems to solve a lot of problems in quite an elegant fashion. However, I am looking for a way to access the second audio track of a video file, so I can save it as separate .wav file.

Code example:

from moviepy.editor import *
def foo():
  videosrc = VideoFileClip("\Volumes\testfile.avi")

  audiostrip = videosrc.audio
  audiostrip.write_audiofile(filename= '\Volumes\test.wav',
                           fps = 48000,
                           codec= "pcm_s24le",
                           bitrate= "96k",
                           buffersize=6000,
                           write_logfile= True,
                           ffmpeg_params= [
                              "-map_metadata", "-1",
                              "-metadata", "creation_time=now"])

  audiostrip.close()
  videosrc.close()

This will perfectly fine extract the first audio track of the video file. Now I am wondering how to extract the second audio track.

With ffmpeg you would do something like add this flag: -map "0:a:1"

Perhaps someone could help me out here,

Thank you

0 Answers
Related