ffmpegx264libx264

How is the FFMPEG x264 result bitrate calculated?


When encoding in x264 (libx264) there is a listing at the end showing different encoding stats. I noticed that the Bitrate is too high. I was wondering how this can be.

Here is an example:

frame=177719 fps= 24 q=-1.0 Lsize= 4768888kB time=02:03:35.74 bitrate=5268.1kbits/s dup=0 drop=43 speed=1.01x
video:4186558kB audio:579355kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.062419%

From the first two result lines I can grab the stream size and stream duration. From that i can calculate the overall bitrate

(4186558 * 8) / 7415.744 = 4516.39970311812

However the last FFMPEG output shows an additional 108.4kb/s:

[libx264 @ 0000026e1011f440] kb/s:4624.79

When I use MediaInfo to get the stream size and stream duration it's also a little different.

(4192906.438 * 8) / 7415.742 = 4523.24952836817

The manual calculations from FFMPEG and MediaInfo are close enough and not significantly different however where are the 100kb/s+ from FFMPEG results coming from?

Edit:

I just found out that using --parsespeed=1 in MediaInfo CLI will give more accurate results for Variable Bitrates. Default is 0.5.


Solution

  • FFmpeg's video:4186558kB is really in KiB i.e.:

    4186558 KiB * 1024 * 8 = 34296283136 bits
    34296283136 bits / 7415.744 seconds = 4624793.296 b/s / 1000 = 4624.79 kb/s