How to Use FFmpeg Silencedetect Filter

This guide explains how to use the FFmpeg silencedetect filter to identify periods of silence in audio and video files. You will learn the basic command syntax, how to adjust detection thresholds, and how to interpret the output to automate your audio editing workflows.

Understanding the Silencedetect Filter

The silencedetect filter analyzes the audio channel of an input file and logs the timestamps of silent intervals to the console. It does not alter the audio itself; instead, it outputs metadata containing the start time, end time, and duration of each detected silent period.

Basic Command Syntax

To run the silencedetect filter, you apply it as an audio filter (-af) and direct the output to a nullmuxer (-f null -) so FFmpeg processes the file without generating a new media file.

Here is the standard command:

ffmpeg -i input.mp3 -af silencedetect=noise=-50dB:d=2 -f null -

Parameter Breakdown:

  • noise (or n): Sets the maximum volume threshold to be considered silence. It can be specified in decibels (e.g., -50dB) or as an amplitude value (e.g., 0.003). The default is -60dB.
  • duration (or d): Sets the minimum duration of silence (in seconds) required to trigger detection. The default is 2 seconds.
  • -f null -: Discards the output video/audio stream while allowing FFmpeg to print the filter's log results in the terminal.

How to Read the Output

When you run the command, FFmpeg will output the results in the terminal. Look for the lines tagged with [silencedetect]:

[silencedetect @ 0x7fa89bc05200] silence_start: 10.512
[silencedetect @ 0x7fa89bc05200] silence_end: 13.824 | silence_duration: 3.312
  • silence_start: The timestamp (in seconds) where the volume dropped below your threshold.
  • silence_end: The timestamp where the volume rose back above the threshold.
  • silence_duration: The total length of that specific silent gap.

Practical Examples

1. Detecting Low-Level Noise (Humming)

If your audio has background hiss, the default -60dB might not detect silence. Increase the threshold to -40dB and set a 1.5-second minimum duration:

ffmpeg -i input.wav -af silencedetect=noise=-40dB:d=1.5 -f null -

2. Exporting Silence Logs to a Text File

Because FFmpeg outputs detection data to stderr (standard error) rather than stdout, you must redirect the stderr stream to save the logs to a text file for scripting or manual review:

ffmpeg -i input.mp4 -af silencedetect=noise=-50dB:d=2 -f null - 2> silence_log.txt

You can then filter the text file using command-line tools like grep to show only the timestamps:

grep "silencedetect" silence_log.txt