.mp3 Files Expanding When Imported

Since upgrading to v.3.3.3 I find that if I import .mp3 files of exactly 1 hour length to an empty grid they expand by 0.039 seconds, which did not happen in v.3.3.2. It’s easy to correct the length with Change Tempo but it’s a step I’d rather not have to do. Has anyone experienced this?

It’s normal with MP3.

MP3 is lossy compression… Some things are changed…


You are quite correct that some earlier versions of Audacity retained the exact length of MP3 files.

The short version: It’s a bug LAME "--nogap" metadata is ignored · Issue #3778 · audacity/audacity · GitHub

The longer version:
DVDdoug is quite correct that it is “normal” for MP3 to be slightly longer than the original audio. This is because the MP3 format does not specify what should happen with the initial and final data frames. This causes MP3s to have a bit of leading silence at the start, and a bit of trailing silence at the end.

Note that to correct this limitation, leading / trailing silence should be trimmed off. The actual audio will be the correct length, so you should not stretch it with Change Speed or Change Tempo.

Fortunately, the LAME encoder library added a nice little trick to combat this limitation of the MP3 format. When encoding, it can calculate the exact amount of padding that is added (it varies every time), and it writes a bit of metadata to the file called the “–no-gap” tag. This allows applications that import MP3s to automatically trim off the exact amount of padding from the start and end of the file.

Audacity previously added the “–no-gap” tag when writing an MP3, and read the “–no-gap” tag when importing an MP3. This allowed Audacity to do the round trip of “Export → MP3 → Import” and retain the correct length.

Unfortunately, about a year ago, a bug in Audacity stopped the import trimming working. Audacity still writes the “–no-gap” tag (via the LAME library), but it ignores the tag when importing, so you will get a bit of padding at the start / end of the track when importing an MP3 into recent versions of Audacity.

Many thanks for the explanation, Steve. It’s puzzled me since v.3.3.3 came out. I’ve been adjusting with Change Tempo (which still leaves a few ms.) but I’ll correct as you suggest until it’s resolved.

Some good news. In the last 10 minutes, one of the Audacity developers committed a fix for this bug (Fixes importing MP3 files with gaps by crsib · Pull Request #5017 · audacity/audacity · GitHub)
The next Audacity release should import MP3s at the correct length :slight_smile:

Very much appreciated!

Less than a second correction in an hour long show is best done by change speed. Change tempo seems like the ideal solution, but it adds digital artifacts. Change speed corrects the runtime without digital artifacts.
The <1:3600 change in pitch caused by changing the speed will be imperceptible.

Thanks Trebor. I apply Change Tempo so the pitch is maintained, also because you can specify the required length. The impression I get from Change Speed is the required length is a matter of trial and error. The smallest Percent Change is 0.001, which is far more than I want to apply - or am I missing something?

The Change Speed effect “should” be capable of stretching to an exact length by using the time controls (I spent a fair bit of effort coding that to work properly), but unfortunately that’s another thing that is now a bit broken.

It’s not really relevant in this case, because you should be just trimming the padding from the ends rather than stretching the track.

Many thanks DVDdoug, steve and Trebor. I’m grateful for your input and pleased the issue should be fixed in the next release. :grinning:

This topic was automatically closed after 30 days. New replies are no longer allowed.