Answer the question
In order to leave comments, you need to log in
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);
}
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;
}
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;
}
const TagLib::List<TagLib::FLAC::Picture*> picList = file->pictureList();
picList is always empty and ID3v2 is missing. Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question