How to Use FFmpeg tmix Filter for Motion Blur

This article provides a quick guide on how to use the tmix (temporal mix) filter in FFmpeg to blend consecutive video frames. You will learn the basic syntax of the filter, understand its key parameters like frames and weights, and see practical examples of how to generate smooth motion blur and long-exposure effects in your videos.

The tmix filter works by averaging a specified number of successive frames together. This temporal blending merges moving objects across frames, resulting in a natural-looking motion blur.

Basic Syntax and Parameters

The basic syntax for the tmix filter is:

-vf "tmix=frames=N:weights=W"

Example 1: Standard Motion Blur

To apply a simple motion blur using 7 consecutive frames with equal weight, use the following command:

ffmpeg -i input.mp4 -vf "tmix=frames=7" output.mp4

This configuration takes the current frame and the surrounding frames, averages them equally, and outputs a smoothed motion effect.

Example 2: Weighted Motion Blur for Smoother Trails

Equal weighting can sometimes cause a ghosting effect rather than a smooth blur. To fix this, you can assign higher weights to the central frames and lower weights to the outer frames.

To mix 5 frames with custom weights:

ffmpeg -i input.mp4 -vf "tmix=frames=5:weights='1 2 3 2 1'" output.mp4

In this example, the middle frame (weighted at 3) has the most influence on the final image, while the preceding and succeeding frames fade out gradually, creating a cleaner motion trail.

Example 3: Combining with Frame Rate Adjustment

For high-framerate inputs, you may want to reduce the framerate first to make the motion blur more pronounced. You can chain the fps filter before tmix:

ffmpeg -i input.mp4 -vf "fps=60,tmix=frames=10" output.mp4

This drops or interpolates the video to 60 frames per second before blending 10 frames together, ensuring a consistent and heavy blur effect regardless of the source file’s original framerate.