Skip to main content


Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: get the number of silent samples (Read 5637 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

get the number of silent samples


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?


get the number of silent samples

Reply #1
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".