How to know the byte offset of a specific CBR MP3 frame?

158 Views Asked by At

I created my own MP3 frame parser. I can read each frame individually if I do it sequentially.

My problem is that I have yet to figure out how to find the byte offset of the nth frame (without having to read all the prior frames).

CBR makes this process easier, but I still don't know how the padding bit factors in.

For example, take a file that has the following info:

Total file length:  4916595

===== ID3 METADATA =====
ID3v2 header length:  143

===== MP3 FRAMES =====
Version: MPEG Version 1
Layer: Layer III
Error protection: No
Bitrate: 192
Frequency: 44.1

Some frames have a byte length of 626 and other frames have a length of 627.

Let's say I want to find the 100th frame, I can't simply do 100 * 626, nor can I do 100 * 627.

How should I factor in the padding bit in my formula to find nth frame's byte offfset?

1

There are 1 best solutions below

1
On

Probably MP3val solves your problem. Once installed, run:

mp3val -f file.mp3