FFmpeg afade Filter: How to Change Transition Curves

The afade filter in FFmpeg is a powerful tool for applying fade-in and fade-out effects to audio tracks. While many users stick to the default linear fade, FFmpeg supports a wide variety of transition curves—such as logarithmic, exponential, and sinusoidal—to create more natural-sounding audio transitions. This article explains how to use the afade filter's curve parameter to select and apply different mathematical curves for your audio transitions.

To change the transition curve in FFmpeg, you use the curve (or c) option within the afade filter. By default, FFmpeg uses a linear transition, but changing this curve alters how the volume scales over the duration of the fade.

Basic Syntax

The basic syntax for the afade filter with a custom curve is:

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

In this command:

  • t=in specifies a fade-in (use out for a fade-out).
  • st=0 sets the start time of the fade in seconds.
  • d=5 sets the duration of the fade in seconds.
  • c=log specifies the curve type, which in this case is logarithmic.

Available Transition Curves

FFmpeg supports numerous curve algorithms. Here are some of the most commonly used options for the c parameter:

  • tri (Linear / Triangular): The default setting. The volume changes at a constant, linear rate.
  • log (Logarithmic): Starts slow and speeds up. This is highly recommended for fade-outs because the human ear perceives volume logarithmically.
  • exp (Exponential): Starts very slow and accelerates rapidly at the end.
  • qsin (Quarter Sine): Follows a quarter of a sine wave, offering a smooth start and a sharper finish.
  • hsin (Half Sine): Follows a half-sine wave, resulting in a very smooth transition at both the start and end of the fade.
  • squ (Square Root): Starts quickly and slows down towards the end.
  • cub (Cubic): Provides an S-curve transition that is very gentle at both ends.

Practical Examples

1. Logarithmic Fade-Out To apply a smooth, natural-sounding 4-second fade-out that starts at the 30-second mark of an audio file using a logarithmic curve:

ffmpeg -i input.wav -af "afade=t=out:st=30:d=4:c=log" output.wav

2. Sinusoidal Fade-In To apply a gentle 5-second fade-in right at the beginning of the audio track using a quarter-sine curve:

ffmpeg -i input.wav -af "afade=t=in:st=0:d=5:c=qsin" output.wav

Choosing the right curve depends on your source material. For general music transitions, log, qsin, and hsin typically produce much more organic and less abrupt results than the default linear (tri) curve.