mov.c: reasonable bitrate for fragmented mp4
authorMika Raento <mikie@iki.fi>
Tue, 21 Oct 2014 12:04:10 +0000 (15:04 +0300)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 21 Oct 2014 16:06:18 +0000 (18:06 +0200)
If using MFRA for timestamps, the stream may start from a large offset
and/or have gaps. With this change we calculate the bitrate based on
frames we've seen.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavformat/mov.c

index 80549eca54f3a00bd2ade98c9871130461ea8e5d..1444bcedf7ef229037f38ce1d45c199e8c28c2c9 100644 (file)
@@ -3943,6 +3943,17 @@ static int mov_read_header(AVFormatContext *s)
         }
     }
 
+    if (mov->use_mfra_for > 0) {
+        for (i = 0; i < s->nb_streams; i++) {
+            AVStream *st = s->streams[i];
+            MOVStreamContext *sc = st->priv_data;
+            if (sc->duration_for_fps > 0) {
+                st->codec->bit_rate = sc->data_size * 8 * sc->time_scale /
+                    sc->duration_for_fps;
+            }
+        }
+    }
+
     for (i = 0; i < mov->bitrates_count && i < s->nb_streams; i++) {
         if (mov->bitrates[i]) {
             s->streams[i]->codec->bit_rate = mov->bitrates[i];