Configure FFmpeg tmix Filter Frames and Weights

The FFmpeg tmix (temporal mix) filter blends consecutive video frames across time to generate visual effects such as motion blur, temporal smoothing, noise reduction, and light trails. This guide explains how to properly configure the filter's two primary parameters: frames, which sets the size of the rolling frame window, and weights, which controls the relative opacity and contribution of each frame in the mix.

Understanding the Parameters

The tmix filter takes three key parameters:

  • frames (or f): Defines the total number of consecutive frames to mix together. The default value is 3.
  • weights (or w): Defines the space-separated list of weight factors applied to each frame in the mix window. The default value is 1 for all frames.
  • scale: A floating-point scale factor applied to the output. By default (scale=0), FFmpeg automatically normalizes the output by dividing the pixel values by the sum of all weights, preventing overexposure.

Basic Syntax

To use tmix, pass the parameters to the -vf (video filter) argument in FFmpeg:

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

Configuring the Frame Count

The frames parameter sets how many frames are buffered and blended simultaneously:

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

Higher values create a stronger averaging effect, producing longer motion trails and smoother motion, but will cause rapid movement to appear ghosted or smeared.

Configuring Weight Factors

Weights dictate the prominence of each frame in the buffer. By default, weights are ordered sequentially from the oldest frame in the buffer to the most recent frame.

1. Fading Motion Blur (Trailing Effect)

To create a trail where past frames gradually fade out behind the current action, assign smaller weights to older frames and the largest weight to the newest frame:

ffmpeg -i input.mp4 -vf "tmix=frames=4:weights=1 2 4 8" output.mp4

In this example, the current frame contributes half of the total brightness (8 / (1+2+4+8)), while the previous three frames fade out progressively.

2. Centered Temporal Blur (Symmetrical)

To create a smooth, centered blur where the middle frame is sharpest and the surrounding frames fade out equally:

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

3. Uniform Temporal Averaging

For temporal denoising or simulated long-exposure shots of stationary scenes with moving elements:

ffmpeg -i input.mp4 -vf "tmix=frames=10:weights=1" output.mp4

When fewer weights are specified than the total frame count, FFmpeg assigns a weight of 1 to any remaining frames. Setting weights=1 distributes equal opacity across all 10 frames.

Handling Brightness with the Scale Parameter

When leaving scale=0, FFmpeg automatically divides the output by the sum of the weights:

\[\text{Output} = \frac{\sum (\text{Frame}_i \times \text{Weight}_i)}{\sum \text{Weights}}\]

If you manually set scale, FFmpeg multiplies the result directly by your scale value instead of normalizing:

ffmpeg -i input.mp4 -vf "tmix=frames=3:weights=1 1 1:scale=0.333" output.mp4

Unless you are intentionally brightening or darkening the video during the mix, leave scale at its default value (0) to maintain proper exposure.