How to Use FFmpeg Smartblur for Edge Preserving Blur
This article explains how to use the smartblur filter in
FFmpeg to apply a selective blur that smooths out noise and details
while preserving sharp edges. You will learn the syntax, key parameters,
and practical command-line examples to achieve clean, edge-aware
blurring in your videos and images.
Understanding the smartblur Filter
The smartblur filter works by applying a blur to the
entire image and then blending it back with the original image based on
a threshold. If the difference between the blurred pixel and the
original pixel is below the threshold (representing flat areas), the
blurred pixel is kept. If it exceeds the threshold (representing edges),
the original pixel is kept, keeping the edge sharp.
The filter accepts parameters for both luma (brightness) and chroma (color) channels.
Key Parameters
luma_radius(lr): The size of the blur radius for the luma channel. Range is0.1to30.0. A larger radius increases the blur area.luma_strength(ls): The strength of the blur for the luma channel. Range is-1.0to1.0. Positive values blur the image, while negative values can actually sharpen it.luma_threshold(lt): The edge preservation threshold for the luma channel. Range is-30to30.- A low threshold (e.g.,
2) preserves almost all edges, blurring only completely flat areas. - A high threshold (e.g.,
20) allows more edges to be blurred, acting more like a standard Gaussian blur.
- A low threshold (e.g.,
chroma_radius(cr): Blur radius for chroma channels (optional).chroma_strength(cs): Blur strength for chroma channels (optional).chroma_threshold(ct): Threshold for chroma channels (optional).
Note: If chroma parameters are not specified, they default to the values of the luma parameters.
Practical command examples
Basic Edge-Preserving Blur
To apply a moderate, clean blur that keeps strong edges intact, use the following command:
ffmpeg -i input.mp4 -vf "smartblur=luma_radius=5:luma_strength=1.0:luma_threshold=5" output.mp4In this command: * luma_radius=5 sets a medium blur
radius. * luma_strength=1.0 applies maximum blur to
non-edge areas. * luma_threshold=5 ensures that any detail
with a contrast difference higher than 5 is treated as an edge and
remains sharp.
Shorthand Syntax
FFmpeg allows you to write this filter more concisely by placing the
values in order (radius:strength:threshold):
ffmpeg -i input.mp4 -vf "smartblur=5:1.0:5" output.mp4Heavy Blur with High Edge Preservation
If you want to heavily blur background textures (like skin blemishes or digital noise) while keeping facial features or text razor-sharp, increase the radius and keep the threshold low:
ffmpeg -i input.mp4 -vf "smartblur=15:1.0:3" output.mp4Tuning Chroma Separately
If you want to smooth out color noise without affecting the brightness details of your video, you can set different values for the chroma channel:
ffmpeg -i input.mp4 -vf "smartblur=lr=1.0:ls=0.0:lt=0:cr=5.0:cs=1.0:ct=5" output.mp4This disables the blur on the luma channel (ls=0.0)
while applying a strong edge-preserving blur only to the color
channels.