Mp3ize

I recently won a black 30GB video iPod for second place in Georgia Tech’s campus iMovie fest. It’s really sexy. I can understand now why all the Apple fanboys are drooling all over themselves. It has a slick interface, sounds much better than my little 512MB rio, and it works as removable storage.

After I got it I brought it to my office, unpacked it, and hooked it up to my system. Amarok and SuSE found it, initialized it, and it was automagically ready to transfer music/files/videos. No annoying restarts because of driver installs, or waiting on the OS to find my device. Were I on Windows I would have to go through the pain of downloading and installing[sic] iTunes, waiting for Windows to figure out that something new has been connected, wait for the driver installs, and then begin transfers.

Something most unfortunate for consumers is the restriction of file formats for certain branded mobile audo devices. I am not about to convert my entire 6000+ song archive from .wma to .aac. First off, aac is DRM, and second off, they all sound nearly the same.

Depressing? Fret not ye who ripped all your cd’s to wma. Linux to the rescue.

I wrote two small shell scripts that search a directory structure for wma’s and convert them to 250kbps VBR LAME encoded mp3. I won’t go into the details of CBR vs. VBR, but trust me when I say it’s better. Also, word is from Lorenzo the compression expert that conversion from high bit rate wmas to VBR mp3s should not result in too much signal degradation. W00t.

mp3ize

#!/bin/bash
 
# look for wma's and run convert on them
find . -name "*wma" -exec convert {} ;

convert

#!/bin/bash
 
set -e
old_name="$1"
cat_name=`basename "$1"`
path=`dirname "$1"`
nospaces=`echo $cat_name | sed -e 's/  */_/g' -e 's/_-_/-/g'`
new_name="${path}/${nospaces}"
 
#echo ---------
echo $old_name
#echo $path
#echo $cat_name
echo $new_name
 
if [ "${path}/${old_name}" != "$new_name" ];
then
   mv "$old_name" "$new_name"
fi
 
mplayer -ao pcm:file="${new_name%.wma}.wav" "$new_name"
lame -V 0 --vbr-new "${new_name%.wma}.wav" "${old_name%.wma}.mp3"
rm -f "${new_name%.wma}.wav"
 
mv "${new_name}" ~/.Trash/

Copy the source into two files named mp3ize and convert respectively, and toss them in your usr/bin/ directory. Then cd into the top directory where the files you wish to convert live, and type mp3ize. Watch for commas in path names because it will cause the script to skip those files or misname them. It will often cut off everything after the comma. This is a limitation of bash scripting, so we will have to live with it.

One thing that I would like everyone to note is my CPU usage graph:

System resource graph

Notice that it’s pretty much pegged at around 100%. As of right now I am typing this blog, running eclipse, seeding a DVD on bittorrent, and running around 9 other terminal tasks all while the mp3ize script is running. When’s the last time you could actually use your Windows system when CPU usage was near 100%? Never. Ever. It should also be noted that I do not have a dual core CPU.

2 Comments »

  1. Dave said,

    March 10, 2007 @ 2:31 am

    I had both threads of mine pegged out at 100% and using 700mb of ram, and could still function well. Still a couple annoying things, but for the most part I’m a happy Linux user now.

  2. Dave said,

    March 10, 2007 @ 2:35 am

    An addendum to the last one:

    Read this article: http://www.theregister.co.uk/2003/10/06/linux_vs_windows_viruses/

    A really good article telling what Windows biggest problems are. It’s a few years old, but it still pretty much applies.

RSS feed for comments on this post

Leave a Comment