How to Use FFmpeg tmedian Temporal Denoise Filter

This article provides a straightforward guide on how to apply the tmedian temporal denoise filter in FFmpeg to reduce video noise and flicker. You will learn the basic command syntax, key parameters for customization, and practical examples to clean up noisy video footage effectively by using pixel data from neighboring frames.

What is the tmedian Filter?

The tmedian (temporal median) filter is a video filter in FFmpeg that reduces noise by calculating the median pixel value across a span of consecutive frames. Unlike spatial filters that blur individual frames, temporal filters compare pixels at the exact same coordinates across time. This makes tmedian highly effective at removing random, high-frequency noise, sensor grain, scratches, and dust while preserving sharp edge details.

Basic Syntax

To apply the default tmedian filter to a video, use the -vf (video filter) flag followed by tmedian:

ffmpeg -i input.mp4 -vf tmedian output.mp4

Customizing tmedian Parameters

You can fine-tune the filter’s behavior using specific parameters:

Practical Examples

Stronger Denoising (Larger Radius)

To apply a stronger temporal denoise effect, increase the radius. This example uses a radius of 3, meaning it calculates the median across 7 consecutive frames (3 before, the current frame, and 3 after):

ffmpeg -i input.mp4 -vf "tmedian=radius=3" output.mp4

Filtering Specific Planes

If you only want to apply the temporal median filter to the luma (brightness) channel (plane 0) and leave the chroma (color) channels untouched:

ffmpeg -i input.mp4 -vf "tmedian=planes=1" output.mp4

Best Practices