A little late, but if someone else needs it ...
This CodeProject article has a lot of good education about the MP3 header.
- Find the starting position of the XING header.
- The 8th byte is an integer of
total frames (if 4 bytes exist, the big end).
Each MPEG frame gives a constant number of samples per frame, determined by the sampling rate, regardless of the total number of bytes in the frame. You can evaluate using calculation, for example:
durationVBR = single_frame_time * total_frames;
Where...
single_frame_time = (SampleRate / SamplesPerFrame) * 1000;
Constants for SamplesPerFrame :
MPEG-1
- Layer i = 384 samples.
- Layer II = 1152 samples.
- Layer III = 1152 samples.
MPEG-2
- Layer i = 384 samples.
- Layer II = 1152 samples.
- Layer III = 576 samples.
source share