Configure FFmpeg afade Start Time, Duration, and Curve

Applying smooth audio transitions in FFmpeg is achieved using the afade audio filter. This guide explains how to configure the three essential parameters of the afade filter—the fade type, start time, duration, and curve shape—to create precise fade-ins and fade-outs for any audio track.

The afade Filter Syntax

The basic syntax for the afade filter is:

-af "afade=type=fade_type:start_time=seconds:duration=seconds:curve=shape"

You can also use the shorthand parameter names:

-af "afade=t=in:st=2:d=3:c=log"

1. Configure the Fade Type (type or t)

Before setting the time and curve, you must define whether the audio is fading in or fading out. * in: Fades the audio from silence up to original volume. * out: Fades the audio from original volume down to silence.


2. Configure the Start Time (start_time or st)

The start time determines exactly when the volume transition begins. * Unit: Expressed in seconds (e.g., 5 for 5 seconds, 2.5 for two and a half seconds). * Default: 0 (starts at the very beginning of the audio). * Alternative: You can use start_sample (or ss) to specify the starting point by audio sample number instead of seconds.


3. Configure the Duration (duration or d)

The duration determines how long the transition takes to complete. * Unit: Expressed in seconds. * Default: 2 seconds. * Alternative: You can use nb_samples (or ns) to define the duration in audio samples.


4. Configure the Curve Shape (curve or c)

The curve shape defines the mathematical transition style of the volume change. Different curves affect how perceived loudness changes over time.

Commonly used curve shapes include: * tri (Default): Linear slope. Best for simple, standard transitions. * qsin: Quarter of a sine wave. Provides a smoother, more musical transition. * hsin: Half of a sine wave. * log: Logarithmic curve. Starts fast and slows down, matching how human ears naturally perceive volume changes. * exp: Exponential curve. Starts slow and speeds up rapidly at the end. * iquas: Inverted quadratic spline.


Practical Examples

Example 1: Standard 3-Second Fade-In at the Start

To apply a 3-second logarithmic fade-in starting immediately at the beginning of the audio track:

ffmpeg -i input.mp3 -af "afade=t=in:st=0:d=3:c=log" output.mp3

Example 2: Fade-Out near the End

To apply a 5-second linear fade-out starting 55 seconds into the audio track:

ffmpeg -i input.mp3 -af "afade=t=out:st=55:d=5:c=tri" output.mp3

Example 3: Combining Fade-In and Fade-Out

To apply both a fade-in and a fade-out to the same audio file, chain two afade filters together separated by a comma:

ffmpeg -i input.mp3 -af "afade=t=in:st=0:d=3,afade=t=out:st=120:d=5" output.mp3