Configure FFmpeg libx264 Noise Reduction
This article provides a quick guide on how to configure the
noise-reduction parameter in the libx264 encoder using
FFmpeg. You will learn the correct syntax, the range of values to use,
and how this parameter helps optimize your video encoding process by
reducing noise and improving compression.
Understanding the libx264 Noise Reduction Parameter
The libx264 encoder has a built-in noise reduction
filter controlled by the nr parameter. This parameter
performs a fast, low-overhead noise reduction directly inside the
encoder before motion estimation. Because it is integrated into the
encoder, it is much faster than using external FFmpeg video filters
(like hqdn3d or owdenoise), though it is
generally less sophisticated.
How to Apply the Parameter in FFmpeg
To use the noise reduction parameter in FFmpeg, you must pass it
through the -x264-params option.
The basic syntax is:
ffmpeg -i input.mp4 -c:v libx264 -x264-params nr=VALUE -c:a copy output.mp4Alternatively, you can use the older -x264opts
syntax:
ffmpeg -i input.mp4 -c:v libx264 -x264opts nr=VALUE -c:a copy output.mp4Recommended Values for
nr
The nr parameter accepts an integer value:
- 0: Disabled (Default).
- 1 to 100000: The level of noise reduction.
While the technical limit is very high, practical values for real-world video encoding usually fall between 100 and 1000.
- Weak Noise Reduction (100 - 250): Ideal for clean videos with a very light amount of camera sensor hiss. It retains most fine details.
- Medium Noise Reduction (400 - 600): Good for typical analog source captures, VHS rips, or low-light digital video. This is the sweet spot for balancing noise removal and image sharpness.
- Strong Noise Reduction (800 - 1000+): Useful for highly degraded, extremely noisy footage. Note that high values will cause noticeable motion blur and loss of fine textures.
Example Command
To encode a video with a moderate level of noise reduction (value of 500), use the following command:
ffmpeg -i input.mp4 -c:v libx264 -crf 20 -x264-params nr=500 output.mp4Combining with Other x264 Parameters
If you are already using -x264-params for other settings
(like keyframe intervals or tuning), you can append the nr
parameter by separating the options with a colon (:):
ffmpeg -i input.mp4 -c:v libx264 -crf 20 -x264-params keyint=240:nr=400 output.mp4