[Ffmpeg-devel] Problems encoding mpeg layer 2 audio files.

Jyrki.Niemela at jutel.fi Jyrki.Niemela
Thu Jan 5 06:05:37 CET 2006

It seems there is a problem in the FFMPEG audio encoder when it is used 
for encoding layer 2 audio files.

If I have understood correctly, some of the MPEG frames in the resulting 
file end up longer than what the frame size calculated from the frame 
header suggests, and these are audible as glitches when the output file is 
played back.

This consists of three issues:

1) the above-mentioned extra data in at least one MPEG frame in the 
2) some extra bytes at the beginning of the output file before the first 
frame header (in case if this is relevant), and
3) the input file might be read incorrectly, so that some parts of the 
audio become repeated in the output, while others are omitted altogether. 
(I have to admit this one has happened on only one occasion, so I am not 
sure if it is an FFMPEG problem at all.)

The problems seem sensitive to the exact PCM input data used. I have 
tested a PCM wave file, which, when encoded by FFMPEG, produces the 
aforementioned glitch.

However, if this file is loaded into Audacity and re-exported in the exact 
same format, the resulting file does not produce the glitch when encoded 
by FFMPEG. The only difference between the two files is in the audio data, 
and by subtracting the audio in these files from each other (using invert 
and mix in Audacity), only very small numbers are produced, suggesting 
that the only difference is in rounding errors caused by the conversion 
first to Audacity's 32-bit float format and then back to 16-bit PCM.

Have you encountered anything like this? Would you have an idea what could 
go wrong here?

I can provide a sample audio file if needed.

Jyrki Niemela

More information about the ffmpeg-devel mailing list