[FFmpeg-devel] [PATCH 1/3] avformat/mov: skip moof and sidx before found moov

Zhao Zhili quinkblack at foxmail.com
Fri Dec 24 11:58:21 EET 2021


---
 libavformat/mov.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 2aed6e80ef..ea2f010aa0 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -7366,6 +7366,21 @@ static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom)
             break;
         a.size = FFMIN(a.size, atom.size - total_size);
 
+        if (!c->found_moov) {
+            static uint32_t skip_before_moov[] = {
+                MKTAG('m', 'o', 'o', 'f'),
+                MKTAG('s', 'i', 'd', 'x'),
+            };
+            for (size_t i = 0; i < FF_ARRAY_ELEMS(skip_before_moov); i++) {
+                if (a.type == skip_before_moov[i]) {
+                    av_log(c->fc, AV_LOG_WARNING, "Skip %s atom before moov.\n",
+                           av_fourcc2str(a.type));
+                    parse = NULL;
+                    goto skip;
+                }
+            }
+        }
+
         for (i = 0; mov_default_parse_table[i].type; i++)
             if (mov_default_parse_table[i].type == a.type) {
                 parse = mov_default_parse_table[i].parse;
@@ -7386,6 +7401,7 @@ static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom)
             parse = mov_read_keys;
         }
 
+skip:
         if (!parse) { /* skip leaf atoms data */
             avio_skip(pb, a.size);
         } else {
-- 
2.31.1



More information about the ffmpeg-devel mailing list