Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Calculating frame sizes (Read 2614 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Calculating frame sizes

I'm trying to calculate the frame size of an MP3 frame using this formula that I found here.

The formula is:
Code: [Select]
FrameLengthInBytes = 144 * BitRate / SampleRate + Padding
When inserting values I get:
Code: [Select]
144 * 128000 / 44100 + 0 = 417,95918367346938775510204081633
I was expecting a whole number. The result is very close to 418, but not quite there. Is the formula wrong? Should I Int() the number, or Round() it?

Calculating frame sizes

Reply #1
You should always Trunc() or Int() it.

From the link you mentioned:

Quote
Example:
Layer III, BitRate=128000, SampleRate=441000, Padding=0
      ==>  FrameSize=417 bytes


So if Padding=1 the frame would be 418 bytes.