How to Extract MP3 Audio from a Video File

It's easy and free with ffmpeg and/or mplayer on Linux, BSD, or similar!


See the documentation for ffmpeg for far more details, but here are some simple examples.

Let's say you have some sort of video file. Maybe you used keepvid.com to save a video from YouTube and now you want to extact and save just the audio track as an MP3 file.

Let's assume that your movie file is moviefile.mpeg and your desired MP3 file is audiofile.mp3 — add the full or a relative path to the following commands as needed.

It's simple! Just do this:

$ ffmpeg -i moviefile.mpeg -f mp3 audiofile.mp3 

That's it!

You can specify the audio bitrate and the audio sampling rate if you want. Here is how you get relatively high quality 128 kbps audio (assuming the original video file had good audio!) sampled at the 44,100 sample/second rate used on a CD:

$ ffmpeg -i moviefile.mpeg -ab 128000 -ar 44100 -f mp3 audiofile.mp3 

What if the video file is some non-MPEG format, like Flash (ugh) or AVI or WMV? Then you will need the appropriate codec plugin for ffmpeg. With some Linux distributions you will need to look outside the distribution itself for the codecs, and maybe even for ffmpeg itself. The Penguin Liberation Front has some useful additions. Note that PLF provides source code in addition to binary RPMs.


Various Technical Topics

Radio topics — Ham radio, construction and repair, propagation, frequencies, etc


Home Page Unix/Linux TCP/IP Infosec Travel Radio Site Map Contact
Use /bin/vi! Manipulate images with ImageMagick! Hosted on OpenBSD
Hosted on Apache Valid XHTML 1.1! Valid CSS!
© Bob Cromwell Jan 2009. Created with /bin/vi and ImageMagick, hosted on OpenBSD with Apache.    Root password available here