avconv.c: fix calculation of input file duration in seek_to_start()
authorPeter Große <pegro@friiks.de>
Mon, 30 Oct 2017 11:25:26 +0000 (12:25 +0100)
committerDiego Biurrun <diego@biurrun.de>
Sat, 4 Nov 2017 16:58:47 +0000 (17:58 +0100)
Fixes looping files without audio or when using stream_copy, where
ist->nb_samples is not set since no decoding is done.

Signed-off-by: Diego Biurrun <diego@biurrun.de>
avtools/avconv.c

index 4e3ffec..cee7a7b 100644 (file)
@@ -2553,9 +2553,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 = FFMAX(av_rescale_q(1, av_inv_q(ist->framerate), ist->st->time_base), 1);
             } else if (ist->st->avg_frame_rate.num) {
-                duration = av_rescale_q(1, ist->st->avg_frame_rate, ist->st->time_base);
+                duration = FFMAX(av_rescale_q(1, av_inv_q(ist->st->avg_frame_rate), ist->st->time_base), 1);
             } else duration = 1;
         }
         if (!ifile->duration)