FFmpeg Bilateral Filter for Edge-Preserving Denoising

This guide explains how to use FFmpeg's built-in bilateral filter to remove noise from video footage while keeping sharp edges intact. You will learn the core command syntax, how the primary filter parameters function, and practical command-line examples for achieving clean, edge-preserved video output.

The Basic Command

FFmpeg includes a dedicated bilateral video filter. To apply the default bilateral filter to a video, run:

ffmpeg -i input.mp4 -vf "bilateral" -c:a copy output.mp4

Understanding Bilateral Filter Parameters

The bilateral filter smooths images while respecting edges by calculating weights based on both geometric closeness (spatial distance) and photometric similarity (color/luminance difference). You can tune this behavior using two main parameters:

  • sigmaS (Spatial Sigma): Sets the spatial variance of the filter. It controls the neighborhood size around each pixel to consider for blurring. Higher values consider pixels farther away, producing a stronger spatial blur. The allowed range is 0.1 to 512.0 (default is 3.0).
  • sigmaR (Range Sigma): Sets the range variance. It determines how different a neighboring pixel's color or brightness can be while still being blurred together. Lower values strictly preserve edges by only blending pixels with nearly identical values. Higher values treat larger differences as smooth surfaces, potentially blurring across edges. The allowed range is 0.0 to 1.0 (default is 0.1).
  • planes: Specifies which video planes to process (Y, U, V, Alpha). By default, it processes all available planes (7 for standard YUV video).

Practical Examples

Light Denoising (Preserving Fine Detail)

For high-definition video with mild sensor noise where you want to keep textures and edges crisp, keep both sigmaS and sigmaR low:

ffmpeg -i input.mp4 -vf "bilateral=sigmaS=2.0:sigmaR=0.05" -c:v libx264 -crf 18 -c:a copy output.mp4

Moderate Denoising (General Purpose)

For standard grain reduction without significant edge degradation:

ffmpeg -i input.mp4 -vf "bilateral=sigmaS=5.0:sigmaR=0.1" -c:v libx264 -crf 18 -c:a copy output.mp4

Heavy Denoising (High Noise or Grain)

For footage shot in low light with noticeable noise, increase the spatial radius and allow slightly more range variance:

ffmpeg -i input.mp4 -vf "bilateral=sigmaS=9.0:sigmaR=0.2" -c:v libx264 -crf 18 -c:a copy output.mp4

Filtering Luma Only

Processing only the luminance (Y) plane can speed up processing and prevent color smearing. To target only the Y plane, set planes=1:

ffmpeg -i input.mp4 -vf "bilateral=sigmaS=4.0:sigmaR=0.08:planes=1" -c:v libx264 -crf 18 -c:a copy output.mp4