So I've been looking into the mp4 file structure a bit and there seems to be quite a lot to it. And from what I understand, this is how things are laid out.

├───general file metadata
├───movie data
│   ├───video
│   │   ├───video metadata
│   │   └───video sample data
│   └───audio
│       ├───audio metadata
│       └───audio sample data
└───more metadata

What I'm wondering is, can I detect "silent" parts in the mp4? (without using ffmpeg and just using the file structure) Like set a variable that says "anything that's under 20dB is considered silent. Are there blocks inside the file structure? And if so, how big are they in milliseconds? If that's even how it works.

  • Why do you need to detect silences?
    – harrymc
    Jan 23, 2023 at 20:42
  • 1
    Audio compression, like all compression, is designed to remove redundant data in a file. Near or total silence would be represented by a long series of near zero values which compression would quickly decimate and reduce to encode only the "important" values. The result is that from a file data standpoint the raw bytes for silence would end up looking random and somewhat similar to the random raw bytes for loud noises. The only way to "see" the silence would be to decompress it to a raw format, and that is what David is suggesting in his answer. You have to use a program to decode and read it.
    – Mokubai
    Jan 23, 2023 at 21:07

1 Answer 1


Can I detect "silent" parts in an mp4?

You can use ffmpeg from https://ffmpeg.org/ to detect silence using the silencedetect filter:

Detect silence in an audio stream.

This filter logs a message when it detects that the input audio volume is less or equal to a noise tolerance value for a duration greater or equal to the minimum detected noise duration.

The printed times and duration are expressed in seconds. The lavfi.silence_start or lavfi.silence_start.X metadata key is set on the first frame whose timestamp equals or exceeds the detection duration and it contains the timestamp of the first frame of the silence.

The lavfi.silence_duration or lavfi.silence_duration.X and lavfi.silence_end or lavfi.silence_end.X metadata keys are set on the first frame after the silence. If mono is enabled, and each channel is evaluated separately, the .X suffixed keys are used, and X corresponds to the channel number.

The filter accepts the following options:

noise, n

mono, m

  • Process each channel separately, instead of combined. By default is disabled.

8.103.1 Examples

Detect 5 seconds of silence with -50dB noise tolerance:


Complete example with ffmpeg to detect silence with 0.0001 noise tolerance in silence.mp3:

ffmpeg -i silence.mp3 -af silencedetect=noise=0.0001 -f null -

Source: FFmpeg Filters Documentation

Replace mp3 with mp4 and the dB value as appropriate for your use case..

  • Ah excuse me, I should of added "without using ffmpeg".
    – JohnA
    Jan 23, 2023 at 19:41
  • Silence is not detectable without scanning the file.
    – DavidPostill
    Jan 23, 2023 at 20:04
  • Unless you write a decoder yourself.. Jan 23, 2023 at 20:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .