FFmpeg tblend Filter: Blend Consecutive Frames

This guide explains how to use the tblend (temporal blend) filter in FFmpeg to apply blend modes between consecutive frames of a single video. You will learn the basic syntax of the filter, the available blend modes, and practical examples for creating visual effects like motion blur, ghosting, and frame-differencing.

Understanding the tblend Filter

The tblend filter is a temporal version of the standard blend filter. While the standard blend filter merges two separate video streams, tblend blends consecutive frames within a single video stream. Specifically, it blends the current frame (frame \(n\)) with the immediately preceding frame (frame \(n-1\)).

This is highly useful for temporal effects, motion analysis, and transition styling.

Basic Syntax

The basic syntax for the tblend filter is:

ffmpeg -i input.mp4 -vf tblend=all_mode=MODE output.mp4

Where MODE is the specific blend algorithm you want to apply.

Key Parameters:


Common Blend Modes

FFmpeg supports a wide variety of blend modes. Here are some of the most commonly used modes for temporal blending:

Mode Description Common Use Case
average Computes the mathematical average of the two frames. Smooth motion blur, noise reduction.
difference Subtracts the pixels of one frame from another. Motion detection, highlighting movement.
multiply Multiplies the pixel values, resulting in a darker image. Darkening transitions, stylized shadows.
screen Oppositely multiplies the pixel values, resulting in a lighter image. Double-exposure effect, light trails.
overlay Combines multiply and screen modes depending on the base light. Enhancing contrast in moving elements.

Practical Examples

1. Creating a Motion Blur/Ghosting Effect

By using the average mode, you can blend consecutive frames to create a smooth, natural-looking motion blur or ghosting effect on moving objects.

ffmpeg -i input.mp4 -vf "tblend=all_mode=average" output.mp4

2. Highlighting Movement (Temporal Difference)

Using the difference mode will turn static parts of the video completely black, while moving objects will be highlighted. This is often used in motion tracking and security video analysis.

ffmpeg -i input.mp4 -vf "tblend=all_mode=difference" output.mp4

3. Creating Light Trails with Screen Mode

Using the screen mode preserves the brightest parts of consecutive frames, making it ideal for creating light trail effects from moving light sources (like cars at night).

ffmpeg -i input.mp4 -vf "tblend=all_mode=screen" output.mp4

4. Adjusting Blend Opacity

If the blending effect is too intense, you can use the all_opacity option to tone it down. This example blends frames using average mode but at only 50% opacity, preserving more of the original frame’s sharpness.

ffmpeg -i input.mp4 -vf "tblend=all_mode=average:all_opacity=0.5" output.mp4