PR #25127 opened by Baptiste Coudurier (bcoudurier) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25127 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25127.patch
A corrupt packet may hold only part of a frame, which skews the average frame rate estimated from the few probed packets. For example, a truncated MXF file whose last probed packet holds only one field of an interlaced frame is probed at 45/2 instead of 25/1 (together with #25126). 🤖 Generated with [Claude Code](https://claude.com/claude-code) From 7814d69ca4dceb3b5a182fd95b928438e0e75ca0 Mon Sep 17 00:00:00 2001 From: Baptiste Coudurier <[email protected]> Date: Fri, 16 Oct 2026 13:02:54 -0700 Subject: [PATCH] avformat/demux: ignore corrupt packets when estimating the frame rate A corrupt packet may hold only part of a frame, which skews the average frame rate estimated from the few probed packets. Co-Authored-By: Claude Opus 5.5 <[email protected]> --- libavformat/demux.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavformat/demux.c b/libavformat/demux.c index cfab580fb6..59e7c52864 100644 --- a/libavformat/demux.c +++ b/libavformat/demux.c @@ -2931,7 +2931,9 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) av_packet_unref(pkt1); break; } - if (pkt->duration > 0 && pkt->duration < INT64_MAX - sti->info->codec_info_duration) { + /* A corrupt packet may hold only part of a frame. */ + if (pkt->duration > 0 && pkt->duration < INT64_MAX - sti->info->codec_info_duration && + !(pkt->flags & AV_PKT_FLAG_CORRUPT)) { const int fields = sti->codec_desc && (sti->codec_desc->props & AV_CODEC_PROP_FIELDS); if (avctx->codec_type == AVMEDIA_TYPE_SUBTITLE && pkt->pts != AV_NOPTS_VALUE && st->start_time != AV_NOPTS_VALUE && pkt->pts >= st->start_time && (uint64_t)pkt->pts - st->start_time < INT64_MAX -- 2.54.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
