Reading mp3 metadata

Sunday 2 November 2003

For some time now, I've wished for a simple script that could make m3u files (play lists) from a directory tree of mp3 files (songs, of course). I figured it would be an easy enough thing to do, but it is not.

I looked into the ID3 2.4 spec, and it's not too bad reading the ID3 metadata from an mp3 file, but the data varies wildly depending on what ripping tool produced the mp3, and (surprisingly) what players have played the file. Windows Media Player likes to annotate the files when they are played.

There are a bunch of python implementations of ID3 tagging out there, but ID3 keeps changing and the ones I could find were for older versions. I hacked around with adding the latest stuff, but the disparity of actual tags in my files left me discouraged.

By the way: the ID3 spec describes itself as "an informal standard". I guess the author means that the standard has not been created under the stewardship of an official standards body. The document itself is the farthest thing from informal that I could imagine.

OK, so I could read the ID3 data from the file where it exists, but the m3u file also wants the length (in seconds) of the mp3 file. This information seems to be stored nowhere. I'm guessing most tools compute the length by examining the mp3 frames themselves. This theory is boosted by the fact that a few of them get the length wrong for variable bit rate files, presumably because they examine the first frame, then assume all other frames are the same rate (and that the file is almost all data frames).

At this point, I gave up. What's the fun in dealing with dirty data? Does anyone have a tool that does what I want? My mp3's are in directories by artist and album, and I'd love to have a .m3u file in each directory that listed all the mp3's beneath it.

Update: In January 2004 I finally got a complete solution together.

tagged: » 2 reactions

Comments

[gravatar]
Aaron 9:23 PM on 2 Nov 2003

I used to work for a company that did a lot of ID3 reading and writing. I believe we started out using LAME (http://lame.sourceforge.net/), but found that it was too unstable for server use, so we switched to the WIMP APIs (http://msdn.microsoft.com/library/en-us/wmplay/mmp_sdk/windowsmediaplayeractivexcontrol.asp) from Microsoft.

HTH

[gravatar]
sudhi 10:29 AM on 10 Nov 2003

creating m3u s easily..
dir elvis /b > elvis.m3u
dir doors /b > doors.m3u
...
works fine !
did i miss something ?

Add a comment:

name
email
Ignore this:
not displayed and no spam.
Leave this empty:
www
not searched.
 
Name and either email or www are required.
Don't put anything here:
Leave this empty:
URLs auto-link and some tags are allowed: <a><b><i><p><br><pre>.