[FFmpeg-devel] [PATCH 2/2] avformat/movenc: allow hdlr name field to be empty

Gyan Doshi gyandoshi at gmail.com
Mon Jun 18 17:34:27 EEST 2018


Fixes #7262.

Requires https://patchwork.ffmpeg.org/patch/9420/ to be applied first.

Regards,
Gyan
-------------- next part --------------
From bc208828dc7c9456550c1b27e7540b2b03be817e Mon Sep 17 00:00:00 2001
From: Gyan Doshi <ffmpeg at gyani.pro>
Date: Mon, 18 Jun 2018 19:52:20 +0530
Subject: [PATCH 2/2] avformat/movenc: allow hdlr name field to be empty

Both QTFF and the ISOBMFF standards allow it.

Fixes #7262
---
 libavformat/movenc.c  | 16 +++++++++++-----
 libavformat/movenc.h  |  1 +
 libavformat/version.h |  2 +-
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 3661d24f4f..cc8bb1cfd5 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -101,6 +101,7 @@ static const AVOption options[] = {
     { "write_prft", "Write producer reference time box with specified time source", offsetof(MOVMuxContext, write_prft), AV_OPT_TYPE_INT, {.i64 = MOV_PRFT_NONE}, 0, MOV_PRFT_NB-1, AV_OPT_FLAG_ENCODING_PARAM, "prft"},
     { "wallclock", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = MOV_PRFT_SRC_WALLCLOCK}, 0, 0, AV_OPT_FLAG_ENCODING_PARAM, "prft"},
     { "pts", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = MOV_PRFT_SRC_PTS}, 0, 0, AV_OPT_FLAG_ENCODING_PARAM, "prft"},
+    { "empty_hdlr_name", "write zero-length name string in hdlr atoms within mdia and minf atoms", offsetof(MOVMuxContext, empty_hdlr_name), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, AV_OPT_FLAG_ENCODING_PARAM},
     { NULL },
 };
 
@@ -2551,6 +2552,7 @@ static int is_clcp_track(MOVTrack *track)
 
 static int mov_write_hdlr_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack *track)
 {
+    MOVMuxContext *mov = s->priv_data;
     const char *hdlr, *descr = NULL, *hdlr_type = NULL;
     int64_t pos = avio_tell(pb);
 
@@ -2613,11 +2615,15 @@ static int mov_write_hdlr_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack *tra
     avio_wb32(pb, 0); /* reserved */
     avio_wb32(pb, 0); /* reserved */
     avio_wb32(pb, 0); /* reserved */
-    if (!track || track->mode == MODE_MOV)
-        avio_w8(pb, strlen(descr)); /* pascal string */
-    avio_write(pb, descr, strlen(descr)); /* handler description */
-    if (track && track->mode != MODE_MOV)
-        avio_w8(pb, 0); /* c string */
+    if (mov->empty_hdlr_name) /* expressly allowed by QTFF and not prohibited in ISO 14496-12 8.4.3.3 */
+        avio_w8(pb, 0);
+    else {
+        if (!track || track->mode == MODE_MOV)
+            avio_w8(pb, strlen(descr)); /* pascal string */
+        avio_write(pb, descr, strlen(descr)); /* handler description */
+        if (track && track->mode != MODE_MOV)
+            avio_w8(pb, 0); /* c string */
+    }
     return update_size(pb, pos);
 }
 
diff --git a/libavformat/movenc.h b/libavformat/movenc.h
index f2967bface..fe605d1ad2 100644
--- a/libavformat/movenc.h
+++ b/libavformat/movenc.h
@@ -233,6 +233,7 @@ typedef struct MOVMuxContext {
     int track_ids_ok;
     int write_tmcd;
     MOVPrftBox write_prft;
+    int empty_hdlr_name;
 } MOVMuxContext;
 
 #define FF_MOV_FLAG_RTP_HINT              (1 <<  0)
diff --git a/libavformat/version.h b/libavformat/version.h
index 3c54efbb37..57b6599e71 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -33,7 +33,7 @@
 // Also please add any ticket numbers that you believe might be affected here
 #define LIBAVFORMAT_VERSION_MAJOR  58
 #define LIBAVFORMAT_VERSION_MINOR  17
-#define LIBAVFORMAT_VERSION_MICRO 100
+#define LIBAVFORMAT_VERSION_MICRO 101
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
                                                LIBAVFORMAT_VERSION_MINOR, \
-- 
2.12.2.windows.2


More information about the ffmpeg-devel mailing list