avformat/utils: Exclude the header size when computing duration from bit_rate
authorHendrik Leppkes <h.leppkes@gmail.com>
Sat, 6 Sep 2014 12:59:23 +0000 (14:59 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Mon, 8 Sep 2014 03:22:05 +0000 (05:22 +0200)
This improves the estimate for MP3s with cover art tags.

Fixes Ticket2931

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavformat/utils.c

index 6e828f7ce9ed27537e7238d6b8cd4516d6e78aa0..d6e3e50d663a63d5dd06c5e160f2bc56adf5d652 100644 (file)
@@ -2287,7 +2287,8 @@ static void estimate_timings_from_bit_rate(AVFormatContext *ic)
     if (ic->duration == AV_NOPTS_VALUE &&
         ic->bit_rate != 0) {
         filesize = ic->pb ? avio_size(ic->pb) : 0;
-        if (filesize > 0) {
+        if (filesize > ic->data_offset) {
+            filesize -= ic->data_offset;
             for (i = 0; i < ic->nb_streams; i++) {
                 st      = ic->streams[i];
                 if (   st->time_base.num <= INT64_MAX / ic->bit_rate