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.mp4Configuring a Large Frame Window
The size of the temporal frame window is calculated as
(2 * radius) + 1.
- A
radiusof1(the default) uses a 3-frame window (1 past frame, the current frame, and 1 future frame). - A
radiusof10creates a 21-frame window. - A
radiusof25creates a 51-frame window.
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.mp4Key Parameters
radius(orr): Sets the temporal lookup radius. The default is1. Larger values increase the denoising power but require more processing power.planes(orp): Specifies which color planes to filter. It accepts a bitmap value from0to15. The default is15, which applies the filter to all video planes (Y, U, V, and alpha).
Performance and Memory Considerations
Using a large temporal window has practical trade-offs that you must consider before processing:
- 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. - 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.
- 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.