用taglib提取mp3文件中的图片和一些其它信息的实例

本文提供了一个使用TagLib库从MP3文件中提取ID3v2标签,包括图片和其他信息的实例。通过TagLib的API,可以访问并处理ID3v2帧,特别是获取和写入附加图片。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

//taglib可以从网上下载,解压包文件中,test and examples 里面有些很好的学习例子,taglib也有API ,可以参考
//reference size:http://sql.codeproject.com/KB/cs/Do_Anything_With_ID3.aspx?display=Print

//

#include <iostream>
#include <stdlib.h>

#include <taglib/tbytevector.h>
#include <taglib/tfile.h>

#include <taglib/mpegfile.h>

#include <taglib/id3v2tag.h>
#include <taglib/id3v2frame.h>
#include <taglib/id3v2header.h>

#include <taglib/id3v1tag.h>

#include <taglib/apetag.h>

#include <taglib/tag.h>
#include <taglib/attachedpictureframe.h>

#include <QDebug>
#include <QImage>

#include <taglib/fileref.h>

using namespace std;
using namespace TagLib;

int main(int argc, char *argv[])
{
  // process the command line args


  for(int i = 1; i < argc; i++) {

    cout << "******************** /"" << argv[i] << "/"********************" << endl;

    MPEG::File f(argv[i]);

    ID3v2::Tag *id3v2tag = f.ID3v2Tag();

    if(id3v2tag) {

      cout << "ID3v2."
           << id3v2tag->header()->majorVersion()
           << "."
           << id3v2tag->header()->revisionNumber()
           << ", "
           << id3v2tag->header()->tagSize()
           << " bytes in tag"
           << endl;

      ID3v2::FrameList::ConstIterator it = id3v2tag->frameList().begin();
      for(; it != id3v2tag->frameList().end(); it++)
        {
            cout << (*it)->frameID() << " - /"" << (*it)->toString() <<"/t it.size()="<<(*it)->size()<< "/"" << endl;
        if (    (*it)->frameID().operator==(ByteVector("APIC")) )
                {
     
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值