]> git.sesse.net Git - ffmpeg/commitdiff
avformat/mov: Add option to ignore chapters during parsing
authorBryan Huh <bryan@box.com>
Tue, 10 Nov 2015 19:11:26 +0000 (11:11 -0800)
committerMichael Niedermayer <michael@niedermayer.cc>
Tue, 10 Nov 2015 22:45:19 +0000 (23:45 +0100)
Chapter-indexing can be expensive since chapters may be interspersed
throughout the entire file and may require many seeks - especially
costly when consuming a video over a remote protocol like http.
Furthermore it is often unnecessary, especially when only trying to get
video info (e.g. via ffprobe).

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/isom.h
libavformat/mov.c

index dba30a25f1a6f18fa42110624327321f0efe92e3..a082e403b73d6fdc5e6587d829cb695b2c86991e 100644 (file)
@@ -190,6 +190,7 @@ typedef struct MOVContext {
     int chapter_track;
     int use_absolute_path;
     int ignore_editlist;
+    int ignore_chapters;
     int seek_individually;
     int64_t next_root_atom; ///< offset of the next root atom
     int export_all;
index a7ba4d8ae29ad0930042351497eb9a64b2b2ee4c..38d36590e6c72781bb3fe96cc7b0e26b197beacf 100644 (file)
@@ -462,6 +462,9 @@ static int mov_read_chpl(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     char str[256+1];
     int ret;
 
+    if (c->ignore_chapters)
+        return 0;
+
     if ((atom.size -= 5) < 0)
         return 0;
 
@@ -4635,7 +4638,7 @@ static int mov_read_header(AVFormatContext *s)
     av_log(mov->fc, AV_LOG_TRACE, "on_parse_exit_offset=%"PRId64"\n", avio_tell(pb));
 
     if (pb->seekable) {
-        if (mov->chapter_track > 0)
+        if (mov->chapter_track > 0 && !mov->ignore_chapters)
             mov_read_chapters(s);
         for (i = 0; i < s->nb_streams; i++)
             if (s->streams[i]->codec->codec_tag == AV_RL32("tmcd"))
@@ -5046,6 +5049,8 @@ static const AVOption mov_options[] = {
         0, 1, FLAGS},
     {"ignore_editlist", "", OFFSET(ignore_editlist), AV_OPT_TYPE_INT, {.i64 = 0},
         0, 1, FLAGS},
+    {"ignore_chapters", "", OFFSET(ignore_chapters), 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},