0

Why ffmpeg / ffprobe gives different bitrate values for the stream and for file as whole?

When I analyze an mp3 file with ffprobe, it gives different bitrates on first and second lines. Does anyone know, what is the difference?

// File 1, there is problem
Duration: 02:05:47.04, start: 0.000000, bitrate: 193 kb/s
Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp, 192 kb/s

// File 2, no problem
Duration: 02:05:51.05, start: 0.000000, bitrate: 192 kb/s
Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp, 192 kb/s

(I need to get correct information about files because I process these files for fingerprinting)

1 Answers1

0

If you want the actual bitrate of the audio stream, you'll need to parse it.

ffmpeg -i file -c copy -map 0:a -f null -

Note down the audio stream size on the last line, e.g. audio:8624kB and the duration on the line above it, e.g. time=00:03:43.16. Divide the first by the second to get the average bitrate of the stream.

If you want the notional bitrate i.e. the target set for the encoder, then it's the reading for the Stream.

The format bitrate i.e. the one next to start:, is crude, and simply divides the filesize by the duration. But this includes all streams and headers. Useful for a file with single video + single audio, but not for others.

Gyan
  • 85,394
  • 9
  • 169
  • 201