]>
diplodocus.org Git - flac-archive/blob - apic-read.cc
ad07b3d70d84172eed2c7e44f0e4e76fe31a6d74
9 #include <attachedpictureframe.h>
13 // some demo apic reading code; would be nice to save all APIC frames.
15 using TagLib::ID3v2::AttachedPictureFrame
;
16 using TagLib::ID3v2::Frame
;
17 using TagLib::ID3v2::FrameList
;
18 using TagLib::ID3v2::Tag
;
21 main(int argc
, char **argv
)
23 const char *mp3_path
= argv
[1];
24 TagLib::MPEG::File
f(mp3_path
);
25 Tag
*id3v2tag
= f
.ID3v2Tag();
29 const FrameList
&frames
= id3v2tag
->frameList();
30 FrameList::ConstIterator it
;
31 for (it
= frames
.begin(); it
!= frames
.end(); it
++) {
33 TagLib::ByteVector frameid
= frame
->frameID();
34 uint frameid_size
= frameid
.size();
35 char *frameid_s
= new char[frameid_size
+ 1];
36 memcpy(frameid_s
, frameid
.data(), frameid_size
);
37 frameid_s
[frameid_size
] = '\0';
38 printf("%s: %s\n", frameid_s
, frame
->toString().toCString());
39 if (frameid
!= "APIC") {
42 AttachedPictureFrame
*pic_frame
= (AttachedPictureFrame
*)frame
;
43 TagLib::ByteVector data
= pic_frame
->picture();
44 int fd
= open(argv
[2], O_CREAT
| O_WRONLY
);
49 ssize_t size
= data
.size();
50 ssize_t status
= write(fd
, data
.data(), size
);
56 fprintf(stderr
, "wrote only %d bytes out of %d\n", status
, size
);