Long time no post!
I recently updated to iTunes 8.2 on my Mac and discovered that more than 5000 of my MP3 files no longer had album artwork. Gone, missing, disappeared. Worse, some of the files no longer had album/artist/song information associated with them. Given that I’d been using iTunes – and its predecessor SoundJam – to maintain all this info, this came as somewhat of a surprise, but many of my MP3 files date from the late 90s so perhaps a bit of bitrot was to be expected. I should probably re-rip and re-encode my CDs too, but who has time for that?
FinderPop could see the embedded album artwork in these files, but neither iTunes 8.2 nor the 10.5.7 Finder could. Investigating, it seems that iTunes 8.2 wants the “image/jpeg” or “image/png” MIME description in the ID3 frame for said artwork. Likewise, while some of my MP3 files had ID3v2 album art, their album/artist/song info came from ancient and deprecated ID3v1 tags. So the info was there, but not in a format usable by the new iTunes.
Nothing for it but to write a once-off program to fix these problems! While I was there, I added an option to tag the album artwork as “FRONT_COVER”, which means that my Nokia N85 can finally display album artwork.
Rather than rolling-my-own ID3 I/O routines, I searched the web for ID3 tag libraries. I finally settled upon id3lib which it unfortunately turns out is old, orphaned, and buggy. Also it only handles ID3v2 2.3 tags, but that was fine by me. I discovered that id3lib screwed up writing Unicode titles etc, but a quick google pointed me at someone else’s fix for this, so I applied a patch to id3lib, then rebuilt and installed the shared library.
The attached quick-and-dirty source code (fixmp3s.cpp) grovels around inside MP3 files and cleans them up enough to work with my iTunes 8.2 setup and my N85. As the Americans say, Your Mileage May Vary. Always ensure that you have backups of your music – I am not responsible if this program eats your music!
Example usage:
find . -name \*.mp3 -type f -print0 | xargs -0 fixmp3s --cover=1 --update
Some of the options:
--dump textually dump the ID3 tags found in each file specified
--[no]v1tov2 [don't] convert ID3V1 tags to V2 if no V2 tags present
--[no]mime [don't] fixup album art MIME type
--[no]cover [don't] set album art type to 3 (FRONT COVER)
--[no]cover=N [don't] set Nth embedded image as FRONT_COVER
--[no]update [don't] write back changes
--warn-no-art scan file for album art and warn if none present
NOTE: no fixes will be applied until you specify --update
Build instructions on OS X and Unix:
Download id3lib, apply Unicode writing patch to id3lib, then configure, make and finally sudo make install for the library. Then build the attached fixmp3s.cpp file using:
c++ fixmp3s.cpp -O -Wall -Werror -lid3 -lz -o ./fixmp3s
Unfortunately I cannot build this statically for some reason, so I can't supply binaries... this is a source-code-only post. Use the Source, Luke!
Enjoy