How to Use FFmpeg DCT Filter for Spatial Denoising

This article provides a straightforward guide on how to use the Discrete Cosine Transform (dct) filter in FFmpeg for spatial block denoising. You will learn the basic syntax of the filter, understand its key parameters—such as threshold and block size—and see practical command-line examples to help you effectively clean up noisy video footage.

The dct filter in FFmpeg denoises video frames in the frequency domain by applying a 2D Discrete Cosine Transform to local blocks, zeroing out high-frequency coefficients that fall below a certain threshold, and then performing the Inverse Discrete Cosine Transform (IDCT). This method is highly effective at reducing high-frequency noise while preserving edge details.

Basic Syntax and Parameters

To use the filter, apply -vf dct in your FFmpeg command. The filter relies on two primary parameters to control the denoising intensity and block evaluation:

Practical Examples

1. Basic Denoising To apply moderate denoising to a video using the default \(8 \times 8\) block size, use a threshold value like 5:

ffmpeg -i input.mp4 -vf "dct=threshold=5" output.mp4

2. Strong Denoising with Larger Blocks For heavily degraded video, you can increase the threshold to 10 and increase the block size to \(16 \times 16\) (n=4) to target larger noise patterns:

ffmpeg -i input.mp4 -vf "dct=threshold=10:n=4" output.mp4

Tips for Best Results