]> diplodocus.org Git - flac-archive/commitdiff
Here's some demo code i whipped up to add APIC to an mp3 with taglib.
authorepg <>
Sun, 29 Oct 2006 08:12:37 +0000 (08:12 +0000)
committerepg <>
Sun, 29 Oct 2006 08:12:37 +0000 (08:12 +0000)
crap.cc [new file with mode: 0644]

diff --git a/crap.cc b/crap.cc
new file mode 100644 (file)
index 0000000..ed0e01d
--- /dev/null
+++ b/crap.cc
@@ -0,0 +1,35 @@
+extern "C" {
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+
+#include <fcntl.h>
+#include <stdio.h>
+#include <unistd.h>
+
+};
+
+#include <attachedpictureframe.h>
+#include <id3v2tag.h>
+#include <mpegfile.h>
+
+int main(int argc, char *argv[])
+{
+    struct stat st;
+    stat(argv[2], &st);
+    int fd = open(argv[2], O_RDONLY);
+    char *m = (char *)malloc(st.st_size);
+    read(fd, m, st.st_size);
+
+    TagLib::MPEG::File f(argv[1]);
+    TagLib::ID3v2::AttachedPictureFrame p;
+    p.setMimeType("image/jpeg");
+    p.setType(TagLib::ID3v2::AttachedPictureFrame::FrontCover);
+    TagLib::ByteVector bv;
+    bv.setData(m, st.st_size);
+    p.setPicture(bv);
+    TagLib::ID3v2::Tag *t = f.ID3v2Tag(true);
+    t->addFrame(&p);
+    f.save();
+    return 0;
+}