[FFmpeg-devel] [PATCH] avformat/mov: Do not hard fail if bit rate calculation overflows unless in explode mode

Derek Buitenhuis derek.buitenhuis at gmail.com
Tue Oct 12 18:17:31 EEST 2021

On 10/12/2021 3:43 PM, Michael Niedermayer wrote:
> this should be using av_rescale() i think

That seems unrelated to this patch - but I can send a second patch
that does that, if you want.

Is your intent something like this;

    if (sc->data_size > INT64_MAX / 8) {
        av_log(s, AV_LOG_WARNING, "Overflow during bit rate calculation %"PRId64" * 8 > INT64_MAX\n",
        if (s->error_recognition & AV_EF_EXPLODE)
            return AVERROR_INVALIDDATA;
    } else
        st->codecpar->bit_rate = av_rescale(sc->data_size * 8, c->time_scale, st->duration);

- Derek

More information about the ffmpeg-devel mailing list