flac2mp3.py

I have a medium-sized CD collection (around 500 or so albums), but like most geeks I never actually fetch the disks and put them in my CD/DVD player anymore. Instead, I rip them to some digital format and listen to them on my computer, my portable MP3 player, or my showcenter. I’ve been listening to music this way ever since I first discovered CD Copy back in -97 or so, and ripped my entire collection.

Back then, disk space was expensive and MP3 encoders were less stellar than they are now, and so after a couple of years my collection of 128 Kbit/s rips started to sound bad compared to what was practical in 2000. Another round of ripping, this time to 192 Kbit/s, which was fine for a while, until I got a portable MP3 player that didn’t have a lot of storage (256 MB), but a nice WMA encoder. WMA in a portable player sound perfectly OK at 64-80 Kbit/s, but not if you convert from a MP3 (because of the lossy nature of both MP3 and WMA, a MP3->WMA conversion will be lossy2).

So, if I was to re-rip my 500 CD’s for the third time, I wanted to do it right. I could rip them to plain WAV files, and then write small scripts that would convert them to my preferred format for portable devices, but WAV has two problems: Firstly, the files get huge, and secondly, it has no good standard for metadata (like song, artist, album etc).

Enter FLAC. Open source implementation, lossless decent compression and excellent metadata capabilities. So, when I’m re-ripping now I use EAC with the configuration given at this page (scroll down a bit for the FLAC configuration), and hopefully I should never have to do it again after this.

So, now I have a tree full of albums in FLAC format. To make things extra pretty, I’ve even used Album Cover Art Downloader to create those folder.jpg files that gets used by Windows XP’s Thumbnail view. Only one problem, though — neither my Showcenter nor my portable player can play FLAC. I neeede a way of batch converting my FLAC collection to MP3 and/or WMA.

Well, I haven’t solved it for WMA yet, but with this script you can convert such a tree to MP3 files, as long as you have python, lame and the command-line FLAC encoder. It’s written for windows, but should run under any Unix variant without too much trouble, I hope. It is written with the assumption that your folder structure is only one level deep, ie directories should be named “Johnny Cash - At Folsom Prison”, not with subdirectories like “Johnny Cash/At Folsom Prison”. Since I rarely have more than three albums with any one artist, I find the “Artist/Album” convention mostly annoying.

Configure the upper-case variables, start a command prompt, cd’ to the root of your FLAC tree, run the script and then be patient (for me, the conversion takes well over 24 hours, and I have a relatively zippy computer).

No license, do whatever you feel like with it (but do let me know if you find it useful!)

Tags:

3 Responses to “flac2mp3.py”

  1. Staffan Malmgrens blogg » Blog Archive » Webtjänst önskas Says:

    […] För några dar sedan upptäckte jag att cdon.com hade rea: Isis “Panopticon” för 99, Skambankt “Skambankt” för 79, och Leonard Cohen “Dear Heather” för löjligt billiga 49 spänn. Eftersom jag fortfarande köper skivor då och då - inte minst för att jag då kan rippa låtarna så att det blir Rätt - var det välkommet, då skivorna legat på min vill-ha-lista ett tag nu. […]

  2. Gustaf Erikson Says:

    This sounds like just what I need! However, the link to the script is 404..

  3. staffan Says:

    Oops! Link to script now fixed, thanks for pointing it out.

Leave a Reply