[FFmpeg-devel] [PATCH 26/28] changed: don't override file duration with bitrate duration for matroska files

Mans Rullgard mans
Wed Jun 30 11:09:54 CEST 2010


From: Cory Fields <theuni-nospam- at xbmc.org>

---
 libavformat/utils.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 5f9beb4..83ae8b9 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1755,6 +1755,8 @@ static int av_has_duration(AVFormatContext *ic)
 {
     int i;
     AVStream *st;
+    if(ic->duration != AV_NOPTS_VALUE)
+        return 1;
 
     for(i = 0;i < ic->nb_streams; i++) {
         st = ic->streams[i];
@@ -1805,14 +1807,14 @@ static void av_update_stream_timings(AVFormatContext *ic)
                 duration = end_time - start_time;
         }
     }
-    if (duration != INT64_MIN) {
+    if (duration != INT64_MIN && ic->duration == AV_NOPTS_VALUE) {
         ic->duration = duration;
-        if (ic->file_size > 0) {
+    }
+        if (ic->file_size > 0 && ic->duration != AV_NOPTS_VALUE) {
             /* compute the bitrate */
             ic->bit_rate = (double)ic->file_size * 8.0 * AV_TIME_BASE /
                 (double)ic->duration;
         }
-    }
 }
 
 static void fill_all_stream_timings(AVFormatContext *ic)
-- 
1.7.1.1




More information about the ffmpeg-devel mailing list