Apply FFmpeg tmedian Filter for Temporal Denoising

This article explains how to use FFmpeg’s tmedian (temporal median) filter to apply high-quality temporal noise reduction to your videos. You will learn the correct syntax for configuring the filter, how to set a large frame window for deep denoising, and how to balance processing performance with visual quality.

The tmedian filter in FFmpeg works by comparing a pixel’s value across a sequence of consecutive frames (the temporal window) and replacing it with the median value. This is highly effective at removing transient noise, such as analog tape static, dust, or sensor hiss, without degrading the spatial sharpness of the video.

The tmedian Filter Syntax

To apply the filter, you use the -vf (video filter) flag followed by tmedian. The size of the temporal window is controlled by the radius parameter.

The basic command structure is:

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

Configuring a Large Frame Window

The size of the temporal frame window is calculated as (2 * radius) + 1.

To apply a large frame window for heavy denoising, increase the radius value. The maximum allowed radius is 127 (which creates a massive 255-frame window).

For example, to use a 31-frame temporal window, set the radius to 15:

ffmpeg -i input.mp4 -vf "tmedian=radius=15:planes=15" output.mp4

Key Parameters

Performance and Memory Considerations

Using a large temporal window has practical trade-offs that you must consider before processing:

  1. Memory Consumption: FFmpeg must buffer all frames within the temporal window in your system memory. If you are working with 4K video and set a radius of 50 (101 frames), FFmpeg will require several gigabytes of RAM just for the filter queue.
  2. Processing Speed: Calculating the median value across dozens of frames for millions of pixels is computationally expensive. As the radius increases, your encoding speed (frames per second) will drop significantly.
  3. Motion Artifacts: Extremely large windows can cause “ghosting” or motion lag on fast-moving objects, as the filter may mistake genuine rapid movement for temporal noise. Use larger windows primarily for static shots or slow-moving footage.