FFmpeg BM3D Filter: Block Size, Step, and Search Range

The FFmpeg bm3d (Block-Matching and 3D filtering) filter is a highly effective denoising tool that reduces image and video noise while preserving edge details. To optimize this filter for your specific video source, you need to understand and adjust its three critical parameters: block size, step size, and search range. This guide explains what these parameters do and provides practical command-line examples to help you configure them for the best balance between processing speed and visual quality.

Understanding the Core Parameters

The bm3d filter works by grouping similar blocks of pixels in a 3D array and collaborative-filtering them. You can control this process using the following settings:

How to Configure the Parameters in FFmpeg

To apply the bm3d filter, you must specify the parameters inside the -vf (video filter) flag. The basic syntax for configuring the block size, step size, and search range is:

ffmpeg -i input.mp4 -vf "bm3d=block=8:step=4:range=9" output.mp4

Configuration Examples

Depending on your hardware capability and your priority (speed vs. quality), you can use one of the configurations below:

1. High-Quality Denoising (Slow Processing)

If you want the best possible visual output and do not mind long render times, decrease the step size and increase the search range:

ffmpeg -i input.mp4 -vf "bm3d=block=8:step=2:range=16" -c:v libx264 -crf 18 output.mp4

2. Fast Processing (Draft/Preview Mode)

If you need to quickly test the filter or have limited computing power, increase the step size and lower the search range:

ffmpeg -i input.mp4 -vf "bm3d=block=8:step=6:range=5" -c:v libx264 -crf 18 output.mp4

3. Handling Fine Details in High-Resolution Video

For 4K videos or content with fine textures where you want to avoid a “plastic” or overly smoothed look, reduce the block size:

ffmpeg -i input.mp4 -vf "bm3d=block=4:step=2:range=12" -c:v libx264 -crf 18 output.mp4

Tips for Best Results