ffmpeg.c: fix calculation of input file duration in seek_to_start()
authorPeter Große <pegro@friiks.de>
Sun, 29 Oct 2017 11:08:05 +0000 (12:08 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Sun, 5 Nov 2017 02:14:29 +0000 (03:14 +0100)
Fixes looping files without audio or when using stream_copy, where
ist->nb_samples is not set since no decoding is done.

This fixes ticket #5719 and also fixes an endless loop with the sample
in ticket #6139.

Signed-off-by: Peter Große <pegro@friiks.de>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
fftools/ffmpeg.c

index 286d898..65dbe93 100644 (file)
@@ -4150,9 +4150,9 @@ static int seek_to_start(InputFile *ifile, AVFormatContext *is)
                 continue;
         } else {
             if (ist->framerate.num) {
-                duration = av_rescale_q(1, ist->framerate, ist->st->time_base);
+                duration = av_rescale_q(1, av_inv_q(ist->framerate), ist->st->time_base);
             } else if (ist->st->avg_frame_rate.num) {
-                duration = av_rescale_q(1, ist->st->avg_frame_rate, ist->st->time_base);
+                duration = av_rescale_q(1, av_inv_q(ist->st->avg_frame_rate), ist->st->time_base);
             } else duration = 1;
         }
         if (!ifile->duration)