Sunday, June 24, 2007

The Rube Goldberg-ian WMA to MP3 Converter

Since we've started using our new home NAS to consolidate and backup our media, I've also undertaken the task to convert my fiance's previous WMA media collection she had accumulated since we started dating. Some of our media devices already supported WMA, such as our Blaupunkt car stereo, and Panasonic DVD player, but the newest, an Ipod 5th gen, obviously wouldn't (well not out of the box at least). Even in the car stereo, however, WMA files never fully worked; tags were never read. So even though MP3s are as much proprietary as WMAs, and WMA has many advantages of its own, MP3's ubiquitous support has won my heart and hard disks. I'd like to believe that keeping OGG media around and supporting its file format by buying a player that supports it will change matters, but the winds of time are behind MP3. Soon enough, patents will expire on MP3.

I initially thought the task would be much easier; surely Google will save me by returning results for "WMA to MP3". Simple inexpensive commercial app links were returned, and they all seemed capable of doing the job, but I felt "icky" knowing that there had to be a GPL/GNU solution to easily do what I needed (or at least a "free as in beer" solution). I had faith I could find success using GPL tools such as mplayer, mencoder, and lame. And I was partly right; I found several examples of mplayer usage with lame in thier own Rube Goldberg-ian *nix bash scripts. So I had hope at least I'd be able to simplify or adapt these to a Windows environment.

I started using an all mplayer solution; pipe mplayer to mplayer or mencoder and be done with it! Eh, not exactly. I could get mplayer to output wav files though... or... to stdout... which lame can read! Well, that would be an awesome one line commando transcode, but I could never get it to work on Windows. I did find a patch by Slingbox that gave better support for stdin in mplayer or lame (I forget which now) which lead me down the path of trying to compile my own solution, but that got to be too much work. Plus, i realized that there doesn't seem to be much support for tags. And that's the rub; I'm an ID3 tag and filename freak. If I didn't appreciate metadata so much, I would probably wouldn't be writing this post, but there's just something I enjoy about a good ID3 tag.

So what did I end up with? Actually a couple of reasonable solutions. Now Winamp isn't free as in speech, but I am quite familiar with it and it is free as in beer-ish. The paid for pro version could probably do all of what I needed quite easily, and support my ipod, but here comes the icky feeling again. The free version does have a couple of great features though. It does have a built in transcode, and it does support a recent out_lame plugin. The transcode feature doesn't let you transcode to mp3 without paying for Winamp Pro, but there is a rather elegant hack of installing the lame ACM codec to add support to Winamp WAV ripping to convert to mp3. But after a couple of passes, it would crash, and I could only seem to get ABR support, not the full VBR I desired.

However, the out_lame plugin is quite nice. It will let you take whatever Winamp will play back and convert it to mp3, all according to what tags and filename features you setup in Winamp.
Now that alone is not very Rube Goldberg-ian, and I still had to at least drag and drop both the WMA files and output files, so I developed a couple of .bat scripts that when used with another Winamp command-line add-on called CLEveR, would allow me to batch convert every wma it found, using whatever lame VBR settings, tags and filenames of my choosing.

Would Rube Goldberg even know what I was talking about by now?

No comments:

Post a Comment