How to Use the FFmpeg sab Filter
This article provides a quick guide on how to use the Shape Adaptive
Blur (sab) filter in FFmpeg to apply smart blurring to your
videos. You will learn the basic syntax of the filter, understand its
key parameters for control over luma and chroma channels, and see
practical command-line examples for preserving edges while reducing
noise.
Understanding the sab Filter
The sab (Shape Adaptive Blur) filter in FFmpeg is
designed to blur smooth areas of an image or video frame while
preserving sharp edges. It is highly effective for noise reduction,
smoothing skin tones, and creating a clean, stylized look without making
the entire video look out of focus.
Filter Syntax and Parameters
The sab filter accepts parameters for both the luma
(brightness) and chroma (color) channels. The basic syntax is:
-vf "sab=luma_radius:luma_pre_filter_radius:luma_strength:chroma_radius:chroma_pre_filter_radius:chroma_strength"Alternatively, you can use named parameters for better readability:
luma_radius/lr: Luma blur radius (range: 0.1 to 1024.0, default: 1.0). Controls the size of the blur on the brightness channel.luma_pre_filter_radius/lpf: Luma pre-filter radius (range: 0.1 to 1024.0, default: 1.0). Used to detect edges before applying the blur.luma_strength/ls: Luma strength (range: 0.1 to 100.0, default: 1.0). Determines the maximum difference between pixels to be blurred. Larger values blur more diverse pixels; smaller values preserve finer details.chroma_radius/cr: Chroma blur radius (range: 0.1 to 1024.0, default: 1.0). Controls the blur size on color channels.chroma_pre_filter_radius/cpf: Chroma pre-filter radius (range: 0.1 to 1024.0, default: 1.0).chroma_strength/cs: Chroma strength (range: 0.1 to 100.0, default: 1.0).
Practical Examples
1. Basic Edge-Preserving Blur
To apply a mild, edge-preserving blur to the luma channel of a video, use the following command:
ffmpeg -i input.mp4 -vf "sab=lr=4.0:lpf=2.0:ls=5.0" -c:a copy output.mp42. Denoising and Smoothing Skin Tones
To reduce noise and smooth skin tones while keeping outlines sharp, you can increase the luma strength and apply a mild blur to both luma and chroma:
ffmpeg -i input.mp4 -vf "sab=lr=5:lpf=1:ls=10:cr=3:cpf=1:cs=5" -c:a copy output.mp43. Extreme Stylized Blur
For a heavy, painted-like effect where only the strongest borders are preserved, increase the radii and strength:
ffmpeg -i input.mp4 -vf "sab=lr=12.0:lpf=4.0:ls=25.0" -c:a copy output.mp4