]>
diplodocus.org Git - flac-archive/blob - apic-read.cc
0438a026d73e927a08d2756770e74d0203bbef26
8 #include <attachedpictureframe.h>
12 // some demo apic reading code; would be nice to save all APIC frames.
15 main(int argc
, char **argv
)
17 const char *mp3_path
= argv
[1];
18 TagLib::MPEG::File
f(mp3_path
);
19 TagLib::ID3v2::Tag
*id3v2tag
= f
.ID3v2Tag();
23 TagLib::ID3v2::FrameList::ConstIterator it
;
24 for (it
= id3v2tag
->frameList().begin();
25 it
!= id3v2tag
->frameList().end();
27 TagLib::ByteVector frameid
= (*it
)->frameID();
28 uint frameid_size
= frameid
.size();
29 char *frameid_s
= new char[frameid_size
+ 1];
30 memcpy(frameid_s
, frameid
.data(), frameid_size
);
31 frameid_s
[frameid_size
] = '\0';
32 printf("%s: %s\n", frameid_s
, (*it
)->toString().toCString());
33 if (frameid
!= "APIC") {
36 TagLib::ID3v2::AttachedPictureFrame
*frame
=
37 (TagLib::ID3v2::AttachedPictureFrame
*)(*it
);
38 TagLib::ByteVector data
= frame
->picture();
39 int fd
= open(argv
[2], O_CREAT
| O_WRONLY
);
40 write(fd
, data
.data(), data
.size());