I wrote a simple tool to do this, called ffmpeg-bitrate-stats
. It requires Python and ffmpeg
installed. Install it via pip
:
pip3 install --user ffmpeg-bitrate-stats
Then run it on a file:
ffmpeg_bitrate_stats /path/to/file.mp4
It will output a valid JSON object containing summary statistics like the maximum bitrate:
{
"input_file": "file.mp4",
"stream_type": "video",
"avg_fps": 23.976,
"num_frames": 150802,
"avg_bitrate": 2249.534,
"avg_bitrate_over_chunks": 2244.912,
"max_bitrate": 2993.706,
"min_bitrate": 1865.406,
"max_bitrate_factor": 1.331,
"bitrate_per_chunk": [
2433.07,
2329.958,
2171.362,
2227.863,
2470.798,
1978.106,
2089.184,
2993.706,
1988.095,
1865.406,
2146.482
],
"aggregation": "time",
"chunk_size": 600.0,
"duration": 6289.65
}
The maximum bitrate in the above file would be roughly 3000 kBit/s (max_bitrate
). It is 1.3⨉ as much as the average bitrate (max_bitrate_factor
).
Note that the meaning of maximum bitrate depends on the time frame over which it is calculated. You can calculate the bitrate every second (the default in my tool), or choose a different chunk size with the -c
parameter. This means you'll get "smoothed" estimates, for instance when you set -c 10
, it only looks at 10 second chunks of video, and picks the maximum based on that.
To just obtain that value, you can use jq
:
ffmpeg_bitrate_stats /path/to/file.mp4 -c 600 | jq -r '.max_bitrate'