02-25-10 - Download MP3's from Youtube

Lately we're on a kick of listening to rare 70's hard rock and prog (which is fucking fantastic shit by the way). It's hard to find the recordings anywhere except Youtube, so I've gotten the need to turn the audio into MP3's.

So far as I know there is no good system to do this. (someone correct me if this is wrong). There are lots of service web sites that will do this for you, but they are slow and full of annoying adds and shit like that. The ideal thing would be a Firefox addon that just has a "save audio on this page as mp3".

(ADDENDUM : I guess there is one called "DownloadHelper", but they want money for the MP3 conversion feature. DownloadHelper does seem to be a little better than Unplug in that it has special code for Youtube that identifies the various format streams available so you can download the best one. Amusingly DownloadHelper seems to be very mainly targetted at porn site scraping; it has features like automatically finding new videos from certain sites and putting them in your queue for download. I guess it's the new era version of the automatic NNTP downloader I wrote in my youth. It looks like the FLV's generally have worse audio than the MP4's, so you should prefer them when possible perhaps.).

What I'm doing :

I use "Unplug" to download the .FLV video from Youtube. (* use DownloadHelper to download .MP4 video instead).

I use "MPlayer" to get the WAV audio out of the FLV. The way you do that is :

mplayer.exe -ni -vo null -vc dummy -ao pcm video.flv

Then I use the LAME command line build to encode the WAV to mp3. BTW there's a ton of bad old advice out there about LAME command line settings; I use this :

lame -h -V1 audiodump.wav r:\audiodump.mp3

but sometimes I wonder if I should use this :

lame -h -V1 --preset extreme audiodump.wav r:\audiodump.mp3

which actually makes smaller files usually because it enables some funny filters or something. Dunno.

Anyway, as a compression worker it bother me morally that I am decoding compressed audio from the FLV and recompressing it - I'd really like to just rip the audio stream directly from the FLV and be able to play that, but the fact is that my iPod and my car want MP3's, not AAC or whatever the fuck is in FLV, so it's pretty hopeless.

It's also annoying that I have to then enter the IDV tags by hand. I wish I could scrape the info right off Youtube. In theory you could use a CDDB auto-tagger on the MP3 to do it, but here are two problems with that : 1. I can't find a command line CDDB auto-tagger out there, there are several of them but they are all GUIs, and 2. even if you fire up the GUIs, CDDB seems to just spew fail all over itself.

ADDENDUM : if you don't need MP3's it is actually very easy to get the audio track directly to an M4A which can be played by iPods & most media players these days. Use mp4box ; I suspect there's a more direct command line that will work but this is the way that I've succeeded :

mp4box -new out.m4a -add gremlins.mp4#audio -ipod


Mojo said...


cbloom said...

Oh good lord. It's really incredible to me that unix people ever get that stuff to work.

By "that stuff" I mean scripts that invoke like a hundred other programs that all have to be the right versions installed in the right places; eg. that thing uses youtube-dl which requires python interpreter 2.x (x >= 4) , etc..

castano said...

Haha, as opposed to windows, installing and upgrading software on linux is a no-brainer.

John said...

Funny to hear you describe yourself as a 'Compression Worker'. Sometimes that's what my 'Sex Worker' does...

nothings said...

Yeah, Linux really is much more predictable for a development platform.

Like unix people think things like stb_image and stb_vorbis are crazy (ignoring the PD vs LGPL issue), because duh, you just link them no muss no fuss. Whereas in windows if you want to use libpng you're in for a world of messy installing and copying files around.

cbloom said...

Does Linux have some better way of handling library versioning ?

How about finding what all bits are needed to make something work and then where to get them from?

Granted I'm no Unix expert by a long shot, but every time I try to run some script like that I get some mysterious failure in the middle of it because some required bit wasn't installed.

Or I download some package and it's got this massive configure script and I have to have a hundred environment variables set correctly to make it work.

castano said...

Libraries in linux work pretty much the same way as in other unixes. What makes software installation easy on linux is the package management systems. If your script is packaged, the package contains information about all the dependencies and the package manager automatically downloads and installs them for you.

So, on debian you would simply write:

apt-get install youtube-dl

and you are all set.

Of course, if the software is not packaged, then you have to find and install the dependencies yourself, but it's not like you have to track the entire dependency chain, compile all the libraries yourself, etc.

Aaron said...

There are an ass-ton of prog stuffs on newsgroups. What's good?

old rants