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