From: James Almer <jamrial@gmail.com> To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH] avformat/mov: don't use stream duration to calculate bitrate with fragmented input Date: Tue, 30 Apr 2024 23:08:46 -0300 Message-ID: <20240501020847.2641-1-jamrial@gmail.com> (raw) sc->data_size may contain the size of a single fragment after probing, and using it alongside the duration of the entire stream to calculate bitrate will result in a bogus small value. Before: Duration: 00:00:05.00, start: 0.000000, bitrate: 586 kb/s Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 640x360 [SAR 1:1 DAR 16:9], 112 kb/s, 60 fps, 60 tbr, 15360 tbn (default) After: Duration: 00:00:05.00, start: 0.000000, bitrate: 586 kb/s Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 640x360 [SAR 1:1 DAR 16:9], 561 kb/s, 60 fps, 60 tbr, 15360 tbn (default) Signed-off-by: James Almer <jamrial@gmail.com> --- libavformat/mov.c | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index e8da6c2d65..b3fa748f27 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -9667,25 +9667,7 @@ static int mov_read_header(AVFormatContext *s) } } - if (mov->trex_data) { - for (i = 0; i < s->nb_streams; i++) { - AVStream *st = s->streams[i]; - MOVStreamContext *sc = st->priv_data; - if (st->duration > 0) { - /* Akin to sc->data_size * 8 * sc->time_scale / st->duration but accounting for overflows. */ - st->codecpar->bit_rate = av_rescale(sc->data_size, ((int64_t) sc->time_scale) * 8, st->duration); - if (st->codecpar->bit_rate == INT64_MIN) { - av_log(s, AV_LOG_WARNING, "Overflow during bit rate calculation %"PRId64" * 8 * %d\n", - sc->data_size, sc->time_scale); - st->codecpar->bit_rate = 0; - if (s->error_recognition & AV_EF_EXPLODE) - return AVERROR_INVALIDDATA; - } - } - } - } - - if (mov->use_mfra_for > 0) { + if (mov->trex_data || mov->use_mfra_for > 0) { for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; MOVStreamContext *sc = st->priv_data; -- 2.44.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
reply other threads:[~2024-05-01 2:09 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20240501020847.2641-1-jamrial@gmail.com \ --to=jamrial@gmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git