[FFmpeg-devel] [PATCH] ffmpeg.c: fix calculation of input file duration in seek_to_start()

Peter Große pegro at friiks.de
Sun Oct 29 13:08:05 EET 2017


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 at friiks.de>
---
 fftools/ffmpeg.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index cabc6864e7..17b594bac8 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -4144,9 +4144,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)
-- 
2.13.6



More information about the ffmpeg-devel mailing list