How to Use FFmpeg smartblur Filter with Custom Thresholds
This guide explains how to use the smartblur filter in
FFmpeg to apply a smooth blur to your videos while preserving sharp
edges. You will learn the exact syntax, how to adjust the custom
threshold parameters for both luma and chroma channels, and see
practical command-line examples to achieve the perfect balance between
noise reduction and detail preservation.
Understanding the smartblur Syntax
The smartblur filter works by blurring areas of the
video that have low contrast (flat areas) while leaving high-contrast
areas (edges) untouched. The basic syntax for the filter is:
smartblur=luma_radius:luma_strength:luma_threshold[:chroma_radius:chroma_strength:chroma_threshold]You can also use the shorthand parameter names:
- lr / cr (Luma/Chroma Radius): Controls the size of
the blur. Allowed range is
0.1to5.0. - ls / cs (Luma/Chroma Strength): Controls the
intensity of the blur. Allowed range is
-1.0to1.0. Positive values blur the video, while negative values sharpen it. - lt / ct (Luma/Chroma Threshold): The crucial
setting that defines what is considered an edge. Allowed range is
-30to30.
A threshold value of 0 filters everything. A positive
threshold filters only flat areas (preserving edges), while a negative
threshold filters only edges (preserving flat areas).
Practical FFmpeg Command Examples
1. Basic Luma Blur with Custom Edge Preservation
To apply a moderate blur to the brightness (luma) channel while keeping the edges of objects sharp, use a positive threshold. Run the following command:
ffmpeg -i input.mp4 -vf "smartblur=luma_radius=3.0:luma_strength=1.0:luma_threshold=5" output.mp4In this command: * luma_radius=3.0 sets a medium-sized
blur radius. * luma_strength=1.0 applies the maximum blur
effect within that radius. * luma_threshold=5 ensures that
any pixel difference greater than 5 (an edge) is not blurred, keeping
details sharp.
2. Advanced Blur (Custom Luma and Chroma Settings)
If you want to blur both the brightness details and the color (chroma) channels independently, you can define all six parameters. This is highly useful for smoothing out color blotches or digital noise:
ffmpeg -i input.mp4 -vf "smartblur=lr=2.5:ls=0.8:lt=4:cr=1.5:cs=0.5:ct=2" output.mp4In this command: * lr=2.5:ls=0.8:lt=4 applies a strong,
edge-preserving blur to the luma channel. *
cr=1.5:cs=0.5:ct=2 applies a milder, more sensitive blur to
the color channels to blend noisy color patches without bleeding over
prominent edges.