How to Fade In Audio with FFmpeg

Applying a fade-in effect to the beginning of an audio track prevents abrupt starts and creates a smoother listening experience. This article explains how to use FFmpeg's afade filter to easily apply a fade-in effect, detailing the exact command-line syntax and parameter adjustments needed to control the start time and duration of the fade.

To apply a fade-in effect, you will use the FFmpeg audio filter option (-af) combined with the afade filter.

The Basic Command

Run the following command in your terminal to apply a 5-second fade-in to the start of an audio file:

ffmpeg -i input.mp3 -af "afade=type=in:start_time=0:duration=5" output.mp3

Parameter Breakdown

  • -i input.mp3: Specifies the input audio file.
  • -af: Tells FFmpeg to apply an audio filter.
  • afade=: Calls the audio fade filter.
  • type=in (or t=in): Specifies that the volume should fade in (gradually increase from silence).
  • start_time=0 (or ss=0): Defines the timestamp (in seconds) where the fade-in should begin. Setting this to 0 starts the fade immediately at the beginning of the track.
  • duration=5 (or d=5): Sets the length of the fade-in effect in seconds. In this example, the audio will reach full volume at the 5-second mark.
  • output.mp3: The name of the resulting audio file.

Customizing the Fade

You can easily adjust the parameters to fit your specific audio requirements. For instance, if you want a shorter, 3-second fade-in that begins 2 seconds after the track starts, use this command:

ffmpeg -i input.mp3 -af "afade=type=in:start_time=2:duration=3" output.mp3

This command-line approach is highly efficient, allowing you to modify your audio files quickly without the need for a heavy graphical user interface.