17Oct2010

How to Download and Convert a YouTube Video to MP3 (2010 Edition)

There's an awesome YouTube user called DJDiscocat. I don't know who he/she is but he uploads videos each day that are recordings of his vast disco and soul vinyl collection. Given my interest in these genres, I often want to get the songs as MP3s.

Till now I've been using the Download YouTube Videos as MP4 GreaseMonkey/GreaseKit script and converting the 4k videos into MP3s using Quicktime 7. A bit of a pain in the ass though. But now I've discovered a much easier way trough proxy server.

Prerequisites

My instructions are based entirely on OS X but I believe they'd work similarly for Linux. You need to have FFmpeg and youtube-dl installed.

I'm not going to get into the details of how to do this but for FFmpeg on OS X, I just ran sudo port install ffmpeg and it went fine (I have MacPorts installed). I tried Homebrew initially but the build failed. And youtube-dl is just a Python script you can download, do a chmod +x on and move to /usr/bin/youtube-dl or similar.

The actual process

Step 1 - Find your video. Find a video you want to download and grab the basic URL for it. For example: http://www.youtube.com/watch?v=BVgM7qeAlko

Step 2 - Download that video. Once youtube-dl is running, it's as simple as:

youtube-dl --title "http://www.youtube.com/watch?v=BVgM7qeAlko"

Naturally you'd replace the URL with that of the video you want.

Step 3 - Convert that video into an MP3. Now you'll have a .flv file sitting around with the video in it. Time to use ffmpeg to convert it to a usable MP3. Simply:

ffmpeg -i flv_filename.flv -ac 2 -ab 160 output.mp3

And, as we say, Bob's your uncle.

Comments are closed.