I have attached an MP3 file which has several errors. MP3Tag and Winamp will rely on the first frame header and will therefore report wrong information.
The first position, which looks like a valid MPEG frame is 735 (0x02DF). EncSpot found the first frame at 1013 (0x03F5).
Peter (or any other Guru around here), could you tell me at which frame the real MP3 begins? How should I synchronize? I tried setting my code to look for 2 valid frames without trash between them, but that returned byte offset 26092 (0x65EC). This is how I look for a frame:
- Look for a frame header (0xFF 0xF?).
- Calculate the frame size using Coefficient * Bitrate * 1000 / Sampling Rate + Padding.
Coefficient:
48 for MPEG 1 Layer 1
144 for MPEG 1 Layer 2 and 3
24 for MPEG 2 Layer 1
144 for MPEG 2 Layer 2
72 for MPEG 2 Layer 3
Padding:
1 if Padding was used
0 if Padding was not used - Search for a valid frame header after the current frame.
- If a frame was found, quit the function
- If a frame wasn't found, look for the next frame CURRENT POSITION + FRAME SIZE
Sebastian Mares