#44 Make extant MP3 gapless without lossy reencoding?


I have some MP3 files that were either not encoded with LAME or were encoded without gapless options enabled. Is it technically possible for LAME to make these files gapless without lossily reencoding them? If so, is there currently a way for the user to do it?


  • Mike Brown
    Mike Brown

    There are two kinds of gapless MP3s. The kind produced by LAME's old gapless options is just a single stream chopped into sections on frame boundaries, and you (or the player) are supposed to concatenate them before or during playback. This technique was largely abandoned before it gained much traction. The other, currently popular kind is what LAME produces by default (no special options needed), where each file is a separately encoded stream, with metadata in it telling the player how many delay & padding samples to skip on each end to get the part of the stream that corresponds to the original sample set. This may not be perfectly seamless but is the definition of gapless that people generally want.

    If the encoder was LAME, the encoder delay is known, and for CD-sourced material (multiples of 588 samples), the padding can be guessed at, or even confirmed if you have access to the exact track length from the original CD. Otherwise, there's no way to know for sure. If the encoder is unknown, then not even the delay is certain. So I don't think there's really a way to do what you want automatically. Further reading: http://wiki.hydrogenaudio.org/index.php?title=Gapless_playback