Configure FFmpeg tpad Filter Color and Duration

This guide explains how to use the FFmpeg tpad (temporal pad) video filter to add padding frames to the beginning or end of a video. You will learn the exact parameters required to configure the duration of the padding—using either seconds or frame counts—and how to customize the background color of these padded frames.

The tpad Filter Parameters

The tpad filter temporarily pads the start or end of a video stream with solid color frames. To control the duration and color, you use the following key parameters:

Configuring Padding Duration

You can specify the padding duration using either time (seconds) or a specific number of frames.

Option 1: Specifying Duration in Seconds

To add 3 seconds of padding to the start of a video and 5 seconds to the end, use start_duration and stop_duration:

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

Option 2: Specifying Duration in Frames

If you need frame-accurate padding, use the start and stop parameters to define the exact number of frames:

ffmpeg -i input.mp4 -vf "tpad=start=90:stop=150" output.mp4

Configuring Padding Color

The color parameter defines the color of the padding. FFmpeg accepts color names (like red, blue, white, green) or hexadecimal values.

Using Color Names

To add 4 seconds of red padding to the start of a video:

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

Using Hexadecimal Color Codes

To use custom colors, specify a hex code in the 0xRRGGBB format. For example, to use a specific shade of purple (#800080):

ffmpeg -i input.mp4 -vf "tpad=start_duration=3:color=0x800080" output.mp4

Combining Duration and Color

You can combine all these parameters into a single filter chain. The following command adds 2 seconds of green padding to the beginning of the video and 4 seconds of green padding to the end of the video:

ffmpeg -i input.mp4 -vf "tpad=start_duration=2:stop_duration=4:color=green" output.mp4