Ch. 11 · Measuring Video Quality in Practice

한국어日本語
8 min

Measurement Pitfalls: Resolution, Frame Alignment, and Color Range

If a score looks strangely low, the measurement setup is more likely wrong than the codec. Check the three classic pitfalls.

VMAF and PSNR compare pixels on the assumption that the two videos are the same frame at the same position. If that assumption breaks, the score comes out low no matter how well the encoder did its job. When a score doesn't make sense, check the measurement setup before you suspect the codec.

Pitfall 1. The resolutions differ

To compare a video whose resolution was lowered during encoding (for example, the 720p rung of a ladder) against the original (1080p), you have to make the two the same size. The usual approach is to scale the result up to the original resolution before comparing. If you feed in mismatched sizes as they are, you get an error, or unintended processing can sneak in. How you scaled up (bicubic, for example) also affects the score, so write it down.

Pitfall 2. The frames are misaligned

  • The frame counts differ. One side may have its beginning trimmed, or the counts may differ because of frame-rate conversion or VFR (variable frame rate). Compare the frame count and fps from ffprobe first.
  • The start times (timestamps) differ. Depending on the container, the first frame's PTS may not be 0. It's safe to set both inputs to start at 0 with setpts=PTS-STARTPTS.
  • The frames are off by one. The symptom is "every frame scores evenly low." Open the per-frame score log and you'll see the whole video sitting low, which is how you tell it apart.

Pitfall 3. The color range or pixel format differs

As you learned in Chapter 1, YUV comes in limited range (16 to 235 at 8-bit) and full range (0 to 255). If one side is interpreted as limited and the other as full, the brightness shifts across the board and the score drops. Make the pixel formats (yuv420p versus 10-bit, and so on) match between the two inputs as well. Check color_range and pix_fmt on both sides with ffprobe.

Compare the conditions of both videos before you measure
ffprobe -v error -select_streams v:0 -count_frames \
  -show_entries stream=width,height,pix_fmt,color_range,r_frame_rate,nb_read_frames \
  -of default=noprint_wrappers=1 reference.y4m

ffprobe -v error -select_streams v:0 -count_frames \
  -show_entries stream=width,height,pix_fmt,color_range,r_frame_rate,nb_read_frames \
  -of default=noprint_wrappers=1 encoded.mkv

# Check that width/height, pix_fmt, color_range, and the frame count match in both outputs
How the measurement article avoided these pitfalls

The average VMAF measurement on this site fixed the input to the first 250 frames of a yuv420p 8-bit, 1920x1080, 25 fps source, and compared each encoded result frame by frame against the same source. With no resolution conversion or frame-rate conversion, the design leaves little room for the three pitfalls above to creep in from the start.

A checklist of suspicious symptoms

① Scores are evenly low on every frame → frame misalignment or a color range mismatch. ② Only the first few frames are low → a start-time difference or something special about the first frame. ③ Scores are abnormally high or stuck at 100 → check that you didn't feed in the same file twice. If you can't find the cause, pull one frame as a PNG from each side with ffmpeg and compare them by eye.

Frame alignmentFrame alignment

Making sure frames from the same moment in the two videos being compared are paired up.

PTSPresentation timestamp

The time at which a frame is shown. If the two videos start at different times, the pairing goes out of step.

Color range (limited / full)Color range

Whether brightness uses 16 to 235 or 0 to 255 at 8-bit.

VFRVariable frame rate

Video whose frame spacing is not constant. A common cause of mismatched frame counts.

CFRConstant frame rate

Video whose frames always sit at the same interval. At 30 fps that is about 33.3 ms per frame. Check for VFR with the tool 'Variable Frame Rate (VFR) Detector'; converting VFR to CFR duplicates or drops frames, so it requires re-encoding.

Check yourself

The VMAF of an encoded result came out strangely low, evenly across every frame. What should you check first?