[FFmpeg-devel] mov/mp4 found_moov variable uninitialized

Frank Barchard fbarchard
Thu Jun 25 10:58:41 CEST 2009


when opening a mov/mp4 with is_streamed, the following statement stops
parsing, avoiding unnecessary seeks to end of file

            if (url_is_streamed(pb) && c->found_moov && c->found_mdat)
               break;


but if you close/shutdown and open a new movie, found_mdat is reset to
0, but found_moov is not.

If the moov comes before the mdat (ie qt-faststart was used), then no
problem is observed.

But if the moov comes after the mdat, as produced by ffmpeg by
default, the old moov header is used.

If the files are similar, its still possible for no issue to be
observed.  So to reproduce, you need 2 different sized videos with
moov header at the end of file, and an application that can
play/decode 2 movies back to back.

The following patch should fix the issue, but I haven't tested it.
I'm hoping someone familiar with the mp4 code can review this, or fix
the issue in another way.


--- libavformat/mov.orig.c      2009-06-24 23:45:32.099461400 -0700
+++ libavformat/mov.c   2009-06-24 23:45:37.755675200 -0700
@@ -1958,6 +1958,7 @@ static int mov_read_packet(AVFormatConte
     }
     if (!sample) {
         mov->found_mdat = 0;
+        mov->found_moov = 0;
         if (!url_is_streamed(s->pb) ||
             mov_read_default(mov, s->pb, (MOVAtom){ 0, 0, INT64_MAX }) < 0
||
             url_feof(s->pb))



More information about the ffmpeg-devel mailing list