Commit 166b8be618 for ffmpeg
commit 166b8be618639ca2ff2b9f34450652d6d932db82
Author: Baptiste Coudurier <baptiste.coudurier@gmail.com>
Date: Fri Nov 13 13:43:55 2026 -0800
avformat/mov: prefer the stts duration over mdhd
The media duration can't be shorter than the sample table, so use the
stts sum. This also covers a clipped or missing mdhd duration.
Fixes: #22532
Signed-off-by: Baptiste Coudurier <baptiste.coudurier@gmail.com>
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 3fe0304f4d..9ad780cde9 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -4044,8 +4044,10 @@ static int mov_read_stts(MOVContext *c, AVIOContext *pb, MOVAtom atom)
}
st->nb_frames= total_sample_count;
+ // The media duration can't be shorter than the sample table, so prefer
+ // the latter when they differ.
if (duration)
- st->duration= FFMIN(st->duration, 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.