[FFmpeg-devel] [PATCH] Optionally enable ID3 in ADTS. Pass through iTunSMPB from MOV.

Dale Curtis dalecurtis at chromium.org
Mon Jul 21 21:05:08 CEST 2014


Allows demuxing of iTunes files into adts while preserving gapless
metadata.
---
 libavformat/adtsenc.c | 5 +++++
 libavformat/mov.c     | 4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/libavformat/adtsenc.c b/libavformat/adtsenc.c
index 58a7f2d..9ec1181 100644
--- a/libavformat/adtsenc.c
+++ b/libavformat/adtsenc.c
@@ -27,6 +27,7 @@
 #include "libavutil/opt.h"
 #include "avformat.h"
 #include "apetag.h"
+#include "id3v2.h"
 
 #define ADTS_HEADER_SIZE 7
 
@@ -38,6 +39,7 @@ typedef struct {
     int channel_conf;
     int pce_size;
     int apetag;
+    int id3v2tag;
     uint8_t pce_data[MAX_PCE_SIZE];
 } ADTSContext;
 
@@ -97,6 +99,8 @@ static int adts_write_header(AVFormatContext *s)
     ADTSContext *adts = s->priv_data;
     AVCodecContext *avc = s->streams[0]->codec;
 
+    if (adts->id3v2tag)
+        ff_id3v2_write_simple(s, 4, ID3v2_DEFAULT_MAGIC);
     if (avc->extradata_size > 0 &&
             adts_decode_extradata(s, adts, avc->extradata, avc->extradata_size) < 0)
         return -1;
@@ -179,6 +183,7 @@ static int adts_write_trailer(AVFormatContext *s)
 #define ENC AV_OPT_FLAG_ENCODING_PARAM
 #define OFFSET(obj) offsetof(ADTSContext, obj)
 static const AVOption options[] = {
+    { "write_id3v2", "Enable ID3v2 tag writing", OFFSET(id3v2tag), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, ENC},
     { "write_apetag", "Enable APE tag writing", OFFSET(apetag), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, ENC},
     { NULL },
 };
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 9b4832f..cfe76cd 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -2534,8 +2534,8 @@ static int mov_read_custom_2plus(MOVContext *c, AVIOContext *pb, int size)
                 if(priming>0 && priming<16384)
                     sc->start_pad = priming;
             }
-        } else if (strcmp(key, "cdec") == 0) {
-        } else {
+        }
+        if (strcmp(key, "cdec") != 0) {
             av_dict_set(&c->fc->metadata, key, val,
                         AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL);
             key = val = NULL;
-- 
2.0.0.526.g5318336



More information about the ffmpeg-devel mailing list