jetpower
Sep 16 2005, 15:39
Hi,
I need information on how to read the number of silent samples from last mp3 frame.
In mp3s, all frames (last frame included) must have exactly 1152 audio samples.
I understand that in the last frame, some samples need to be digitally silent (to fill up to 1152).
So how to count the silent samples through reading an mp3 file?
Thanks
SebastianG
Sep 20 2005, 08:51
Since mp3 is a lossy compression sheme it's highly unlikely that padded zero samples are still zero after decoding if some non-zero samples were also present in the last frame. So decoding + counting isn't going to work.
But you might want to check out what LAME does here an how players like Foobar2K or XMPlay32 decide what to remove (at the beginning and) at the end. LAME produces a single "header frame" + all coded audio frames. This "header frame" just looks like a normal MPEG audio frame. It carrays some meta informations including "enc_delay" and "enc_padding". Decoders/Players that are not aware of this just decode this frame which results in a bit of silence. Decoders/Players that ARE aware of this only evaluate the meta informations of this frame and skip it. These "enc_delay" and "end_padding" values are actually telling those decoders/players how many samples to remove at the beginning and at the end after they decoded all the audio frames.
This meta information (LAME tag) is embedded in the first frame right after a Xing-VBR/Info tag. Google for "lame tag specification".
Sebi