Last ~277 samples missing after encoding with LAME

Michael Bradshaw <[email protected]>
Newsgroups gmane.comp.audio.mp3.lame
Message-ID <CAJ29FNY6WHQ08SZNx5vqR8Qdoip0FkoBAeLT813RcZoD0J_G0g@mail.gmail.com>
Hi,

I just did a test with lame and found that the last ~277 samples of
audio are missing. I noticed this when converting a song (that's
supposed to loop; more on that later), so I decided to test it more
carefully.

I created a 440Hz sine wave, sampled at 44100 Hz, with a duration of 1
second (44100 samples total in (mono) WAVE file). I then encoded this
file (sine.wav) to mp3 using lame CLI (and I tested with ffmpeg CLI).
The resulting MP3 had a delay at the beginning of ~2257 samples (which
I expected), but the actual sine wave is about 277 samples short at
the end.

My question is: is this 277 sample shortage intentional? Can I
overcome it and properly save the full sine wave (I don't mind if LAME
adds extra silent padding to the end of the track if necessary)? I've
read the technical FAQ (question 3), but I'm not seeing this; in fact,
it looks like LAME isn't adding padding and that the last few sample
of that granule can't be decoded.


Side question: what's the safest way to find the number of delay
samples (both encoder and decoder)? I assume the decoder delay can't
be known without knowing the specific decoder that'll be used, and
from the FAQ a decoder delay of 528 seems to be a safe assumption.
What about LAME's encoder delay?
lame_get_encoder_delay(lame_global_flags*) is correct, right? So the
total delay would be (encoder + decoder):
lame_get_encoder_delay(lame_global_flags*) + 528? I see FFmpeg's
libmp3lame encoder does lame_get_encoder_delay(lame_global_flags*) +
528 + 1. Is the +1 necessary?

Also, another side question: the silent delay added to the beginning
of a file has just a tiny bit of noise just before the actual audio
begins (it's not really audible: the amplitudes of the noise are sooo
small, but visually it's seeable when graphing the audio data). What's
causes this noise (Adobe Flash's MP3 encoder (or whichever encoder it
is they use) doesn't produce this)? Is there a way the silent delay
added to the beginning of a file can be made truly silent (so all the
amplitudes are 0)?

Thanks! And if you need me to provide samples or pictures or anything
please just let me know.

--Michael

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.