MP3 -> how much are 320 kbps in bps?

Hello everybody.

I just decode mp3 files on an ESP32 (only the first frame / vbr frame) to calculate the information such as duration and average kbps etc.

In the vbr files (xing + vbri) I already have the correct calculation.

But with cbr files I still have a problem. I read, for example 320 kbps from the header. Since I save the value in a uint16_t, I do not calculate the bps but calculate ....
(file length / 1024) / (320/8)

File length is 7370235 byte.
So the result is 7197 / 40 = 179 (duration 2:59 min)

But two different Codecs on my PC (VLC + Video Editing) indicate the duration of 3:04 min.

So I checked the calculations again. If i calculate the following, then the duration coincides with the codecs:
(file length / 1000) / (320/8)
So the result is 7370 / 40 = 184 (duration 3:04 min) -> correct

So 320 kbps is not 40 kilo bytes per second? Do the kbps have to be converted with kilo or kibi? :confused:

"kbps" is kilo bits per second. 7,370,235 Bytes * 8 bits / Byte = 58,961,880 bits. 58,961,880 bits / 320 kbps = 58,961,880 bits / 320,000 bps = 184.26 s.

Kilo (k) just means 10³ in this case.

What does your program do when there's a variable bit rate?

Pieter

Ok, thank you first. So kbps is really KILO and not KIBI like filesize in kb!
For VBR files, I calculate "frames * 1152 / samplerate". So... total samples / samplerate

mp3AudioInfo-> totalAudioSeconds = (headerVbrFrameCount * 1152) / (float) mp3AudioInfo-> samplerate;

You helped me already.

In data comms we use powers of ten, in data storage powers of two. This is because crystal
frequencies and baudrates and suchlike have nothing to do with binary representation (1 baud
is one symbol/second, not bit/second, for instance.