How to Add a Lead Out in FFmpeg

This article explains how to create a professional "lead-out" at the end of your videos and audio files using FFmpeg. While FFmpeg does not feature a specific filter named "leadout," you can easily achieve this exact effect by utilizing the tpad filter to append black frames to the end of a video, the apad filter to extend audio with silence, and the fade filter to create smooth transitions.

Video Lead-Out using the tpad Filter

To add a visual lead-out (such as a black screen or a frozen frame) to the end of a video, use the tpad (temporary padding) video filter. The stop_duration option specifies how many seconds of padding to add to the end of the stream.

ffmpeg -i input.mp4 -vf "tpad=stop_duration=5:stop_mode=add:color=black" output.mp4
  • stop_duration=5: Adds 5 seconds of padding to the end of the video.
  • stop_mode=add: Generates new frames of a solid color.
  • color=black: Sets the padding color to black. You can change this to any standard color.

If you prefer to freeze the very last frame of your video for the lead-out instead of using a solid color, change stop_mode to clone:

ffmpeg -i input.mp4 -vf "tpad=stop_duration=5:stop_mode=clone" output.mp4

Audio Lead-Out using the apad Filter

If you extend your video stream, you must also extend your audio stream so the player does not cut off early. The apad filter pads the end of an audio stream with silence.

ffmpeg -i input.mp4 -vf "tpad=stop_duration=5" -af "apad" -shortest output.mp4
  • -af "apad": Adds infinite silence to the end of the audio track.
  • -shortest: Tells FFmpeg to stop hosting the container output as soon as the longest explicit stream (the newly padded video) ends.

Creating a Fade-Out Transition

For a more natural lead-out, you can fade both the video and audio to black and silence before the file ends. This is done using the fade and afade filters.

ffmpeg -i input.mp4 -vf "fade=t=out:st=58:d=2" -af "afade=t=out:st=58:d=2" output.mp4
  • t=out: Specifies that the transition is a fade-out.
  • st=58: The start time of the fade-out in seconds (e.g., at the 58-second mark).
  • d=2: The duration of the fade-out (2 seconds).