Where music is going

I'm going to make a bold prediction here, hold on to your hats! I'm going to predict that the next music player I buy will have more storage than the one I have now. I'd bet even the one after that will have more than that one!

While that prediction isn't groundbreaking, thinking about it lead me down an interesting path. I, like probably a lot of people, got onto the bandwagon of ripping my CDs to MP3s pretty early. It was exciting to have my whole collection of music on my hard drive (portable players were pretty rare back then) and compared to my computer speakers the quality was amazing! After doing that, I was then at the point of realizing that I needed to do it again. Things like reliable tagging made it so most of the files weren't useless, but I would get better results by just starting from scratch. So I did.

I then realized that I never want to do this again so I needed to rip all my music into a lossless format, but no player could hold all that data, at least not yet. In turn that forced me to realize that over time storage will probably grow faster than the amount of music I'm interested in, but the variable I can adjust is quality. So I can build a bunch of 96 kbps MP3s for my phone and keep 256 kbps OGGs for my laptop. And, eventually, everyone will just have those flac files I originally ripped. Whew, now getting from A to B.

I decided that I needed to make a Makefile for a few different reasons:

  • Make handles the idea of transformations pretty easily, so the idea of a transformation between flac and another format would be simple to express.
  • Make already tracks which jobs are complete by looking at the file times and which files are created. This would make it easy to rip new CDs as only the new files would be re-encoded.
  • Make can parallelize the whole thing for me to work on my dual-core processor. nice make -j 2
  • If I quit half way make will delete the half built files and allow me to pick up where I left off.
The one problem that I had using Make is that it doesn't easily handle file names with spaces in them. This was easy enough to change:
$ find . -name "*.flac" -exec rename "y/ /_/" {} \;
Which is a small one line operation to find all the files ending in .flac and replace all the spaces in their name with underscores.

Here is the Makefile and the small shell script that I'm using to do the conversion (mostly stolen from a forum thread I can't find now). Everything is grossly hardc oded, but it works great for my situation. My situation includes putting both of these in the Flac folder and wanting to put all the MP3s into the ../mp3 folder. Currently it only builds MP3s at 96 kbps. Good luck, hopefully my collection will be encoded in a couple of days.

posted on Tue, 30 Dec 2008 at 21:29 | permanent link | 4 Comments

Posted by Martijn at Wed Dec 31 01:26:21 2008
You know that Banshee and Rhythmbox automatically transcode flac into ogg or mp3 (based on what the device advertises), right? :)

Posted by Timo Aaltonen at Wed Dec 31 02:20:20 2008
I've used flac2mp3 to convert my collection to mp3. The neat thing about it is that if the tags on flacs are updated, it'll only update the tags instead of re-encoding the files.

You can find it here:

http://projects.robinbowes.com/flac2mp3/trac

It doesn't currently handle ogg's though, but it shouldn't be too hard to add. Also, the encoding options need to be hardcoded in the script which is unfortunate..

Posted by Pádraig Brady at Wed Dec 31 05:09:07 2008
The above find command is inefficient as it starts a process per file. If the filenames are taken on the end of the command, as is the case for rename, you can just do:

find ... -print0 | xargs -r0 rename ...

You could also use the POSIX compliant find variation of replacing the \; above with +, which also efficiently appends multiple arguments to each command.

Posted by Michaël Ball at Wed Dec 31 09:41:39 2008
Nice work. I'd been looking to do something like this for a while, but never thought of using make.

I've tried your script (edited a little to output to oggs instead of mp3s), but unfornately it seems to be trying to create "../mp3/)" as a directory. I'm going to have a further play around to see if I can fix it.

As an aside: there's a way you can escape the spaces in the filenames for the flac files:

find . -name "*.flac" | sed 's/\( \)/\\\1/g'

Name:


OpenID:


Comment: