Search code examples
pythonaudiowavwebm

Convert WEBM file to WAV file with Python


I want to convert webm files to wav files with Python to analyze. Is there any simple way to do the conversion from webm to wav in Python?

I looked through all questions here and on google. I know there are some possibilities, but i can't convert the files locally with ffmpeg or convert them with the API from cloudconverter website.


Solution

  • Yes! You can do this using ffmpeg without Python, but if you want to use Python install the package MoviePy. pip install it like so:

    pip install MoviePy
    

    Then you can use it in your program:

    import moviepy.editor as moviepy
    clip = moviepy.VideoFileClip("in_video.webm")
    clip.audio.write_audiofile("out_audio.wav")
    

    Note: with some versions of MoviePy, you might have to use clip.write_audiofile(...) instead of clip.audio.write_audiofile(...).