How to Use FFmpeg tmedian for Video Noise Reduction

The tmedian filter in FFmpeg offers an effective way to reduce temporal video noise, grain, and sensor artifacts across progressive footage by calculating the median pixel value across a defined window of sequential frames. This article explains how the tmedian filter works, details its essential parameters, and provides ready-to-use FFmpeg commands for processing static and low-motion footage without losing spatial sharpness.


How the tmedian Filter Works

Unlike spatial denoisers that smooth pixel values within the same frame, the tmedian filter operates temporally. It looks at the current frame alongside preceding and succeeding frames, sorting the values for each pixel coordinate across time and selecting the median.

Because random noise (such as sensor grain or compression specks) fluctuates rapidly from frame to frame, the outlier pixel values caused by noise are discarded, while consistent visual elements are preserved.

Core Parameters

The tmedian filter provides several parameters to control how frames are sampled:

  • radius: Specifies the number of frames to inspect before and after the current frame. The total window size is calculated as (2 * radius) + 1. The default radius is 4 (a 9-frame window). Higher values produce stronger denoising but increase processing time and the likelihood of ghosting artifacts on moving objects.
  • planes: Sets which color planes to filter. Available options are 1 (Y/Luma), 7 (all planes: Y, U, and V), or specific bitmasks. The default applies filtering to all planes.
  • percentile: Determines the temporal percentile to pick instead of a strict median. The default is 0.5 (the exact median). Values lower than 0.5 pick darker temporal pixels, while values higher pick brighter temporal pixels.

Practical FFmpeg Examples

1. Basic Denoising with Default Settings

To apply the filter with default settings (radius of 4 across all color planes):

ffmpeg -i input.mp4 -vf "tmedian" -c:a copy output.mp4

2. Subtle Denoising for Moderate Motion

When working with footage containing moderate motion, reduce the radius to minimize ghosting or motion trails:

ffmpeg -i input.mp4 -vf "tmedian=radius=2" -c:v libx264 -crf 18 -c:a copy output.mp4

A radius of 2 checks 2 frames forward and 2 frames back (5 frames total), effectively removing high-frequency grain while preserving moving edges.

3. Heavy Denoising for Static Shots

For stationary camera setups, such as tripod-mounted landscape or surveillance video with heavy low-light noise, increase the radius:

ffmpeg -i input.mp4 -vf "tmedian=radius=6" -c:v libx264 -crf 18 -c:a copy output.mp4

This inspects 13 consecutive frames to average out persistent temporal noise.

4. Denoising Chroma Noise Only

If the luma detail is clean but color noise (chroma jitter) is visible, target only the chroma planes (planes 2 and 4, or U and V components):

ffmpeg -i input.mp4 -vf "tmedian=radius=3:planes=6" -c:v libx264 -crf 18 -c:a copy output.mp4

Best Practices and Limitations

  • Motion Sensitivity: Because tmedian does not use motion estimation or motion vectors, fast-moving objects will leave translucent trails (ghosting). Keep the radius low (between 1 and 3) for videos with moving subjects.
  • Progressive Scan Only: Ensure your input video is progressive. If the source is interlaced, deinterlace it first (e.g., using -vf "yadif,tmedian") to prevent combining fields incorrectly.
  • Bitrate Efficiency: Temporal median filtering makes video streams substantially easier for encoders like H.264 or H.265 to compress, resulting in smaller file sizes at equivalent CRF values.