From 8903205dd9df71ee15df5d24f3e578245a7ccabb Mon Sep 17 00:00:00 2001 From: Aras Pranckevicius Date: Thu, 15 Aug 2024 15:47:01 +0200 Subject: [PATCH] Fix: incorrect ffmpeg video length estimation logic 71f2229b0 added a workaround for video files that contain entirely incorrect stream duration, and corrects that by using container duration instead. However it used math of `seconds=frames*rate` instead `seconds=frames/rate`, effectively always ending up falling back to container instead of stream duration. Pull Request: https://projects.blender.org/blender/blender/pulls/126368 --- source/blender/imbuf/intern/anim_movie.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/imbuf/intern/anim_movie.cc b/source/blender/imbuf/intern/anim_movie.cc index f69c717b561..13e372d4a72 100644 --- a/source/blender/imbuf/intern/anim_movie.cc +++ b/source/blender/imbuf/intern/anim_movie.cc @@ -270,7 +270,7 @@ static int startffmpeg(ImBufAnim *anim) /* Sanity check on the detected duration. This is to work around corruption like reported in * #68091. */ if (frame_rate.den != 0 && pFormatCtx->duration > 0) { - double stream_sec = anim->duration_in_frames * av_q2d(frame_rate); + double stream_sec = anim->duration_in_frames / av_q2d(frame_rate); double container_sec = pFormatCtx->duration / double(AV_TIME_BASE); if (stream_sec > 4.0 * container_sec) { /* The stream is significantly longer than the container duration, which is