Python extract wav from video file

后端 未结 5 1427
执念已碎
执念已碎 2020-12-02 11:24

Related:

How to extract audio from a video file using python?

Extract audio from video as wav

How to rip the audio from a video?

My question

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-02 12:03

    It is a very easy Task using ffmpeg with python subprocess and there is a reason why people are pointing to this solution as a good solution.

    This is the basic command extracting audio from a given video File:

    ffmpeg -i test.mp4 -ab 160k -ac 2 -ar 44100 -vn audio.wav

    The Python Code is just wrapping this command:

    import subprocess
    
    command = "ffmpeg -i C:/test.mp4 -ab 160k -ac 2 -ar 44100 -vn audio.wav"
    
    subprocess.call(command, shell=True)
    

    You have to make sure that ffmpeg is a known task, so in your system environment variables, under path, the path to ffmpeg.exe should be listed, or you can just use the full path to the exe in your python code.

提交回复
热议问题