<p>See <a href="https://github.com/zeroepoch/plotbitrate" rel="nofollow noreferrer">https://github.com/zeroepoch/plotbitrate</a></p>
<p>It uses <code>ffprobe</code> under the hood and can output an xml file. Here's an example output.svg:</p>
<p><a href="https://i.sstatic.net/ugIED.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ugIED.png" alt="enter image description here" /></a></p>
<p>(Although it is slow - almost as slow as transcoding, because it scans the whole video.)</p>

CC BY-SA 4.0
2021-12-30T05:34:06.697Z
2021-12-30T16:23:13.840Z
2021-12-30T16:23:13.840Z
Jeff Ward
<p>I wrote a simple tool to do this, called <a href="https://github.com/slhck/ffmpeg-bitrate-stats" rel="nofollow noreferrer"><code>ffmpeg-bitrate-stats</code></a>. It requires Python and <code>ffmpeg</code> installed. Install it via <code>pip</code>:</p>
<pre><code>pip3 install --user ffmpeg-bitrate-stats
</code></pre>
<p>Then run it on a file:</p>
<pre><code>ffmpeg_bitrate_stats /path/to/file.mp4
</code></pre>
<p>It will output a valid JSON object containing summary statistics like the maximum bitrate:</p>
<pre class="lang-json prettyprint-override"><code>{
    &quot;input_file&quot;: &quot;file.mp4&quot;,
    &quot;stream_type&quot;: &quot;video&quot;,
    &quot;avg_fps&quot;: 23.976,
    &quot;num_frames&quot;: 150802,
    &quot;avg_bitrate&quot;: 2249.534,
    &quot;avg_bitrate_over_chunks&quot;: 2244.912,
    &quot;max_bitrate&quot;: 2993.706,
    &quot;min_bitrate&quot;: 1865.406,
    &quot;max_bitrate_factor&quot;: 1.331,
    &quot;bitrate_per_chunk&quot;: [
        2433.07,
        2329.958,
        2171.362,
        2227.863,
        2470.798,
        1978.106,
        2089.184,
        2993.706,
        1988.095,
        1865.406,
        2146.482
    ],
    &quot;aggregation&quot;: &quot;time&quot;,
    &quot;chunk_size&quot;: 600.0,
    &quot;duration&quot;: 6289.65
}
</code></pre>
<p>The maximum bitrate in the above file would be roughly 3000 kBit/s (<code>max_bitrate</code>). It is 1.3⨉ as much as the average bitrate (<code>max_bitrate_factor</code>).</p>
<p>Note that the meaning of <em>maximum bitrate</em> 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 <code>-c</code> parameter. This means you'll get &quot;smoothed&quot; estimates, for instance when you set <code>-c 10</code>, it only looks at 10 second chunks of video, and picks the maximum based on that.</p>
<p>To just obtain that value, you can use <code>jq</code>:</p>
<pre><code>ffmpeg_bitrate_stats /path/to/file.mp4 -c 600 | jq -r '.max_bitrate'
</code></pre>

CC BY-SA 4.0
2024-10-06T19:55:00.997Z
this is awesome! Yes it's using a separate tool, but it's very quick and should be the accepted answer!
memo
CC BY-SA 4.0
2022-01-30T19:13:09.750Z
2022-05-06T07:41:02.410Z
2022-05-06T07:41:02.410Z
slhck
<p>That <code>max_bit_rate</code> is a a tag written by some encoders, when set by the user in the export dialog box. It is not an indication of the maximum bitrate found if you were to survey the encoded bitstream.</p>

<hr>

<p>It's possible to get a good idea of the maximum bitrate of a stream this way:</p>

<pre><code>ffmpeg -i in.mp4 -map 0:v -c copy
       -f segment -segment_time 1 -break_non_keyframes 1 folder\seg%d.264
</code></pre>

<p>This will break up the video stream into 1 second segments. Sort the directory listing by size to find out the largest file. That's your maximum bitrate. Not totally accurate as it's not a rolling survey but should be close enough.</p>

CC BY-SA 3.0
2017-06-14T01:39:30.527Z
I see, so is there any way to know the 'real' `max_bit_rate`? I need to know the value so that I can choose a suitable parameter for `libx264`
shintaroid
CC BY-SA 3.0
2017-06-14T04:25:55.917Z
Possible, but it requires some work.
Gyan
CC BY-SA 3.0
2017-06-14T08:53:54.957Z
Great, thanks! Now I learned another ffmpeg trick!
shintaroid
CC BY-SA 3.0
2017-06-13T10:33:45.557Z
2017-06-14T04:31:04.840Z
2017-06-14T04:31:04.840Z
Gyan
<p>I have an <code>MP4</code> file <code>input.mp4</code> which is encoded in <code>libx264</code>. By <code>ffprobe</code> command:</p>

<pre><code>ffprobe -v error -show_streams input.mp4
</code></pre>

<p>I can know the bit rate of <code>input.mp4</code>, but it does not give the information of <code>max bit rate</code> (<code>max_bit_rate=N/A</code> ).</p>

<p>Is there any <code>ffmpeg</code> (<code>ffprobe</code>) command for getting <code>max bit rate</code> of a video?</p>

<ffmpeg><bitrate>
Is there any ffmpeg command for knowing max bit rate of a video?
shintaroid
# Is there any ffmpeg command for knowing max bit rate of a video?

(Asked by: username_0 on 2017-06-13)

I have an MP4 file input.mp4 which is encoded in libx264. By ffprobe command:
ffprobe -v error -show_streams input.mp4

I can know the bit rate of input.mp4, but it does not give the information of max bit rate (max_bit_rate=N/A ).
Is there any ffmpeg (ffprobe) command for getting max bit rate of a video?

**Tags:** ffmpeg, bitrate


---

## 3 answers

### Answer by username_4 on 2017-06-13. Score: 7 | Accepted answer

That max_bit_rate is a a tag written by some encoders, when set by the user in the export dialog box. It is not an indication of the maximum bitrate found if you were to survey the encoded bitstream.

It's possible to get a good idea of the maximum bitrate of a stream this way:
ffmpeg -i in.mp4 -map 0:v -c copy
       -f segment -segment_time 1 -break_non_keyframes 1 folder\seg%d.264

This will break up the video stream into 1 second segments. Sort the directory listing by size to find out the largest file. That's your maximum bitrate. Not totally accurate as it's not a rolling survey but should be close enough.

> **Comments:**
> **username_0**: I see, so is there any way to know the 'real' `max_bit_rate`? I need to know the value so that I can choose a suitable parameter for `libx264`  
> **username_4**: Possible, but it requires some work.  
> **username_0**: Great, thanks! Now I learned another ffmpeg trick!  

---

### Answer by username_1 on 2021-12-30. Score: 2

See <https://github.com/zeroepoch/plotbitrate>

It uses `ffprobe` under the hood and can output an xml file. Here's an example output.svg:

[![enter image description here](https://i.sstatic.net/ugIED.png)](https://i.sstatic.net/ugIED.png)

(Although it is slow - almost as slow as transcoding, because it scans the whole video.)


---

### Answer by username_2 on 2022-01-30. Score: 2

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'

> **Comments:**
> **username_3**: this is awesome! Yes it's using a separate tool, but it's very quick and should be the accepted answer!  

---

