stripping tags from FLAC

Новичков А.А. novichko at atnet.ru
Sat Mar 13 19:28:27 CET 2010


Hi, I have a question. Is there any possibility to quickly strip all
tags from FLAC files (and from ogg, oga, spx, wma, m4a as well) as it
was done for MPEG? I use the following code:

TagLib::FLAC::File *f=new TagLib::FLAC::File(FILE_NAME(file));
        {TagLib::Ogg::XiphComment *tag=f->xiphComment(false);
        if (tag) {
            TagLib::Ogg::FieldListMap map=tag->fieldListMap();
            TagLib::StringList list;
            for (TagLib::Ogg::FieldListMap::ConstIterator it =
map.begin(); it != map.end(); ++it)
                list.append((*it).first);
            for (TagLib::StringList::ConstIterator it=list.begin(); it!
=list.end(); ++it)
                tag->removeField((*it));
        } }
        {TagLib::ID3v1::Tag *tag=f->ID3v1Tag(false);
         if (tag) {
            tag->setAlbum("");
            tag->setArtist("");
            tag->setComment("");
            tag->setGenre("");
            tag->setTitle("");
            tag->setTrack(0);
            tag->setYear(0);
        } }
       {TagLib::ID3v2::Tag *tag=f->ID3v2Tag(false);
        if (tag) {
            tag->setAlbum("");
            tag->setArtist("");
            tag->setComment("");
            tag->setGenre("");
            tag->setTitle("");
            tag->setTrack(0);
            tag->setYear(0);
            TagLib::ID3v2::FrameListMap map =tag->frameListMap();
            TagLib::List<TagLib::ByteVector> list;
            for (TagLib::ID3v2::FrameListMap::ConstIterator it =
map.begin(); it != map.end(); ++it)
                list.append((*it).first);
            for (TagLib::List<TagLib::ByteVector>::ConstIterator
it=list.begin(); it!=list.end(); ++it)
                tag->removeFrames((*it));
        } }
        f->save();
        delete f;

But it is inconvenient and I don't sure whether all tags are really
stripped.

Thanks,
Alex.



More information about the taglib-devel mailing list