<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hello,<div class=""><br class=""></div><div class="">I am having strange issue reading / writing cover data in MP4 (AAC or ALAC).</div><div class="">I am using code adapted from test_mp4.cpp (see below).</div><div class=""><br class=""></div><div class="">1. taglib <b class="">can</b> read cover data saved by other apps. (e.g. iTunes)</div><div class="">2. taglib <b class="">can’t read</b> cover data written with taglib</div><div class="">3. Other apps (i.e.iTunes, MusicBrainz Picard) <b class="">can</b> read cover data written with taglib.</div><div class=""><br class=""></div><div class="">with latest release. (i am pretty sure this used to work in previous releases)</div><div class="">thank you for any help</div><div class="">yannis</div><div class=""><br class=""></div><div class="">_________________________________________________________________________</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><span style="color: rgba(163, 163, 163, 0.35); font-family: Menlo; background-color: rgb(255, 255, 255);" class="">///</span><span style="font-family: Menlo; background-color: rgb(255, 255, 255); color: rgb(163, 163, 163);" class="">/ READ</span></div><div class=""></div><div class=""><span style="font-family: Menlo; background-color: rgb(255, 255, 255); color: rgb(92, 38, 153);" class="">NSData</span><span style="font-family: Menlo; background-color: rgb(255, 255, 255);" class=""> *</span><span style="font-family: Menlo; background-color: rgb(255, 255, 255); caret-color: rgb(15, 104, 160); color: rgb(15, 104, 160);" class="">readCoverForFile</span><span style="font-family: Menlo; background-color: rgb(255, 255, 255); color: rgb(15, 104, 160);" class="">(</span><span style="font-family: Menlo; background-color: rgb(255, 255, 255); color: rgb(63, 110, 116);" class="">MP4</span><span style="font-family: Menlo; background-color: rgb(255, 255, 255);" class="">::</span><span style="font-family: Menlo; background-color: rgb(255, 255, 255); color: rgb(63, 110, 116);" class="">File</span><span style="font-family: Menlo; background-color: rgb(255, 255, 255);" class=""> </span><span style="font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&f, </span><span style="font-family: Menlo; background-color: rgb(255, 255, 255); caret-color: rgb(170, 13, 145); color: rgb(170, 13, 145);" class="">int </span><span style="font-family: Menlo; background-color: rgb(255, 255, 255); color: rgb(15, 104, 160);" class="">index)</span></div><div class=""><span style="font-family: Menlo; background-color: rgb(255, 255, 255);" class="">{</span></div><div class=""><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span class="Apple-tab-span" style="white-space: pre;"> </span><span style="color: rgb(63, 110, 116);" class="">MP4</span>::<span style="color: rgb(63, 110, 116);" class="">Tag</span> *tag = f.<span style="color: rgb(38, 71, 75);" class="">tag</span>();</div><p style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><span class="Apple-tab-span" style="white-space:pre"> </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #aa0d91" class="">if</span>( tag-><span style="color: #26474b" class="">contains</span>(<span style="color: #c41a16" class="">"covr"</span>) )</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>{</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #3f6e74" class="">MP4</span>::<span style="color: #3f6e74" class="">Item</span> item = tag-><span style="color: #26474b" class="">item</span>(<span style="color: #c41a16" class="">"covr"</span>);</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #3f6e74" class="">MP4</span>::<span style="color: #3f6e74" class="">CoverArtList</span> coverArtList = item.<span style="color: #26474b" class="">toCoverArtList</span>();</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #aa0d91" class="">if</span>( index < coverArtList.<span style="color: #26474b" class="">size</span>() )</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>{</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #3f6e74" class="">MP4</span>::<span style="color: #3f6e74" class="">CoverArt</span> coverArt = coverArtList[index];</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #aa0d91" class="">return</span> [<span style="color: #5c2699" class="">NSData</span> <span style="color: #2e0d6e" class="">dataWithBytes</span>:coverArt.<span style="color: #26474b" class="">data</span>().<span style="color: #26474b" class="">data</span>() <span style="color: #2e0d6e" class="">length</span>:coverArt.<span style="color: #26474b" class="">data</span>().<span style="color: #26474b" class="">size</span>()];</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>}</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>}</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>return nil;</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">}</div></div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span></div><div class=""><span style="color: rgba(163, 163, 163, 0.35); font-family: Menlo; background-color: rgb(255, 255, 255);" class="">///</span><span style="font-family: Menlo; background-color: rgb(255, 255, 255); color: rgb(163, 163, 163);" class="">/ WRITE</span></div><div class=""><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="color: #aa0d91" class="">static</span> <span style="color: #aa0d91" class="">void</span> <span style="color: #0f68a0" class="">setCoverForFile</span>(<span style="color: #3f6e74" class="">MP4</span>::<span style="color: #3f6e74" class="">File</span> &f, <span style="color: #5c2699" class="">NSData</span> *coverData, <span style="color: #aa0d91" class="">const</span> <span style="color: #aa0d91" class="">char</span> *mime)</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">{</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #3f6e74" class="">MP4</span>::<span style="color: #3f6e74" class="">Tag</span> *tag = f.<span style="color: #26474b" class="">tag</span>();</div><p style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><span class="Apple-tab-span" style="white-space:pre"> </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #aa0d91" class="">if</span>( tag-><span style="color: #26474b" class="">contains</span>(<span style="color: #c41a16" class="">"covr"</span>) )</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>tag-><span style="color: #26474b" class="">removeItem</span>(<span style="color: #c41a16" class="">"covr"</span>);</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #aa0d91" class="">if</span>( coverData )</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>{</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; color: rgb(163, 163, 163); background-color: rgb(255, 255, 255);" class=""><span style="color: #000000" class=""><span class="Apple-tab-span" style="white-space:pre"> </span></span>// Create cover art</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #3f6e74" class="">ByteVector</span> v((<span style="color: #aa0d91" class="">const</span> <span style="color: #aa0d91" class="">char</span> *) coverData.<span style="color: #5c2699" class="">bytes</span>, (<span style="color: #aa0d91" class="">unsigned</span> <span style="color: #aa0d91" class="">int</span>) coverData.<span style="color: #5c2699" class="">length</span>);</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; color: rgb(63, 110, 116); background-color: rgb(255, 255, 255);" class=""><span style="color: #000000" class=""><span class="Apple-tab-span" style="white-space:pre"> </span></span>MP4<span style="color: #000000" class="">::</span>CoverArt<span style="color: #000000" class=""> coverArt( (</span>MP4<span style="color: #000000" class="">::</span>CoverArt<span style="color: #000000" class="">::</span>Format<span style="color: #000000" class="">)</span><span style="color: #2e0d6e" class="">typeJPEG</span><span style="color: #000000" class="">, v);</span></div><p style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><span class="Apple-tab-span" style="white-space:pre"> </span><br class="webkit-block-placeholder"></p><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; color: rgb(163, 163, 163); background-color: rgb(255, 255, 255);" class=""><span style="color: #000000" class=""><span class="Apple-tab-span" style="white-space:pre"> </span></span>// Create cover art item (a CoverArtList instance)</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #3f6e74" class="">MP4</span>::<span style="color: #3f6e74" class="">CoverArtList</span> coverArtList;</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>coverArtList.<span style="color: #26474b" class="">append</span>(coverArt);</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span class="Apple-tab-span" style="white-space:pre"> </span><span style="color: #3f6e74" class="">MP4</span>::<span style="color: #3f6e74" class="">Item</span> coverItem(coverArtList);</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; color: rgb(163, 163, 163); background-color: rgb(255, 255, 255);" class=""><span style="color: #000000" class=""><span class="Apple-tab-span" style="white-space:pre"> </span></span>// Insert to tag map</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>tag-><span style="color: #26474b" class="">setItem</span>(<span style="color: #c41a16" class="">"covr"</span>, coverItem);</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>}</div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><div style="margin: 0px; font-stretch: normal; line-height: normal; color: rgb(38, 71, 75);" class=""><span style="color: #000000" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>f.</span>save<span style="color: #000000" class="">()</span></div></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">}</div></div><div class=""><br class=""></div></body></html>