PR #26033 opened by Baptiste Coudurier (bcoudurier) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26033 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26033.patch
The file in #22532 has a version 0 mdhd duration of 0x80000000 on both tracks (an overflowed 32-bit value), so the 18:38:10 file is reported as 12:25:39. Treat that value as unknown, like UINT32_MAX, and use the stts duration when mdhd gives none. This also gives a duration to non-fragmented files whose mdhd duration is 0 or UINT32_MAX; they are reported as N/A today. An mdhd shorter than stts still wins as before. Tested with synthetic files (with and without edit lists) carrying mdhd durations of 0x80000000, 0, UINT32_MAX and a valid shorter value. FATE passes. Fixes: #22532 🤖 Generated with [Claude Code](https://claude.com/claude-code) From e888706c1533268431abb286c8848aa9b2a0a029 Mon Sep 17 00:00:00 2001 From: Baptiste Coudurier <[email protected]> Date: Fri, 13 Nov 2026 13:43:55 -0800 Subject: [PATCH] avformat/mov: use the stts duration when mdhd has none Treat a version 0 mdhd duration of 0x80000000 as unknown, like UINT32_MAX. Fixes: #22532 Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Baptiste Coudurier <[email protected]> --- libavformat/mov.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index ca33cb2285b..4e534be9dbd 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -2050,7 +2050,8 @@ static int mov_read_mdhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) st->duration = (version == 1) ? avio_rb64(pb) : avio_rb32(pb); /* duration */ if ((version == 1 && st->duration == UINT64_MAX) || - (version != 1 && st->duration == UINT32_MAX)) { + (version != 1 && st->duration == UINT32_MAX) || + (version != 1 && st->duration == 0x80000000)) { st->duration = 0; } @@ -3939,7 +3940,7 @@ 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); + st->duration = st->duration ? FFMIN(st->duration, 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.54.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
