A few questions...

Jeff Mitchell kde-dev at emailgoeshere.com
Tue Jul 11 14:42:44 CEST 2006

> I suspect this is an amaroK bug.  By default both ID3v1 and ID3v2 are
> written.
> > a) Will writing an ID3v1 tag remove the ID3v2.4 tag, like it does the
> > other way around?
> > b) If we do this, is there a way to have it automatically copy over
> > values from the ID3v2.4 tag, like it does when you create the ID3v2.4
> > tag (realizing that truncation, etc., may take place)?
> See above.   The default is to write both and there is an API
> function (in TagLib::Tag) to copy over values.  This is  done by
> default unless you are explicitly writing the tags separately.
> -Scott


I found the location in my code.  I'm calling TagLib::MPEG::File::save with 
TagLib::MPEG::File::ID3v2 as an argument, and didn't catch in the 
documentation where it says it strips tags not in the mask.  I've changed it 
to TagLib::MPEG::File::AllTags.  Thanks for the pointer.

One other issue I have:

When reading the ID in the UFID frame, I have come across a situation where 
I'll save a uniqueid from an 8-character QString, but the value returned when 
I try to read it back is 9 characters.

When saving the frame, I use the following:
file->ID3v2Tag()->addFrame( new TagLib::ID3v2::UniqueFileIdentifierFrame(
                        QStringToTString( ourId ),
                        TagLib::ByteVector( m_uniqueId.ascii(), randSize )
                        ) );

where ourId is Amarok's identifier, and m_uniqueId is a QString consisting of 
randSize characters.

However, when I read it back:

m_uniqueId = TStringToQString( TagLib::String( ourMP3UidFrame( file, 
ourId )->identifier().data() ) );

where ourMP3UidFrame is the following:

TagLib::ID3v2::UniqueFileIdentifierFrame *
MetaBundle::ourMP3UidFrame( TagLib::MPEG::File *file, QString ourId )
    TagLib::ID3v2::FrameList ufidlist = file->ID3v2Tag()->frameListMap()
    TagLib::ID3v2::UniqueFileIdentifierFrame* currFrame;
    for( TagLib::ID3v2::FrameList::Iterator iter = ufidlist.begin(); iter != 
ufidlist.end(); iter++ )
        currFrame = 
        if( TStringToQString( currFrame->owner() ) == ourId )
            return currFrame;
    return 0;

When this is run, m_uniqueId is equal to the uniqueId that was saved into the 
tag, plus one extra character, which shows up in my debug as ? (I could try 
to get the hex code for you if you want).  To solve this I've had to add 
a .left( randSize ) onto the returned string:

m_uniqueId = TStringToQString( TagLib::String( ourMP3UidFrame( file, 
ourId )->identifier().data() ) ).left( randSize );

Any idea what's going on?  It works perfectly fine with the .left, but it 
feels hacky.


More information about the taglib-devel mailing list