FFmpeg BM3D Filter Tutorial for Video Denoising

This article provides a comprehensive guide on how to use the BM3D (Block-Matching and 3D filtering) denoiser in FFmpeg. You will learn the basic command syntax, key parameters for fine-tuning noise reduction, and how to execute both single-pass and high-quality two-pass denoising to achieve professional-grade video clean-up.

Understanding the FFmpeg BM3D Filter

BM3D is a state-of-the-art image and video denoising algorithm. It works by grouping similar 2D image patches into 3D data arrays (block-matching) and collaborative filtering them in the transform domain.

Because of its mathematical complexity, the bm3d filter in FFmpeg is highly effective at removing heavy noise while preserving sharp edges, but it is computationally expensive and slow compared to simpler filters like hqdn3d or nlmeans.

Basic Command Syntax

The simplest way to apply the BM3D filter is to run a single-pass denoising command using the basic mode.

ffmpeg -i input.mp4 -vf "bm3d=sigma=20:mode=basic" output.mp4

In this command: * sigma sets the denoising strength (standard deviation of the noise). Higher values remove more noise but can blur fine details. * mode=basic tells FFmpeg to perform the initial thresholding pass.

Key Parameters of the BM3D Filter

You can customize the filter behavior using several parameters appended to the filter string, separated by colons:

Advanced Two-Pass Denoising (Highest Quality)

To get the absolute best results from BM3D, you should use the two-pass approach. In the first pass, a “basic” estimate is created. In the second pass, this estimate is used as a reference to perform empirical Wiener filtering (mode=final).

You can achieve this in a single FFmpeg command using a complex filtergraph to split the input stream:

ffmpeg -i input.mp4 -filter_complex "[0:v]split[original][ref];[ref]bm3d=sigma=20:mode=basic[basic_estimate];[original][basic_estimate]bm3d=sigma=20:mode=final" output.mp4

How the Filtergraph Works:

  1. split duplicates the input video into two identical streams: [original] and [ref].
  2. The [ref] stream is processed with bm3d in basic mode to generate a preliminary clean stream named [basic_estimate].
  3. The [original] stream and the [basic_estimate] stream are fed together into a second bm3d filter set to mode=final. This produces the final, highly-detailed denoised output.

Speed Optimization Tips

Because BM3D is CPU-intensive, you can use these adjustments to speed up rendering: