Audacity adds a gap when exporting mp3

7

2

I created a loop Audacity which was 10.549s long, I exported it to mp3, now when I open the exported file via Audacity it now has a gap at the beginning making it 10.58s long. The loop I made that sounded perfectly inside Audacity becomes an imperfect loop when exported to mp3. Any ideas how to fix this?

IMB

Posted 2015-07-10T08:15:58.320

Reputation: 4 845

I'd try export as WAV & see what happens. Will maybe eliminate whether it's the app itself or the export/conversion process. – Tetsujin – 2015-07-10T08:19:35.783

@Tetsujin there is no problem with WAV export but I need the file as mp3. Apparently, I tried converting wav to mp3 using another tool but the gap is still there. The issue is probably with LAME converter. – IMB – 2015-07-10T08:25:34.823

if you convert the mp3 back to wav is the gap still there? What happens if you use a different converter? – Tetsujin – 2015-07-10T08:32:52.593

Answers

7

Problem: MP3 File has a gap

This is a known, acknowledged issue since at least 2000:

1 Why is a decoded MP3 longer than the original .wav file?

Because LAME (and all other MDCT based encoders) add padding to the beginning and end of each song. For an explination of why, see the questions below.

800 word long technical explanation pertaining to both decoder and encoder issues snipped.

LAME-enabled players should apparently automatically jump this gap:

LAME embeds the amount of padding in the ancillary data of the first frame of the MP3 file. (LAME INFO tag). The LAME decoder will use this information to remove the leading padding of an MP3 file.

however:

Modifications to the decoder so that it will also remove the trailing padding have not yet been made.

Alternatives

You could try another encoder as mentioned, if you have access to the Fraunhofer version (IIRC it is available in iTunes and Windows Media Player). Alternatively, you may be able to compile/acquire a version of sox with libmad enabled. I think these will have similar issues, however.

The question is, do you definitely need an MP3 as mentioned in the comments? Are you using a player that only handles MP3s?

If it absolutely, definitely, positively has to be an MP3, no ifs ands or buts; and the Fraunhofer encoder also gives the same issue, you could have a look at a previous thread here on SU:

Best program to trim silence beginning and end of mp3 files?

bertieb

Posted 2015-07-10T08:15:58.320

Reputation: 6 181

Is there any update to this? Does the official lame decoder still not remove the trailing padding? If so, I assume this problem translates to all other software that decodes mp3s (eg, Chrome and web audio api)? – V. Rubinetti – 2018-09-23T06:07:55.213