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:
start_duration: The duration of the padding at the start of the video (in seconds).stop_duration: The duration of the padding at the end of the video (in seconds).start: The number of padding frames to add at the start (alternative tostart_duration).stop: The number of padding frames to add at the end (alternative tostop_duration).color: The color of the padded frames. The default is black.
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.mp4Option 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.mp4Configuring 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.mp4Using 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.mp4Combining 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