[FFmpeg-devel] mov: add option to ignore moov atoms which are detected in free atoms, so apps can have flexibility to use moov atom not in free atoms as default.

Submitted by liangsi on Oct. 24, 2016, 9:11 p.m.

Details

Message ID 1477343512-60568-1-git-send-email-zhennihuang@google.com
State New
Headers show

Commit Message

liangsi Oct. 24, 2016, 9:11 p.m.
From: liangsi <zhennihuang@google.com>

---
 libavformat/isom.h | 1 +
 libavformat/mov.c  | 5 ++++-
 2 files changed, 5 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/libavformat/isom.h b/libavformat/isom.h
index 2246fed..6824f7e 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -214,6 +214,7 @@  typedef struct MOVContext {
     int use_absolute_path;
     int ignore_editlist;
     int ignore_chapters;
+    int ignore_moov_atom_in_free;
     int seek_individually;
     int64_t next_root_atom; ///< offset of the next root atom
     int export_all;
diff --git a/libavformat/mov.c b/libavformat/mov.c
index a15c8d1..1d80c09 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -4848,7 +4848,8 @@  static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom)
         if (atom.size >= 8) {
             a.size = avio_rb32(pb);
             a.type = avio_rl32(pb);
-            if (a.type == MKTAG('f','r','e','e') &&
+            if (!c->ignore_moov_atom_in_free && 
+                a.type == MKTAG('f','r','e','e') &&
                 a.size >= 8 &&
                 c->moov_retry) {
                 uint8_t buf[8];
@@ -5926,6 +5927,8 @@  static const AVOption mov_options[] = {
         0, 1, FLAGS},
     {"ignore_chapters", "", OFFSET(ignore_chapters), AV_OPT_TYPE_BOOL, {.i64 = 0},
         0, 1, FLAGS},
+    {"ignore_moov_atom_in_free", "", OFFSET(ignore_moov_atom_in_free), AV_OPT_TYPE_BOOL, 
+        {.i64 = 0}, 0, 1, FLAGS},
     {"use_mfra_for",
         "use mfra for fragment timestamps",
         OFFSET(use_mfra_for), AV_OPT_TYPE_INT, {.i64 = FF_MOV_FLAG_MFRA_AUTO},