Hello,
My LMS has been unable to display some of my mp3 library artworks with no apparent reason. I have searched this forum for a solution with no success. Rescanning my library didn't change anything and removing the artwork from the id3v2 tags wasn't a solution that I was willing to apply as I want to keep the artworks in my mp3 files for when I read them on my mobile.
So I tried to figure out what was wrong and I found out that there is a bug in LMS with the way it handles the artworks when the id3v2 tags are unsynchronized as required by the id3v2 specification. I quote the documentation of MP3::Tag which explains the purpose of id3v2 unsynchronization :
Quote:
by definition, MP3 files should contain
combinations of bytes "FF F*" or "FF E*" only at the start of
audio frames ("syncronization" points). ID3v2 standards take
this into account, and supports storing raw tag data in a
format which does not contain these combinations of bytes [via
"unsyncronization"].
Unsynchronization of an id3v2 tag consists on adding a 0x00 byte after every 0xff that is followed by a 0x00 or by a value between 0xe0 and 0xff.
LMS calls Audio::Scan::scan_tags in Slim::Utils::GDResizer::_read_tag in order to decode the tags contained in audio files. When an artwork is present in a tag, it gets the offset and size of this embedded artwork. It then directly reads this artwork from the audio file at the offset it got from this call. With an unsynchronized id3v2 tag the offset return by Audio::Scan::scan_tags is wrong and does not point to the beginning of the artwork. Thus LMS can't recognize the type of the artwork.
I have submitted a bug report on CPAN to the maintainers of Audio::Scan for this bug but, if corrected, LMS will still not be able to handle the artwork correctly because it would still have to undo the unsynchronization in order to get a usable artwork. The actual LMS code doesn't take this into account.
This bug seems to impact every LMS versions. I have first encountered with version 7.7.2 - before it seems that none of my mp3 files did contain unsynchronized tags - and I am currently using version 7.7.3. I have not upgraded to version 7.8.1 but I have checked its code and it seems this bug has not been corrected.
A workaround is to undo the id3v2 tag unsynchronization in the MP3 files in order to make them compatible with LMS. No need to rescan the lilbrary after this ; LMS is able to display the artworks as soon as the id3v2 tags are no more unsynchronized.
I have written a perl script in order to modify all the mp3 files having unsynchronized id3v2 tags in my library. I have attached it to this post as it may be useful to others. This script expects a list of mp3 files on its standard input (in order to be able to be used piped with a find command) and processes each file, undoing the unsynchronization when necessary. You'll need a functional perl installation with the MP3::Tag module installed (it can be found on CPAN). This script is given as is with no warranty, etc... Make a backup of your mp3 files before processing with this script, in case of a bug.
Stéphane