Few days ago, I found a new song in youtube and I've been listening it since then. I like to have it in my mp3 player but I couldn't find it in mp3 format. First, I thought to google it for tools or add-ons to convert from youtube video to mp3 but then I realized that it is actually quite easy with the shell. The necessary processes are already in place in my Linux.
1. youtube-dl, is a small command-line program to download videos from YouTube.com and a few more sites.
2. ffmpeg, is a complete, cross-platform solution to record, convert and stream audio and video.
3. lame, is a high quality MPEG Audio Layer III (MP3) encoder licensed under the LGPL.
Here is the procedure;
First download the video with youtube-dl
$ youtube-dl "http://www.youtube.com/watch?v=QjA5faZF1A8"
then extract the audio from the video file with ffmpeg
$ ffmpeg -i QjA5faZF1A8.flv QjA5faZF1A8.wav
last, convert the wav file to mp3 with lame
$ lame QjA5faZF1A8.wav QjA5faZF1A8.mp3