How to Insert Silence into Audio with FFmpeg

This article provides a quick and practical guide on how to insert a specific duration of absolute silence into any audio file using FFmpeg. Whether you need to pad the beginning, append silence to the end, or splice a silent gap directly into the middle of your audio track, you will find the exact command-line instructions needed to accomplish these tasks.

1. Prepend Silence to the Beginning of an Audio File

The most efficient way to add silence to the beginning of an audio track is by using the adelay filter. This filter delays the start of the audio channels, filled with absolute silence.

Run the following command to prepend 5 seconds of silence (note that the delay time must be specified in milliseconds, so 5 seconds is 5000 milliseconds):

ffmpeg -i input.wav -af "adelay=5000|5000" output.wav

Note: The | separator delays both the left and right channels for stereo files. If your audio has more channels, append additional |5000 values for each channel.

2. Append Silence to the End of an Audio File

To add silence to the end of an audio file, you can generate a silent audio stream using FFmpeg’s virtual audio source (anullsrc) and concatenate it with your original file.

Run the following command to append 3 seconds of silence:

ffmpeg -i input.wav -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 -filter_complex "[1]atrim=duration=3[silence];[0][silence]concat=n=2:v=0:a=1[out]" -map "[out]" output.wav

Ensure that the channel_layout and sample_rate match your input file to avoid compatibility issues during concatenation.

3. Insert Silence in the Middle of an Audio File

To insert a specific length of silence at a precise timestamp in the middle of your track, you must split the original audio into two parts, generate the silent segment, and concatenate all three pieces together.

The following command inserts 4 seconds of silence at exactly the 10-second mark:

ffmpeg -i input.wav -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 -filter_complex \
"[0]atrim=end=10[part1]; \
 [1]atrim=duration=4[silence]; \
 [0]atrim=start=10[part2]; \
 [part1][silence][part2]concat=n=3:v=0:a=1[out]" \
-map "[out]" output.wav

Explanation of parameters: