How To Snarf Songs from Youtube with ffmpeg

Ingredients:

  • a YouTube video that you want to steal the music from for your collection. For example, the MC Rove rap. Who doesn’t want to listen to that again and again? Not to be missed!
  • a means of downloading the video, for example DownloadHelper for Firefox, or one of the zillion online youtube video downloaders.
  • ffmpeg, an open source video manipulation program. I checked mine out from Subversion and compiled my own, but there may be easier ways to get ahold of it.
  • a command line to run ffmpeg on. This ain’t no gui, baby. Sorry.

Anyway — download the flv file.

See what you’ve got, like this:

ffmpeg -i Rapping_Rove.flv

You’ll get back a bunch of stuff, hopefully including something like this:

Input #0, flv, from ‘Rapping_Rove.flv’:
Duration: 00:01:55.7, start: 0.000000, bitrate: 64 kb/s
Stream #0.0: Video: flv, yuv420p, 320×240, 29.97 fps(r)
Stream #0.1: Audio: mp3, 22050 Hz, mono, 64 kb/s

Hey, there’s an mp3 in there, trying to get out! Score! Let’s help it. Here’s the magic command:

ffmpeg -i Rapping_Rove.flv -vn -acodec copy Rapping_Rove.mp3

And now you’ve got the file Rapping_Rove.mp3, ready to slurp into iTunes and put on infinite loop. It’s that easy!

Thanks to this posting on some mailing list which helped me figure out the magic command in the absence of comprehensible documentation for ffmpeg. :)

If all this is a little too much, the vixy.net guys have an interface to do it for you on the web. I am not sure however whether it actually extracts the mp3 out of the flv itself, or else pulls the audio out of the flv and re-encodes it as an mp3, possibly losing precious sound quality! But it’s probably a better bet than this ffmpeg voodoo for 99% of people.

2 thoughts on “How To Snarf Songs from Youtube with ffmpeg”

  1. Mmmm. My own copy of “Vampires are Alive” by DJ Bobo. He’s the king of Dance, you know. 12 points.

    I have to wash myself in acid now.

Comments are closed.