Grabbing MP3 via YouTube on #UbuntuLinux #avconv

Earlier this week, someone asked me, “How do you strip audio out of a youtube video?” The process was pretty straightforward (using ffmpeg) before but apparently, it’s changed with more recent versions of Ubuntu and/or distros based on Ubuntu (I’m using Linux Mint, which has turned out to be an absolute joy).

Here are the steps I followed:

1) Install necessary software if it’s not already there. I installed the following, although I’m not sure if it was “necessary:”

sudo apt-get install avconv ubuntu-restricted-extras youtube-dl

A quick overview of those:

  1. avconv – this program replaced ffmpeg and is the program we’ll use to strip audio out as MP3 format from an FLV
  2. ubuntu-restricted-extras – this adds some components that are usually needed. I believe I had these already installed in Linux Mint.
  3. youtube-dl – this will enable you to download/get a youtube video from (as opposed to using a service like )

2) Once software is installed, all you need is a YouTube video URL to begin download. For example, here’s the YouTube video I made Reaching for the Heart. The audio will put you to sleep quick, so download it!

At the command line (in Terminal), type the following (you can shift-insert to paste the youtube address/URL or right-click and paste with your mouse):


This will save–depending on your internet speed, etc.–a copy of the YouTube video on your computer as an FLV video file. In this case, it was saved with the awkward name of 00QTN_TFRtE.flv. You can rename it easily by typing:
mv 00QTN*.flv reach4heart.flv or choose to not rename it. It’s all up to you.

3) Extract the audio as MP3 from the FLV video file.

avconv -i reach4heart.flv -ab 192k reach4heart_audio.mp3

The resulting file looks like this:

-rw-r–r– 1 mg mg  15M May  8 19:24 reach4heart_audio.mp3
-rw-r–r– 1 mg mg  21M Mar 12 07:54 reach4heart.flv

You can get a smaller sized file than 15 megs by changing the bitrate:

avconv -i reach4heart.flv -ab 48k reach4heart_audio_small.mp3

and that will result in the following….

-rw-r–r– 1 mg mg 3.6M May  8 19:26 reach4heart_audio_small.mp3

I didn’t significantly notice the quality being diminished.

If you want to have multiple input files–or batch convert several files at once–then try this at the command line (copy-n-paste):

for i in *.flv; do avconv -i "$i" -vcodec copy -ac 2 -strict experimental "out-$i.mp3" ; done

4) Remove un-needed files, such as the FLV video files.

rm *.flv

Be aware that the command above will remove ALL FLV video files in the directory where you type it, so I like to do all my work in a folder setup for just that purpose.

Check out Miguel’s Workshop Materials online at

Everything posted on Miguel Guhlin’s blogs/wikis are his personal opinion and do not necessarily represent the views of his employer(s) or its clients. Read Full Disclosure

var _gaq = _gaq || []; _gaq.push([‘_setAccount’, ‘UA-3445626-5’]); _gaq.push([‘_setDomainName’, ‘’]); _gaq.push([‘_trackPageview’]); (function() { var ga = document.createElement(‘script’); ga.type = ‘text/javascript’; ga.async = true; ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl’ : ‘http://www’) + ‘’; var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(ga, s); })();

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: