How to Use the sab Filter in FFmpeg

The FFmpeg sab (Shape Adaptive Blur) filter is a video filter used to apply edge-preserving blur to video streams. This article provides a quick guide on how the sab filter works, explains its key parameters, and demonstrates practical command-line examples to help you effectively denoise or smooth your videos while maintaining sharp edges.

Understanding the sab Filter Parameters

The sab filter works by adapting the blur shape to the features of the image, which helps prevent the blurring of sharp edges. It accepts several options, divided between luma (brightness) and chroma (color) channels.

Practical FFmpeg Examples

To use the sab filter, pass it to the -vf (video filter) flag in your FFmpeg command.

1. Basic Edge-Preserving Smoothing

To apply a mild, balanced blur that smooths out flat surfaces while keeping edges sharp, use the default settings:

ffmpeg -i input.mp4 -vf "sab" output.mp4

2. Strong Denoising

If you have a noisy video and want to aggressively smooth the flat areas while preserving the main outlines, increase the luma radius and strength:

ffmpeg -i input.mp4 -vf "sab=luma_radius=8.0:luma_pre_filter_radius=1.5:luma_strength=5.0" output.mp4

Using short-hand notation, this command can be written as:

ffmpeg -i input.mp4 -vf "sab=lr=8.0:lpfr=1.5:ls=5.0" output.mp4

3. Independent Luma and Chroma Filtering

To apply a strong blur to the brightness (luma) channel but keep the color (chroma) channel processing minimal, define both sets of parameters:

ffmpeg -i input.mp4 -vf "sab=lr=6.0:lpfr=1.0:ls=4.0:cr=2.0:cpfr=0.5:cs=1.0" output.mp4