Removing pictures from ID3v2 tag

Jeff Mitchell kde-dev at emailgoeshere.com
Sat Apr 7 22:03:35 CEST 2007


taglib doesn't lock files (I learned this the hard way)  :-)

There are reasons for this.  IIRC some of the reasons are that music files are 
often stored on network media where locks may not work or, worse, may appear 
to work but actually fail silently.  Some lock functions would have less 
problems than others but are not portable.

However, as a result, it's possible that taglib saves the file, then another 
app with the file open, or in memory, re-writes the file again.  There are 
ways of doing atomic, safe writes that involve a bit more coding on the end 
user's part (needing access to a hashing or CRC library, too).

Anyways, that's just a little info in case it helps someone out.  Probably not 
relevant to solving this problem  :-)

--Jeff

On Thursday 05 April 2007, Vitali Lovich wrote:
> Are you sure that save is returning true?  It could be that if you still
> have a file handle open to the file in another application, then the
> code may fail to save the file depending on what kind of lock TagLib and
> the other app request.
>
> Stefan Vunckx wrote:
> > Hello,
> >
> > I seem to have some trouble removing pictures from an mp3's ID3v2 tag
> > using TagLib.
> >
> > This is my code:
> >
> > TagLib::MPEG::File file( ... );
> > if ( file.ID3v2Tag() ) {
> > TagLib::ID3v2::FrameList l= file.ID3v2Tag()->frameListMap()["APIC"];
> > for( std::list<TagLib::ID3v2::Frame*>::iterator iter = l.begin(); iter !=
> > l.end(); iter++ ) {
> >   TagLib::ID3v2::AttachedPictureFrame *frame =
> > static_cast<TagLib::ID3v2::AttachedPictureFrame *>( *iter );
> >   file.ID3v2Tag()->removeFrame( frame, TRUE );
> > }
> > file.save();
> > }
> >
> > Is what I'm doing so wrong ? Ive tested this in my Qt application, using
> > mp3s who have 1 or more pictures attached, and although there are no
> > error messages, the images do not get removed either. If I reload the
> > tags, the images re-appear.
> >
> > If someone can point me to what it is I am missing, I would be grateful !
> > ;-) Please CC me as I am not on the taglib-devel list.
> >
> > Regards,
> > Stefan Vunckx
> > _______________________________________________
> > taglib-devel mailing list
> > taglib-devel at kde.org
> > https://mail.kde.org/mailman/listinfo/taglib-devel
>
> _______________________________________________
> taglib-devel mailing list
> taglib-devel at kde.org
> https://mail.kde.org/mailman/listinfo/taglib-devel




More information about the taglib-devel mailing list