FFmpeg adelay: Pad Audio with Silence at Beginning
Padding an audio track with silence at the beginning is a common task
in audio and video editing. This article provides a straightforward
guide on how to use the FFmpeg adelay filter to insert a
specific duration of silence at the start of an audio file, detailing
the exact command-line syntax for both stereo and multi-channel audio
tracks.
The Basic Command Syntax
The adelay filter works by delaying the start of the
audio channels. When you delay an audio stream, FFmpeg automatically
fills the resulting gap at the beginning with silence.
The simplest way to apply this filter to all audio channels is by
using the all=1 option.
ffmpeg -i input.mp3 -af "adelay=3000:all=1" output.mp3Explaining the Parameters
-i input.mp3: Specifies your input audio (or video) file.-af: This is the shorthand flag for-filter:a, which tells FFmpeg to apply an audio filter.adelay=3000:all=1:3000is the delay time in milliseconds (3000ms = 3 seconds).:all=1tells FFmpeg to apply this exact delay to all channels (left, right, center, etc.) in the audio stream.
output.mp3: The name of the newly generated output file containing the silent padding.
Specifying Delay in Seconds
If you prefer not to calculate milliseconds, you can append
s to the number to specify the delay in seconds:
ffmpeg -i input.wav -af "adelay=5s:all=1" output.wavThis command inserts exactly 5 seconds of silence at the start of the audio file.
Delaying Channels Individually (Alternative Method)
If you are using an older version of FFmpeg that does not support the
all=1 parameter, or if you want to delay channels by
different amounts, you must specify the delay for each channel
individually, separated by a pipe (|) character.
For a standard stereo (2-channel) file:
ffmpeg -i input.mp3 -af "adelay=3000|3000" output.mp3For a 5.1 surround sound (6-channel) file:
ffmpeg -i input.wav -af "adelay=3000|3000|3000|3000|3000|3000" output.wavNote: If you do not specify a delay for every channel in the stream, the unmapped channels will not be delayed, resulting in desynchronized audio.