D
D
Door2012-10-15 16:09:32
C++ / C#
Door, 2012-10-15 16:09:32

taglib. Flac file cover?

You need to get the cover from the audio file. I use Taglib (version 1.8). Problems arise with flac .
As far as I understand, the best option to extract cover is this:

founded = extractFlac(file);

        if(!founded)
        {
            TagLib::ID3v2::Tag* tag = file->ID3v2Tag();
            if(tag)
                founded  = extractId3(tag);
        }

extractFlac
bool extractFlac(TagLib::FLAC::File* file)
{
    const TagLib::List<TagLib::FLAC::Picture*> picList = file->pictureList();
    if(!picList.isEmpty())
    {
        // Let's grab the first image
        TagLib::FLAC::Picture* pic = picList[0];
        return saveData(pic->data());
    }

    return false;
}

extractId3
bool extractId3(TagLib::ID3v2::Tag* tag)
{
    const TagLib::ID3v2::FrameList& frameList = tag->frameList("APIC");
    if(!frameList.isEmpty())
    {
        // Grab the first image
        TagLib::ID3v2::AttachedPictureFrame* frame =
            static_cast<TagLib::ID3v2::AttachedPictureFrame*>(frameList.front());
        return saveData(frame->picture());
    }

    return false;
}

The problem is that
const TagLib::List<TagLib::FLAC::Picture*> picList = file->pictureList();
picList is always empty and ID3v2 is missing.
I looked in the bug tracker of the project - it seems like there is no such bug (Windows 7, 32-bit)
or, if this is not a bug, tell me how to correctly extract cover.
Thanks in advance

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question