FFmpeg BM3D Filter Guide: Function and Block Size

The bm3d filter in FFmpeg is a powerful denoising tool based on the Block-Matching and 3D filtering algorithm, which is highly effective at removing noise while preserving sharp details and edges in video. This article explains the core function of the bm3d filter and provides clear, step-by-step instructions on how to configure its block size parameter to optimize your video processing workflow.

Function of the bm3d Denoising Filter

The bm3d (Block-Matching and 3D filtering) filter is an advanced image and video denoising algorithm. Unlike simpler filters that average neighboring pixels, bm3d works by grouping similar-looking 2D image patches (blocks) from across the frame into 3D arrays.

Once these groups are formed, the filter applies a collaborative filtering process in a 3D transform domain (such as Wavelet or DCT). This allows the algorithm to easily distinguish actual image details (which are correlated across the blocks) from random noise (which is uncorrelated). After filtering, the 3D blocks are transformed back, and the overlapping patches are averaged to reconstruct a clean, denoised frame. This method is exceptionally good at preserving fine textures and sharp edges, though it is highly computationally intensive.

How to Configure the Block Size

In FFmpeg, you can control the size of the blocks used for the matching process using the block parameter.

The syntax for the bm3d filter is: bm3d=sigma=<value>:block=<value>

The block Parameter

Choosing the Right Block Size

Example FFmpeg Commands

To apply the bm3d filter with a custom block size, use the -vf (video filter) flag.

Example 1: Standard denoising with default \(8 \times 8\) block size

ffmpeg -i input.mp4 -vf "bm3d=sigma=3:block=8" output.mp4

Example 2: Heavy denoising using a larger \(16 \times 16\) block size

ffmpeg -i input.mp4 -vf "bm3d=sigma=5:block=16" output.mp4

(Note: sigma represents the noise standard deviation; higher values increase the overall denoising strength.)