Back to the blog

A little know-how

Why a converted MP3 starts late, and ours does not.

MP3 and AAC encoders add a few hundredths of a second of silence to every file. Why it happens, when it matters (loops, albums, ringtones), and how files can say how long their sound really is.

By KeepSimp 4 min read

Two waveforms of the same sound, the upper one starting after a short flat line of silence, the lower one starting at once

Convert a WAV to MP3 and the MP3 is a little longer than the WAV: a few hundredths of a second of silence at the start, a little more at the end. Most of the time nobody notices. In a loop, between the tracks of a live album, or at the start of a ringtone, everyone does.

Where the gap comes from.

MP3 and AAC encoders work on blocks of samples that overlap. To start cleanly, they put a run of samples before the sound (the encoder delay, or priming), and to end on a whole block they pad the end. LAME, the MP3 encoder, puts 576 samples first, and every MP3 decoder adds 529 more; AAC encoders put 1,024 or 2,112. At 44.1 kHz that is 25 to 50 milliseconds of silence at the start.

How a file says how long its sound is.

An MP3 can carry the delay and the padding in a header in its first frame, the LAME header, which players such as iTunes, foobar2000 and FFmpeg read to play exactly the sound. An AAC file in MP4 or M4A says the same in an edit list: start after the priming, play this many samples.

Many converters leave both out. The KeepSimp Audio editor writes them into every MP3 and AAC file it makes. Because AAC encoders differ from browser to browser, it measures the priming of the one your browser has, with a short test before the first file, rather than assume it.

Checked, not hoped.

Each file written is opened again and decoded, its delay and padding left out as a player leaves them out, and its length is held against the original's. A file that comes out longer than it should is reported, not handed over in silence.

On your device.

Files are read and written in your browser and never uploaded. There is no account and no limit on how many you convert.

Further reading

Topics: MP3 silence at start · gapless MP3 · gapless playback · encoder delay · AAC priming · LAME header · audio converter gap

A little less theory. A little more doing.

Try it on your own terms, with a free browser tool.

Try the tool