This week I have been playing with youtube videos to either extract the sound from the video and converting to MP3 or converting the whole video to mpeg.

I’ve used the same kind of process to convert RealAudio streams to MP3. Firstly download the youtube video. I use the DownloadHelper addon for firefox. It’s really easy to use, you just search for your favourite video then click the button in the toolbar.

Once you’ve got your flv, you should be able to play that through totem/mplayer. If not, you’ll need install the correct gstreamer plugins. If you’re using Fedora, I’d suggest taking a look at MyGuide

OK, let’s say we want to rip the sound out of the file.. Really useful if you want a obsecure song that you can only find on youtube. It’s a two stage process, rip it as a wav then encode it to mp3.

mplayer Pork_and_Beans.flv -ao pcm:file=file.wav -vc dummy -vo null
lame -V Pork_and_Beans.mp3 file.wav --tt "Pork and Beans --ta "Weezer"
rm file.wav

That’s all there is to it!

OK next trick is to convert the flv to a Mpeg. This is slightly tricker and I haven’t had great results playing these on Windows (timing are all screwy)

mencoder Pork_and_Beans.flv -oac lavc -ovc lavc -lavcopts vcodec=msmpeg4v2:acodec=libmp3lame:abitrate=64 -o Pork_and_Beans.avi 2>/dev/null

The /dev/null is to drop the millions of warning messages you get about clipping.