How to Use FFmpeg tpad Filter for Video Padding

This guide explains how to use the tpad (temporary padding) filter in FFmpeg to add extra frames to the beginning or end of a video. You will learn the key parameters of the filter, including how to control the padding duration, choose custom colors, and clone existing frames to create a freeze-frame effect at the start or end of your file.

Understanding the tpad Filter

The tpad filter is a video filter (-vf) in FFmpeg designed to temporarily pad video streams. This is highly useful for adding intro/outro buffers, inserting black screens, or holding on the first/last frame of a video.

The filter is configured using four primary options to control timing:

How to Customize the Padding Style

By default, tpad adds solid black frames. You can customize this behavior using the following parameters:


Practical Examples

Here are the most common ways to implement the tpad filter.

1. Add Black Padding by Duration

To add 3 seconds of black video to the beginning and 5 seconds of black video to the end of your input file:

ffmpeg -i input.mp4 -vf "tpad=start_duration=3:stop_duration=5" output.mp4

2. Freeze the First and Last Frames (Clone Mode)

If you want to pause the video on the first frame for 2 seconds before it plays, and freeze the last frame for 4 seconds when it ends, use the clone mode:

ffmpeg -i input.mp4 -vf "tpad=start_duration=2:start_mode=clone:stop_duration=4:stop_mode=clone" output.mp4

3. Add Custom Colored Padding

To add 2 seconds of solid red padding to the start of the video:

ffmpeg -i input.mp4 -vf "tpad=start_duration=2:color=red" output.mp4

4. Padding by Frame Count

If you prefer to work with exact frame counts rather than seconds, use start and stop. For example, to add exactly 30 frames of padding to the end of a video:

ffmpeg -i input.mp4 -vf "tpad=stop=30" output.mp4

Note: If your video contains audio, adding video padding with tpad will not automatically pad the audio stream. You may need to use audio filters like adelay or aresample to keep the audio and video in sync.