How to get MP3 file from a WebM video

Read it in: CatalàCastellano

Another title for this post could be: "Getting audio from video clips". Because you could do it with MP4 (Mpeg4), WebM, Mov, FLV, etc. We are going to use ffmpeg to that:

ffmpeg -i input_file.webm -ab 128k -ar 44100 out_file.mp3

The meaning of the parameters:

  • ab: the audio bitrate in bps

  • ar: the audio sample rate in hz

And if you have a directory with a lot of files to convert you could use:

find . -name "*.webm" -print0 |while read -d

Pay attention to "find" and "while read" commands combinations because we want to support files with spaces.

I hope this is as useful for you as for me.

\0' file; do ffmpeg -i "$file" -ab 128k -ar 44100 -y "${file%.webm}.mp3";done

Pay attention to "find" and "while read" commands combinations because we want to support files with spaces.

I hope this is as useful for you as for me.

6 comments

Comments from the old blog, as they were written. Comments are closed.

  1. Bagus Aji Santoso

    Nice tutorial

  2. mauriciolazo

    Wow, incredibly simple, yet so powerful. Thank you very much! This is amazing.

  3. Christian

    When I copy and paste a command-line sample, a trailer is added: "- See more at: http://oriolrius.cat/blog/2013/09/20/converting-webm-files-to-mp3/". That's very inconvenient, can you turn that off somehow?

    1. Oriol Rius

      Solved, try now.

  4. Isla

    Incredible, man. Thanks a lot.

  5. Boris

    May you need a YouTube to MP3 converter, as like AnyMusic.