Extract Audio (.mp3) from Video Files Like .flv, .mov, .avi and Others with Ubuntu
It is very easy to extract the audio track from video files using Linux. All you need is ffmpeg and some codecs.
Let’s get started…
Note: The commands below are for Ubuntu (or Debian derivatives) but you can do the same with any other Linux distribution provided you can install the necessary packages.
1. Add the Medibuntu’s repository to your sources.list:
sudo wget --output-document=/etc/apt/sources.list.d/medibuntu.list http://www.medibuntu.org/sources.list.d/$(lsb_release -cs).list && sudo apt-get --quiet update && sudo apt-get --yes --quiet --allow-unauthenticated install medibuntu-keyring && sudo apt-get --quiet update
2. Install ffmpeg:
sudo apt-get install ffmpeg
3. Let’s get the restricted packages and some codecs installed:
sudo apt-get install ubuntu-restricted-extras libmp3lame0 libdvdcss2 w32codecs
The above command is for i386 architecture. If you have an amd64 architecture, substitute w32codecs with w64codecs.
Note: This is not a complete list of codec packages by any stretch of the imagination. It will get you started though and you will be able to do most formats, but you might have to add codecs as you go along.
4. Now we are ready to extract the audio from the video files:
ffmpeg -i input_file.flv output_file.mp3
The above command will extract the audio from a Flash video file. You can do the same for a QuickTime file as well:
ffmpeg -i input_file.mov output_file.mp3
Or for an Audio Video Interface file:
ffmpeg -i input_file.avi output_file.mp3
YouTube and other video web sites:
Having done all this, now we can download flash files from places like YouTube and strip the audio from them. All you need besides the steps above is a way to save the Flash files (.flv) from YouTube. An easy way to do that is by using Firefox Add-ons like Download Flash and Video or Flash Video Downloader.
The quality of the audio in the YouTube videos for example is 64 bit/sec. Most of the mp3 files are normally compressed to 128 bit/sec or above. Obviously the quality will not be the same, but a human year cannot tell the difference.
The quality of the extracted mp3 will depend on the quality of the audio track in the video file. So the above statement about the 64 bit/sec audio is mostly the case for the files on some video sharing sites.
8 Comments to Extract Audio (.mp3) from Video Files Like .flv, .mov, .avi and Others with Ubuntu
Leave a comment
Search
Archive
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « Nov | ||||||
| 1 | 2 | 3 | 4 | 5 | ||
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | ||||
Recent Comments
- wesley on How to sign an unsigned Android package (.apk file)
- dimitar on Android – Displaying Dialogs From Background Threads
- Salmpy on Android – Displaying Dialogs From Background Threads
- Mark Quinn on How to connect your Android phone to Ubuntu to do development, testing, installations or tethering
- Mark Quinn on How to connect your Android phone to Ubuntu to do development, testing, installations or tethering
Categories
Blogroll
Online Tools
Other
BLOG ARCHIVE
- November 2011 (1)
- August 2011 (1)
- April 2011 (1)
- January 2011 (2)
- September 2010 (1)
- August 2010 (2)
- July 2010 (2)
- June 2010 (2)
- May 2010 (1)
- January 2010 (2)
- December 2009 (2)
- November 2009 (3)
- October 2009 (1)
- September 2009 (3)
- July 2009 (1)
- May 2009 (1)
- March 2009 (1)
- February 2009 (2)
- January 2009 (2)
- December 2008 (1)
- November 2008 (4)
- October 2008 (5)
Simple and clear instructions — that work. Many thanks.
I second that ^. It worked for flac so now I have lossless.
When will the Linux-world understand at last average computer users DON’T WANT THE COMMAND LINE CAUSE IT’S MEDIEVAL?
When you want to extract audio from videofiles in Linux just use WINFF.
That’s an excellent GRAPHICAL frontend for FFMPEG. WINFF is also available for Windows. Just import the videofile in WINFF. Select Convert to Audio, select the audioformat of your choice, fill in the desired bitrate (ie for mp3 128 kbps) and there it goes.
WINFF is in the repositories of several major Linux distributions like Ubuntu and OpenSUSE. See also: http://winff.org/html_new/
Hi,
You can use an Any File to Audio Converter to convert video to mp3.
I installed winff out of curiosity. It’s great but 1) I wouldn’t even have understood how to extract the audio without Willem’s advice, so it’s not better than the command line; 2) typing ffmpeg -i input_file.avi output_file.mp3 on the command line is so much faster that I don’t care looking medieval. This is one of those cases when I feel sorry for Windows users that have to waste so much time with the file open dialog and all the other GUI controls.
I’m using audacity and openshot for my other video production steps, so I’m not always medieval. I just like to be efficient.
Especially when you can use the full power of the CLI and do this:
#> for i in *.flv ; do ffmpeg -i ${i} ${i:s/flv/wav/” ; done
And do them all at once. Change *.flv to *.mp4 or what have you. Change ${i:s/flv/wav} to ${i:s/flv/mp3} or ${i:s/flv/ogg} or what you want.
This little command line loop will list each file that matches *.flv, feed it into whatever command follows the ‘do’ and it’s position in the command is wherever you put the ${i}. The added ‘s/flv/wav/’ means to search ‘s’ for flv and replace with wav. This substitution occurs *before* ffmpeg actually is run.
Eazy squeezy.
Opps — forgot the closing }. That command line is:
#> for i in *.flv ; do ffmpeg -i ${i} ${i:s/flv/wav/} ; done
interesting little cross flame upthread – the command line can be seen as medieval, or it can be seen as matrix-chic. Very much a matter of taste that one, regardless of what you can or cannot do with it. As for feeling sorry for windows users, it is possible to use a cli in windows i believe.
Anyway nice command reference. As for compression issues with flash videos, I assume it is reasonable to replace the output format with flac (for instance)?