[PR] avformat/mov: don't overwrite stream duration with stts values (PR #23674)

James Almer via ffmpeg-devel <[email protected]>
Newsgroups gmane.comp.video.ffmpeg.devel
Message-ID <178291994152.59.1599392103806112220@29965ddac10e>
PR #23674 opened by James Almer (jamrial)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23674
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23674.patch

The mdhd box duration value takes precedence, and the sum of all stts durations is not valid on video tracks with B frames.

Fixes issue #23670


>From 1fffd7f172bdea994a7b6f139ea0e67c44e19870 Mon Sep 17 00:00:00 2001
From: James Almer <[email protected]>
Date: Wed, 1 Jul 2026 12:27:42 -0300
Subject: [PATCH] avformat/mov: don't overwrite stream duration with stts
 values

The mdhd box duration value takes precedence, and the sum of all stts durations is
not valid on video tracks with B frames.

Fixes issue #23670

Signed-off-by: James Almer <[email protected]>
---
 libavformat/mov.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 90b01f9499..313614025c 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -3768,8 +3768,8 @@ static int mov_read_stts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     }
 
     st->nb_frames= total_sample_count;
-    if (duration)
-        st->duration= FFMIN(st->duration, duration);
+    if (!st->duration)
+        st->duration = duration;
 
     // All samples have zero duration. They have higher chance be chose by
     // mov_find_next_sample, which leads to seek again and again.
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.