How to Use the FFmpeg Deblock Filter
This article provides a straightforward guide on how to use the
deblock filter in FFmpeg to reduce blockiness and
compression artifacts in your videos. You will learn the basic syntax,
the key parameters of the filter, and practical command-line examples to
improve your video quality.
Understanding the Deblock Filter
The deblock filter in FFmpeg is designed to reduce the
“blocking” artifacts that often appear in highly compressed videos,
especially in areas of flat color or slow motion. It works by smoothing
the edges between compression blocks.
Basic Syntax
To apply the default deblocking settings to a video, use the following basic FFmpeg command:
ffmpeg -i input.mp4 -vf "deblock" output.mp4Filter Parameters
You can fine-tune the deblocking strength and behavior using specific parameters. The filter accepts the following options:
block: Sets the size of the block to be processed. This value must be a multiple of 4, ranging from 4 to 512. The default value is8.alpha: Controls the threshold for detection of block boundaries. A higher value increases the deblocking strength for stronger artifacts. The range is from-6to6, with a default of0.beta: Controls the threshold for detail preservation. Higher values smooth more details along with the blocks. The range is from-6to6, with a default of0.planes: Specifies which color planes to filter. The value is a bitmask (1 for Y, 2 for U, 4 for V, 8 for Alpha). The default is15, which filters all planes.
Practical Examples
1. Adjusting Filter Strength
If the default settings are too weak, you can increase the
alpha and beta parameters to apply stronger
smoothing:
ffmpeg -i input.mp4 -vf "deblock=alpha=2:beta=2" output.mp42. Changing the Block Size
To target larger compression blocks, increase the block
size parameter (for example, to 16):
ffmpeg -i input.mp4 -vf "deblock=block=16" output.mp43. Combining Parameters
You can combine multiple parameters to customize the filter for severely pixelated videos:
ffmpeg -i input.mp4 -vf "deblock=block=12:alpha=3:beta=3" output.mp4By adjusting these parameters, you can find the right balance between removing block artifacts and preserving the original details of your video.