Adjust FFmpeg silencedetect Threshold and Duration

This article explains how to configure the silencedetect filter in FFmpeg to identify silent periods in audio and video files. You will learn how to adjust the two primary parameters of this filter: the noise threshold, which defines what volume level constitutes silence, and the duration, which sets the minimum length of time the silence must last to be detected.

The silencedetect filter analyzes the audio stream of an input file and outputs timestamps of detected silence to the console log. To customize this detection, you need to modify the noise (or n) and duration (or d) options.

The Duration Parameter

The duration parameter specifies the minimum duration of silence that must occur before FFmpeg flags it. If a silent period is shorter than this value, it will be ignored.

The Noise Threshold Parameter

The noise parameter determines the maximum volume level that is still considered silence. Any audio below this threshold is treated as quiet enough to be flagged.

How to Use the Parameters in a Command

To apply these settings, pass them to the -filter_complex or -af (audio filter) flag using the format silencedetect=noise=THRESHOLD:duration=DURATION.

Example 1: High Sensitivity (Short, Quiet Silence)

If you want to detect silence that lasts at least 0.5 seconds with a threshold of -50dB:

ffmpeg -i input.mp3 -af "silencedetect=noise=-50dB:duration=0.5" -f null -

Example 2: Low Sensitivity (Longer, Louder Silence)

If you want to find silent gaps that are at least 5 seconds long, allowing for a higher ambient noise level of -30dB:

ffmpeg -i input.mp4 -af "silencedetect=n=-30dB:d=5" -f null -

Reading the Output

When you run these commands, FFmpeg will output the results to the standard error stream. Look for lines in the output that resemble the following:

[silencedetect @ 0x7fa26bc040c0] silence_start: 12.45
[silencedetect @ 0x7fa26bc040c0] silence_end: 15.82 | silence_duration: 3.37

This output indicates that silence started at 12.45 seconds and ended at 15.82 seconds, lasting for a total of 3.37 seconds.