aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/id3v2enc.c
diff options
context:
space:
mode:
authorMatthieu Bouron <matthieu.bouron@gmail.com>2013-05-29 12:05:26 +0200
committerPaul B Mahol <onemda@gmail.com>2013-05-30 21:16:57 +0000
commitf468325d34899a9b44ac6a38b24c6a9426682a28 (patch)
treef060904767e42bde1a177b749df5838afd4e94d3 /libavformat/id3v2enc.c
parentc4e0e314248865830ec073e5a3ef08e0a40aabf2 (diff)
downloadffmpeg-f468325d34899a9b44ac6a38b24c6a9426682a28.tar.gz
lavf/id3v2enc: fix cover art display on some software
Adding an arbitrary amount of padding bytes at the end of the ID3 metadata fixes cover art display for some software (iTunes, Traktor, Serato, Torq). For reference (ID3 metadata): [ Apic frames ] -> cover doesn't show up [ Apic frames, Padding ] -> ok [ Apic frames, ID3 frames ] -> ok [ ID3 frames, Apic frames ] -> cover doesn't show up [ ID3 frames, Apic frames, Padding ] -> ok
Diffstat (limited to 'libavformat/id3v2enc.c')
-rw-r--r--libavformat/id3v2enc.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/libavformat/id3v2enc.c b/libavformat/id3v2enc.c
index 60ddbaaafc..f7c37ebbdb 100644
--- a/libavformat/id3v2enc.c
+++ b/libavformat/id3v2enc.c
@@ -26,8 +26,11 @@
#include "libavutil/intreadwrite.h"
#include "avformat.h"
#include "avio.h"
+#include "avio_internal.h"
#include "id3v2.h"
+#define PADDING_BYTES 10
+
static void id3v2_put_size(AVIOContext *pb, int size)
{
avio_w8(pb, size >> 21 & 0x7f);
@@ -319,7 +322,15 @@ int ff_id3v2_write_apic(AVFormatContext *s, ID3v2EncContext *id3, AVPacket *pkt)
void ff_id3v2_finish(ID3v2EncContext *id3, AVIOContext *pb)
{
- int64_t cur_pos = avio_tell(pb);
+ int64_t cur_pos;
+
+ /* adding an arbitrary amount of padding bytes at the end of the
+ * ID3 metadata fixes cover art display for some software (iTunes,
+ * Traktor, Serato, Torq) */
+ ffio_fill(pb, 0, PADDING_BYTES);
+ id3->len += PADDING_BYTES;
+
+ cur_pos = avio_tell(pb);
avio_seek(pb, id3->size_pos, SEEK_SET);
id3v2_put_size(pb, id3->len);
avio_seek(pb, cur_pos, SEEK_SET);