From 738ad621d822196e606c3825b7be47f2c67138ea Mon Sep 17 00:00:00 2001 From: "epg@pretzelnet.org" <> Date: Fri, 2 Nov 2012 00:52:13 -0700 Subject: [PATCH] some demo apic reading code; would be nice to save all APIC frames. --- apic-read.cc | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 apic-read.cc diff --git a/apic-read.cc b/apic-read.cc new file mode 100644 index 0000000..0438a02 --- /dev/null +++ b/apic-read.cc @@ -0,0 +1,45 @@ +#include + +#include +#include +#include +#include + +#include +#include +#include + +// some demo apic reading code; would be nice to save all APIC frames. + +int +main(int argc, char **argv) +{ + const char *mp3_path = argv[1]; + TagLib::MPEG::File f(mp3_path); + TagLib::ID3v2::Tag *id3v2tag = f.ID3v2Tag(); + if (!id3v2tag) { + return 0; + } + TagLib::ID3v2::FrameList::ConstIterator it; + for (it = id3v2tag->frameList().begin(); + it != id3v2tag->frameList().end(); + it++) { + TagLib::ByteVector frameid = (*it)->frameID(); + uint frameid_size = frameid.size(); + char *frameid_s = new char[frameid_size + 1]; + memcpy(frameid_s, frameid.data(), frameid_size); + frameid_s[frameid_size] = '\0'; + printf("%s: %s\n", frameid_s, (*it)->toString().toCString()); + if (frameid != "APIC") { + continue; + } + TagLib::ID3v2::AttachedPictureFrame *frame = + (TagLib::ID3v2::AttachedPictureFrame *)(*it); + TagLib::ByteVector data = frame->picture(); + int fd = open(argv[2], O_CREAT | O_WRONLY); + write(fd, data.data(), data.size()); + close(fd); + } + + return 0; +} -- 2.48.1