From 5f692f18d6ff63418c0a48a7e0162ccc8dbcd8d8 Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Fri, 2 Sep 2022 09:36:06 -0500 Subject: [PATCH] Protect video_length from being overwritten if CheckFPS overwrites it first --- src/FFmpegReader.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/FFmpegReader.cpp b/src/FFmpegReader.cpp index 78f1a232..21479798 100644 --- a/src/FFmpegReader.cpp +++ b/src/FFmpegReader.cpp @@ -822,7 +822,8 @@ void FFmpegReader::UpdateVideoInfo() { } // Get the # of video frames (if found in stream) - if (pStream->nb_frames > 0) { + // Only set this 1 time (this method can be called multiple times) + if (pStream->nb_frames > 0 && info.video_length <= 0) { info.video_length = pStream->nb_frames; } @@ -837,6 +838,7 @@ void FFmpegReader::UpdateVideoInfo() { is_duration_known = true; // Calculate number of frames (if not already found in metadata) + // Only set this 1 time (this method can be called multiple times) if (info.video_length <= 0) { info.video_length = round(info.duration * info.fps.ToDouble()); }