Pad a video with black frames to a target duration
Sometimes you have a clip that is too short for the slot it needs to fill — a 2-second title card that needs to run for 10 seconds, a 30-second bumper that needs to be 1 minute. The `tpad` filter pads the start, end, or both of a video with a chosen color (black by default) to a target duration.
The command
ffmpeg -i short.mp4 -vf "tpad=stop_duration=8:color=black" -c:v libx264 -crf 20 out.mp4What it does
The filter pads the end of the video with 8 seconds of black, so a 2-second source becomes a 10-second output. Use `start_duration=8` to pad the beginning instead, or both for a centered source. The `color` parameter accepts any CSS color name or hex code. The audio is unaffected — to pad the audio as well, use `apad` with the same logic.
Requirements
Any video input. The filter is in libavfilter. CPU-only — the padding is just a constant frame the encoder writes, so the cost is proportional to the target duration, not the source.
Things to avoid
- Padding with a color that does not match the project's background. The pad will be visible at the cut; for a black background, use `color=black`; for a white background, `color=white`.
- Padding the video without padding the audio. The video will run longer than the audio, and the player will either loop the audio or play silence. Pad both.
- Using `tpad` on a stream that is already at the target duration. The filter pads up to the target, so passing a 12-second source with `stop_duration=8` will leave the source untouched.
- Combining `tpad` with a complex filter chain. The padding is a single frame inserted at the end; if your chain expects a specific duration, run the padding last.