Show duration for large asf files as written in the file header.
authorCarl Eugen Hoyos <cehoyos@ag.or.at>
Sat, 21 Jun 2014 17:35:06 +0000 (19:35 +0200)
committerCarl Eugen Hoyos <cehoyos@ag.or.at>
Sat, 21 Jun 2014 21:08:55 +0000 (23:08 +0200)
Fixes ticket #3428.
(cherry picked from commit e3fd263f0b73e4425192d6dd1ab18027ecaa35db)

libavformat/asfdec.c

index de42b45..7c7105a 100644 (file)
@@ -378,7 +378,8 @@ static int asf_read_stream_properties(AVFormatContext *s, int64_t size)
 
     if (!(asf->hdr.flags & 0x01)) { // if we aren't streaming...
         int64_t fsize = avio_size(pb);
-        if (fsize <= 0 || (int64_t)asf->hdr.file_size <= 0 || FFABS(fsize - (int64_t)asf->hdr.file_size) < 10000)
+        if (fsize <= 0 || (int64_t)asf->hdr.file_size <= 0 ||
+            FFABS(fsize - (int64_t)asf->hdr.file_size) / (float)FFMIN(fsize, asf->hdr.file_size) < 0.05)
             st->duration = asf->hdr.play_time /
                        (10000000 / 1000) - start_time;
     }