Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Using C++ TagLib, not TagLib Sharp - how to write APIC frames

Using C++ TagLib, not TagLib Sharp - how to write APIC frames

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorial
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Steve S
    wrote on last edited by
    #1

    I'm wanting to batch edit the ID3V2 tags in around 1660 CDs worth of tracks, as I have metadata stored elsewhere. Part of this process involves adding a APIC tag with the contents of a JPEG file. Now, I have jumped through the various hoops to get everything working except one thing, namely, the artwork. Everything else (genre, album, track number, etc) work fine, and the tags are visible to iTunes and Windows Media Player. However, I am stumped as to how to add the artwork I thought that the sequence

    TagLib::MPEG::File f(filename);
    TagLib::ID3v2::Tag*t = f.ID3v2Tag();
    // code omitted to initialise the ByteVector of data from file (which I checked!)
    TagLib::ID3v2::AttachedPictureFrame* pF = new TagLib::ID3v2::AttachedPictureFrame();
    pF->setData(jpegData);
    pF->setMimeType("image/jpeg");
    pF->setType(TagLib::ID3v2::AttachedPictureFrame::FrontCover);
    t->addFrame(pF);
    f.save(TagLib::MPEG::File::ID3v2,false,3);

    should work, but it does not save my artwork :( If anyone has working C++ code that does work, I'd be very grateful.

    Steve S Developer for hire

    S 1 Reply Last reply
    0
    • S Steve S

      I'm wanting to batch edit the ID3V2 tags in around 1660 CDs worth of tracks, as I have metadata stored elsewhere. Part of this process involves adding a APIC tag with the contents of a JPEG file. Now, I have jumped through the various hoops to get everything working except one thing, namely, the artwork. Everything else (genre, album, track number, etc) work fine, and the tags are visible to iTunes and Windows Media Player. However, I am stumped as to how to add the artwork I thought that the sequence

      TagLib::MPEG::File f(filename);
      TagLib::ID3v2::Tag*t = f.ID3v2Tag();
      // code omitted to initialise the ByteVector of data from file (which I checked!)
      TagLib::ID3v2::AttachedPictureFrame* pF = new TagLib::ID3v2::AttachedPictureFrame();
      pF->setData(jpegData);
      pF->setMimeType("image/jpeg");
      pF->setType(TagLib::ID3v2::AttachedPictureFrame::FrontCover);
      t->addFrame(pF);
      f.save(TagLib::MPEG::File::ID3v2,false,3);

      should work, but it does not save my artwork :( If anyone has working C++ code that does work, I'd be very grateful.

      Steve S Developer for hire

      S Offline
      S Offline
      Steve S
      wrote on last edited by
      #2

      (cough) Actually, it works properly when you remember to call the right member function. Instead of pF->setData(...), I should have called pF->setPicture(...) :-O Sigh. That's another hour's debugging time I'll never get back, for want of proper reading of the underlying code....

      Steve S Developer for hire

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups