[FFmpeg-devel] [PATCH 1/1] possible fix to correct (improve) bitrate estimation for streams in fragmented MP4 when calculation is based on trex_data

Nick Ryan nick.paul.ryan at gmail.com
Wed Sep 26 15:00:44 EEST 2018


Signed-off-by: Nick Ryan <nick.paul.ryan at gmail.com>
---
 libavformat/mov.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 540e5ca057..67015a72a1 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -7459,14 +7459,14 @@ static int mov_read_header(AVFormatContext *s)
         for (i = 0; i < s->nb_streams; i++) {
             AVStream *st = s->streams[i];
             MOVStreamContext *sc = st->priv_data;
-            if (st->duration > 0) {
+            if (sc->duration_for_fps > 0) {
                 if (sc->data_size > INT64_MAX / sc->time_scale / 8) {
                     av_log(s, AV_LOG_ERROR, "Overflow during bit rate calculation %"PRId64" * 8 * %d\n",
                            sc->data_size, sc->time_scale);
                     mov_read_close(s);
                     return AVERROR_INVALIDDATA;
                 }
-                st->codecpar->bit_rate = sc->data_size * 8 * sc->time_scale / st->duration;
+                st->codecpar->bit_rate = sc->data_size * 8 * sc->time_scale / sc->duration_for_fps;
             }
         }
     }
-- 
2.17.1 (Apple Git-112)



More information about the ffmpeg-devel mailing list