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

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.mp4

In 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.mp4

Heavy 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.mp4

Tuning 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.mp4

This disables the blur on the luma channel (ls=0.0) while applying a strong edge-preserving blur only to the color channels.