How to Use FFmpeg Deblock Filter to Fix Blocky Video
This article explains how to use the FFmpeg deblock
filter to reduce blockiness and compression artifacts in old or
low-bitrate videos. You will learn the essential parameters of the
filter, the correct command syntax, and practical examples to help you
restore visual quality to your digital archives.
Understanding the FFmpeg Deblock Filter
Highly compressed or older digital videos often suffer from
“blocking”—visible square patterns caused by block-based compression
algorithms (like MPEG-2 or early H.264). The FFmpeg deblock
filter smooths out these block boundaries to make the video appear
cleaner and more continuous.
The basic syntax for applying the filter is:
ffmpeg -i input.mp4 -vf "deblock" output.mp4Key Parameters of the Deblock Filter
To get the best results, you can fine-tune the filter using three
main parameters: blocksize, alpha, and
beta.
blocksize: Sets the size of the blocks to be analyzed.- Default:
8 - Range:
4to512(must be a multiple of 4) - Usage: Most older video codecs use 8x8 or 16x16 blocks. Set this to match the approximate size of the blocky artifacts in your video.
- Default:
alpha: Controls the threshold for detection of block boundaries.- Default:
0.098 - Range:
0.0to1.0 - Usage: Higher values increase the filter’s willingness to smooth out edges, resulting in a stronger deblocking effect.
- Default:
beta: Controls the threshold for flat areas inside the blocks.- Default:
0.05 - Range:
0.0to1.0 - Usage: Higher values will smooth details inside the blocks. Adjust this if you see banding or block textures inside flat areas like skies or walls.
- Default:
Practical Examples
1. Default Deblocking
For minor compression issues, the default settings are often sufficient. This command applies the default deblock filter and re-encodes the video using the H.264 codec:
ffmpeg -i input.mp4 -vf "deblock" -c:v libx264 -crf 18 -c:a copy output.mp42. Strong Deblocking for Highly Compressed Video
For older, highly pixelated videos (such as low-resolution 240p or
360p clips), you should increase the alpha and
beta values to apply a stronger smoothing effect:
ffmpeg -i input.mp4 -vf "deblock=blocksize=8:alpha=0.2:beta=0.15" -c:v libx264 -crf 18 -c:a copy output.mp43. Combining Deblock with Denosing and Sharpening
Deblocking can sometimes make a video look slightly blurry. To
counteract this, you can combine the deblock filter with a
denoiser (hqdn3d) and a subtle sharpening filter
(unsharp) in a single filterchain:
ffmpeg -i input.mp4 -vf "deblock=blocksize=8:alpha=0.12:beta=0.08,hqdn3d,unsharp=3:3:0.5:3:3:0.5" -c:v libx264 -crf 18 -c:a copy output.mp4Using these configurations will help you significantly reduce block artifacts and improve the overall viewing experience of legacy video files.