Help - Search - Members - Calendar
Full Version: Synchronizing an MP3
Hydrogenaudio Forums > Hydrogenaudio Forum > Uploads
Sebastian Mares
Hello!

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:
  1. Look for a frame header (0xFF 0xF?).
  2. 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
  3. Search for a valid frame header after the current frame.
  4. If a frame was found, quit the function
  5. If a frame wasn't found, look for the next frame CURRENT POSITION + FRAME SIZE
Any help would be appreciated.

Sebastian Mares
Sebastian Mares
OK, the error is here:

QUOTE
If a frame wasn't found, look for the next frame CURRENT POSITION + FRAME SIZE


If the thing we found isn't really a frame, the frame size information will be wrong. I changed it to CURRENT POSITION + 1 (to look on byte after another), but can't the number (1) be greater (4, for example)? That would accelerate the seeking. The buffer I use for reading has 4 bytes.

In VB (I know, I know...) it looks like this:

Get #intFileNumber, lngCurrentPosition + 1, abytBuffer

abytBuffer is a byte array with 4 items (0 - 3).
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.