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.
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.
# 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.mkvDeblocking 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.
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.
Distortion where block-by-block quantization makes values mismatch at the boundaries of neighboring blocks, so square pieces become visible.
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.
At low bitrate, square block boundaries show up only in high-motion scenes. What should you try first?
Which statement about blocking is correct when the source itself is already heavily compressed?