Ch. 19 · Diagnosing Video Quality Problems

한국어日本語
7 min

Blocking: When You See Square Pieces

Blocking happens because quantization is done block by block. The main fix is less coarse quantization (CRF or bitrate), and next is adjusting deblocking strength. If the source is already full of blocks, encoder settings can't undo that.

An encoder splits the picture into blocks and predicts them, then transforms and quantizes the remaining difference (the residual) (Quantization lesson). When quantization gets coarse, each block gets smeared in its own way, and values suddenly jump between neighboring blocks. When you can see those boundaries, that is blocking.

Why it happens

  • Quantization is coarse. When CRF is high or the target bitrate falls short, many coefficients are thrown away in each block. Most blocking comes from this.
  • The scene is hard. Fast motion or lots of detail makes it easy to run short of bits even at the same CRF. In this site's measurements too, results at the same CRF differed a lot from clip to clip (Why the same CRF gives different results).
  • The in-loop filter is weak or turned off. The deblocking filter is designed to smooth block boundaries (In-loop filter lesson). In some cases you can change its strength through encoder settings.
  • The source already has blocks. If you re-encode video that was heavily compressed once before, those blocks go in as the input (generation loss, Chapter 18).

Fixes

KnobWhat it doesCost and limits
Lower CRF / raise bitrateLess coarse quantization → fewer mismatches at block boundariesFile size grows. For easy video you may already be saturated
Use a slower presetTends to give the same quality with fewer bits (x265 measurements in Chapter 18)Takes time. If the blocking comes from too few bits, the preset alone may not be enough
Adjust deblocking strengthx264 and x265 are known to have options that set deblocking strengthToo strong and detail gets blurred. Check option names and ranges in the encoder docs
Playback-side post-processingSome players soften blocks during playbackYour file stays as it is, and it varies by viewer device
Get the source againIf the input already has blocks, this is the real fixIf you can't, give up or soften it with something like denoising

Check x264 and x265 options with ffmpeg -h encoder=libx264 and each encoder's documentation. This site has not measured the effect of the deblocking option.

Example: try the deblocking option (the values are only a starting point; always verify on your own video)
# x264: set deblocking alpha:beta. Compare the same segment while moving it weaker/stronger than default
ffmpeg -ss 30 -t 10 -i input.mp4 -c:v libx264 -preset slow -crf 24 \
  -x264-params deblock=1:1 -an test_deblock.mkv
Deblocking 'hides' blocks; it does not 'restore' them

Deblocking can't bring back information that was already discarded; it only softens the mismatch at the boundaries. If the blocking comes from too few bits, spend bits first and touch deblocking strength afterward. This site has no size or quality numbers for deblocking settings, so it states no numeric effect.

In practice: when blocking shows up only in certain segments

If blocking appears only in some scenes (a fast pan, fireworks, heavy rain) and not throughout, the average bitrate is enough and it is short only in those scenes. It may not show up well in the mean VMAF, so, as in the trap of averages, you need to look at the minimum and the lowest segments. How to find those segments is covered in Lesson 7.

Blocking artifactBlocking artifact

Distortion where block-by-block quantization makes values mismatch at the boundaries of neighboring blocks, so square pieces become visible.

Generation lossGeneration loss

The effect where each time lossy-compressed video is lossy-compressed again, quality drops further and the distortion from earlier stages stays in the input.

Check yourself

At low bitrate, square block boundaries show up only in high-motion scenes. What should you try first?

Check yourself

Which statement about blocking is correct when the source itself is already heavily compressed?