Without this we get a bogus bitrate whenever we rely on mfra With this patch we could potentially drop -use_mfra_for
/Tomas
From 7484bb3b83e23b152e1cabb7b00bdceff0a217e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= <g...@haerdin.se> Date: Mon, 16 Dec 2024 16:15:10 +0100 Subject: [PATCH 4/6] lavf/mov: Do not set bit_rate unless all fragment headers have been read --- libavformat/mov.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 58481747e4..7ab4a4b233 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -10521,7 +10521,7 @@ static int mov_read_header(AVFormatContext *s) AVIOContext *pb = s->pb; int j, err; MOVAtom atom = { AV_RL32("root") }; - int i; + int i, all_headers_read; if (mov->decryption_key_len != 0 && mov->decryption_key_len != AES_CTR_KEY_SIZE) { av_log(s, AV_LOG_ERROR, "Invalid decryption key len %d expected %d\n", @@ -10651,7 +10651,17 @@ static int mov_read_header(AVFormatContext *s) } } - if (mov->trex_data || mov->use_mfra_for > 0) { + // if we have fragments, check that all of them have been parsed, especially trun + // if not then sc->data_size will be incorrect and therefore bit_rate + all_headers_read = 1; + for (i = 0; i < mov->frag_index.nb_items; i++) { + if (!mov->frag_index.item[i].headers_read) { + all_headers_read = 0; + break; + } + } + + if ((mov->trex_data || mov->use_mfra_for > 0) && all_headers_read) { for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; MOVStreamContext *sc = st->priv_data; -- 2.39.2
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".