dashenc: fix bitrate estimation with correct scaling
authorAnton Schubert <ischluff@mailbox.org>
Sun, 29 Oct 2017 15:10:34 +0000 (16:10 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Sun, 29 Oct 2017 17:28:40 +0000 (18:28 +0100)
Signed-off-by: Anton Schubert <ischluff@mailbox.org>
Signed-off-by: Peter Gro├če <pegro@friiks.de>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/dashenc.c

index 04b0fd9..e25a660 100644 (file)
@@ -947,6 +947,7 @@ static int dash_flush(AVFormatContext *s, int final, int stream)
 
     for (i = 0; i < s->nb_streams; i++) {
         OutputStream *os = &c->streams[i];
+        AVStream *st = s->streams[i];
         char filename[1024] = "", full_path[1024], temp_path[1024];
         int range_length, index_length = 0;
 
@@ -1001,7 +1002,7 @@ static int dash_flush(AVFormatContext *s, int final, int stream)
 
         if (!os->bit_rate) {
             // calculate average bitrate of first segment
-            int64_t bitrate = (int64_t) range_length * 8 * AV_TIME_BASE / (os->max_pts - os->start_pts);
+            int64_t bitrate = (int64_t) range_length * 8 / ((os->max_pts - os->start_pts) * av_q2d(st->time_base));
             if (bitrate >= 0) {
                 os->bit_rate = bitrate;
                 snprintf(os->bandwidth_str, sizeof(os->bandwidth_str),