]> git.sesse.net Git - ffmpeg/commitdiff
dashenc: fix bitrate estimation with correct scaling
authorAnton Schubert <ischluff@mailbox.org>
Thu, 26 Oct 2017 16:02:04 +0000 (18:02 +0200)
committerLuca Barbato <lu_zero@gentoo.org>
Fri, 27 Oct 2017 17:52:48 +0000 (19:52 +0200)
Signed-off-by: Anton Schubert <ischluff@mailbox.org>
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
libavformat/dashenc.c

index 336cea24ec33b653dec87e4a0bf9286a2b29a2f8..4f8d7d85dc0f4445af1ac10624dfd5c39bb637a8 100644 (file)
@@ -1040,6 +1040,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;
 
@@ -1091,7 +1092,9 @@ 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 * AV_TIME_BASE / av_rescale_q(os->max_pts - os->start_pts,
+                                                                                       st->time_base,
+                                                                                       AV_TIME_BASE_Q);
             if (bitrate >= 0) {
                 os->bit_rate = bitrate;
                 snprintf(os->bandwidth_str, sizeof(os->bandwidth_str),