The Diagnostic Order: Telling Artifacts Apart from Screenshots
The first step is turning 'the quality looks off' into a symptom you can name. Three questions (where it appears, what shape it has, and whether it changes over time) separate six kinds of artifacts.
A complaint that the quality is bad is usually not one single phenomenon. Bands in the sky, messy edges around text, and a grid pattern have different causes and different fixes. Raising the bitrate sounds like it would cure everything, but some symptoms come from bit depth or color settings, not bitrate. This chapter goes in this order: name the symptom, narrow down the cause, and pick the matching knob.
Three questions to sort them out
1Where does it appear? In flat areas (sky, walls, dark backgrounds), around sharp edges (text, outlines), or across the whole frame.
2What shape is it? A grid or square pieces, stair-step bands, smudges or ripples that run along edges, or color leaking sideways.
3Does it change over time? Is it visible in a still frame, only when things move, or does it repeat at regular intervals?
The 'first suspect' is simply the first candidate to check. The real cause may be two or more things stacked together.
Things to watch for when telling them apart from screenshots
Look at the same frame from the source side by side. With only the output, you can't tell whether what you see was already in the source (camera noise, a gradient that was always there) or was created by the encode.
Save as a lossless format such as PNG. If you save as JPEG, JPEG compression adds new blocking and ringing and muddies the diagnosis (the same principle as JPEG's 8×8 blocks).
Zoom in by an integer factor with nearest-neighbor interpolation. Enlarging with smooth interpolation can blur things or add new ringing, so a method that leaves each pixel as a visible square shows the symptom most honestly.
Don't screen-capture a player; extract frames straight from the file. A player mixes in its own scaler, post-processing, and the monitor's color conversion. If the problem you see in the player differs from the one you see in the file, the cause may be playback, not the encode.
Don't judge temporal behavior from a single still. Flicker and mosquito noise can't be seen in one frame, so you need to look at several consecutive frames.
Extract the same timestamp from the source and the output as PNG, zoom a region 3x, and stitch them side by side
# At 12.4 s, take the 320x180 region at (800,400), enlarge it 3x (nearest-neighbor), and join the two left/right
ffmpeg -ss 12.4 -i reference.y4m -ss 12.4 -i encoded.mkv -frames:v 1 \
-filter_complex "[0:v]crop=320:180:800:400,scale=iw*3:ih*3:flags=neighbor[a];[1:v]crop=320:180:800:400,scale=iw*3:ih*3:flags=neighbor[b];[a][b]hstack" \
compare.png
hstack needs both inputs to have the same format
If the height or pixel format differs, you get an error (the widths may differ). If the source is in a different format, add a conversion such as format=yuv420p to each input to match them. Notation like [0:v] in the filter graph was covered in Filter graph syntax. How -ss behaves is summarized in Lesson 7.
Naming it is half the battle
From the next lesson on, we go through each symptom in order: cause → fix → limits. Keep in mind that the fix is not 'raise the bitrate' but a different knob for each symptom.
ArtifactArtifact
A general term for distortion that wasn't in the source and was introduced by compression, conversion, or filtering. Blocking, ringing, and banding are examples.
Nearest-neighbor scalingNearest-neighbor scaling
An enlargement method that scales up pixels without blending them. Each pixel shows as a square, which makes it well suited to examining artifacts.
Check yourself
What is the best way to diagnose an artifact from screenshots?
Check yourself
'It is visible even in a still frame, and a gentle gradient in the sky shows stair-step bands.' Which symptom is closest?