How to Denoise Video with FFmpeg hqdn3d
Video noise can ruin the quality of your footage, but FFmpeg offers
powerful built-in tools to clean it up. This article provides a
straightforward guide on how to apply the hqdn3d (High
Quality Denoise 3D) filter in FFmpeg to reduce both spatial and temporal
noise, resulting in a cleaner and highly compressible output video.
Understanding the hqdn3d Filter
The hqdn3d filter is a 3D denoiser that reduces noise in
two ways: * Spatial Denoising: Reduces noise within
individual frames (pixels next to each other). * Temporal
Denoising: Reduces noise across consecutive frames (pixels in
the same spot over time).
By combining these two methods, hqdn3d effectively
smooths out grain and compression artifacts without causing significant
motion blur.
The Basic Command
To apply the default denoising settings to a video, use the following FFmpeg command:
ffmpeg -i input.mp4 -vf "hqdn3d" -c:a copy output.mp4In this command: * -i input.mp4 specifies your noisy
source file. * -vf "hqdn3d" applies the video filter with
default settings. * -c:a copy copies the audio track
directly without re-encoding to save time. * output.mp4 is
your clean video file.
Adjusting Denoise Strength
You can customize the intensity of the denoising effect by passing up to four parameters to the filter. The syntax is:
hqdn3d=luma_spatial:chroma_spatial:luma_tmp:chroma_tmp
- luma_spatial (default
4.0): Spatial denoising strength for brightness (luma). - chroma_spatial (default
3.0): Spatial denoising strength for color (chroma). - luma_tmp (default
6.0): Temporal denoising strength for brightness. - chroma_tmp (default
4.5): Temporal denoising strength for color.
Example: Light Denoising
If your video only has a small amount of noise, use lower values to prevent the video from looking too soft or blurry:
ffmpeg -i input.mp4 -vf "hqdn3d=2.0:1.5:3.0:2.25" -c:a copy output.mp4Example: Heavy Denoising
For very grainy or low-light footage, you can increase the values. Be aware that high values can create a “soap opera” effect or cause motion ghosting:
ffmpeg -i input.mp4 -vf "hqdn3d=8.0:6.0:12.0:9.0" -c:a copy output.mp4Best Practices
- Test on a Sample: Denoising can be CPU-intensive.
Test your settings on a short 10-second clip first by adding
-t 10before your input file. - Order of Filters: If you are resizing or
color-correcting your video, always place the
hqdn3dfilter first in your filter chain so it processes the raw, unscaled noise.