How to Use FFmpeg tpad for Start and End Frames
This guide explains how to use FFmpeg's tpad (time pad)
filter to add extra video frames to the beginning and end of a video
file. You will learn the core parameters of the tpad
filter, how to pad videos with solid colors or by freezing existing
frames, and how to handle corresponding audio tracks to keep your media
synchronized.
Understanding the
tpad Filter
The tpad filter modifies video duration by prepending or
appending video frames. It accepts the following primary parameters:
start: The number of frames to add at the beginning.stop: The number of frames to add at the end.start_duration: The length of time (in seconds or timestamp format) to delay the start.stop_duration: The length of time (in seconds or timestamp format) to extend the end.start_mode/stop_mode: Determines what frames are inserted:add: Adds solid color frames (default is black).clone: Replicates and freezes the first frame (for start) or last frame (for stop).
color: Sets the fill color when usingaddmode (e.g.,black,white,red, or a hex value like0x000000).
Freezing the First and Last Frames
To hold the initial frame for a moment before playback begins, or to
freeze the final frame at the end, set the mode parameters to
clone.
The following command clones the first frame for 2 seconds and the last frame for 3 seconds:
ffmpeg -i input.mp4 -vf "tpad=start_duration=2:stop_duration=3:start_mode=clone:stop_mode=clone" -c:a copy output.mp4To specify the freeze duration by frame count instead of time (for example, adding 60 frames at the end):
ffmpeg -i input.mp4 -vf "tpad=stop=60:stop_mode=clone" -c:a copy output.mp4Adding Blank (Solid Color) Frames
By default, tpad inserts black frames. If you want blank
space before or after the video, use start_mode=add or
stop_mode=add.
The following command prepends 1.5 seconds of black video and appends 2 seconds of white video:
ffmpeg -i input.mp4 -vf "tpad=start_duration=1.5:start_mode=add:color=black,tpad=stop_duration=2:stop_mode=add:color=white" -c:a copy output.mp4Handling Audio Synchronization
The tpad filter operates strictly on the video stream.
If your input file contains an audio track, padding only the video will
cause the audio to desync or cut off early.
Delaying Audio at the Start
When adding video at the start, delay the audio by an equivalent
amount using the adelay filter (specified in
milliseconds):
ffmpeg -i input.mp4 -filter_complex \
"[0:v]tpad=start_duration=2:start_mode=clone[v]; \
[0:a]adelay=2000|2000[a]" \
-map "[v]" -map "[a]" output.mp4Extending Audio at the End
When adding video at the end, pad the audio stream with silence using
apad and stop encoding when the video finishes using
-shortest:
ffmpeg -i input.mp4 -filter_complex \
"[0:v]tpad=stop_duration=3:stop_mode=clone[v]; \
[0:a]apad[a]" \
-map "[v]" -map "[a]" -shortest output.mp4