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:

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

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