[FFmpeg-user] Can ffmpeg calculate the min and max bitrate of a video?

Nicolas George george at nsup.org
Wed May 4 10:29:43 EEST 2022


smu johnson (12022-05-03):
> ffprobe / ffmpeg can show a video's avg. bitrate easily enough but I would
> like the option for ffmpeg to scan an entire video file (if need be, I
> don't think this info is stored anywhere) to find out the lowest (min)
> bitrate of a video stream as well as the highest (max) bitrate it uses and
> print them.

ffprobe can print for you the size and timestamp of each packet. From
that, you can compute what you want.

Note that since the video is made of frames encoded as packets, a
discrete series, there is no such thing as an instantaneous bit rate in
which you can search a min and max: instantaneous bit rate is a
derivative, derivatives are continuous beings.

What exists is the average bit rate over a short period, the shortest
being the duration of a single frame, and the corresponding bit rate the
size of the corresponding packet divided by said duration. But that
would be full of noise. For a less noisy and more relevant information,
you would need to make an average over an interval containing at least
one I-frame.

The last two paragraphs were not about FFmpeg, they were math. I am not
on this mailing list to teach math.

> This has been asked on Stack Exchange before by someone else here:
> https://video.stackexchange.com/questions/21661/is-there-any-ffmpeg-command-for-knowing-max-bit-rate-of-a-video
> .  The only problem is people are suggesting running scripts and other
> hacks in order to do this instead of ffmpeg being able to just do it itself.

And they are perfectly right. For specific and unique needs, scripting
your own solution is infinitely superior to knocking on wood in the hope
somebody already implemented exactly what you want.

> I'm on Windows 11 so I don't know how easy it would be to run these scripts

You can find a solution to this issue there:
https://www.debian.org/

> others wrote and I'd rather get an official answer from ffmpeg instead of
> some script that might not even work properly or give me accurate
> information.

I hope it is clear for you: you should not run a script you found on a
random web site, it would be a huge security risk. You need to
understand the script and adapt it to your needs.

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-user/attachments/20220504/3e54f290/attachment.sig>


More information about the ffmpeg-user mailing list