[FFmpeg-devel] [PATCH]Show duration written in file header for large asf files

Carl Eugen Hoyos cehoyos at ag.or.at
Sat Jun 21 18:40:43 CEST 2014


Hi!

asf duration set in the file header is currently not shown 
if the file is very large because as a validity check the absolute 
difference between actual file size and stream size in the header 
is used instead of a ratio.
Attached patch fixes ticket #3428 for me.

Please comment, Carl Eugen
-------------- next part --------------
diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c
index 03f4b20..7b4a0a5 100644
--- a/libavformat/asfdec.c
+++ b/libavformat/asfdec.c
@@ -372,7 +372,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;
     }


More information about the ffmpeg-devel mailing list