Creating iTunes compatible COMM frames
patrick machielse
patrick at hieper.nl
Tue Dec 22 23:03:15 CET 2009
I just spent quite some time figuring out a way to get iTunes (9.0.2) to pick up the comments COMM frame in tags I created with TagLib (1.6.1).
It turns out that new comment frames by default do not have a language set, and TagLib writes out 'XXX' in place of the 3-character language code:
// commentsframe.cpp
ByteVector CommentsFrame::renderFields() const
{
//...
v.append(d->language.size() == 3 ? d->language : "XXX");
Q: why "XXX"? The ID3V2.4 spec says it should be an ISO 639-2 code. "XXX" isn't valid.
http://en.wikipedia.org/wiki/List_of_ISO_639-2_codes
iTunes doesn't like "XXX" as much as we all do and fails to parse the comment string. I find that specifying 'eng' as the language code will make the comments visible in iTunes. From my code:
// copy to id3v2 tag, create it if needed
ID3v2::Tag *id3Tag = destFile.ID3v2Tag(true);
Tag::duplicate(mp4Tag, id3Tag);
// Fix for iTunes: default TagLib lang is 'XXX' (?), but iTunes wants 'eng'
ID3v2::CommentsFrame *comm = (ID3v2::CommentsFrame *)id3Tag->frameListMap()["COMM"].front();
if ( comm ) {
comm->setLanguage("eng");
}
patrick
--
Patrick Machielse
Hieper Software
http://www.hieper.nl
info at hieper.nl
More information about the taglib-devel
mailing list