Ch. 19 · Diagnosing Video Quality Problems

한국어日本語
7 min

Flicker and Pumping: When Quality Surges Up and Down

When quality varies from frame to frame, it looks like flicker or pumping. It is often caused by keyframe interval and bitrate constraints, and you first need to separate it from flicker that was already in the source.

Flicker and pumping are problems along the time axis. Each frame looks fine on its own, but when played back, brightness or sharpness surges up and down. You can't find them with a still screenshot, so you need to look at consecutive frames or at scores over time.

First check whether it is flicker in the source

  • The source itself flickers. Flicker from fluorescent or LED lighting, refresh-rate mismatch when filming a screen, or auto-exposure has nothing to do with the encode. Play the source at the same segment and you will know.
  • Interlacing problems. Encoding interlaced video as-is or deinterlacing it wrongly produces a once-per-second flicker pattern (Deinterlacing lesson).
  • Frame rate conversion problems. Conversions that repeat or drop frames make motion look choppy, but that is a problem of smoothness, not of picture quality (fps lesson).

Pumping created by the encode

An encoder spends bits differently for each frame type. Keyframes (I) are made expensively without referencing other frames, and the P and B frames in between are made cheaply by referencing frames before and after (Inter prediction lesson). If quality differs slightly by frame type, you can see a periodic surge where the picture gets sharper and then blurrier each time a keyframe arrives.

  • When the keyframe interval (GOP) is long and the bitrate constraint is tight. A pattern can repeat in which quality suddenly rises at a keyframe and then gradually drops in the frames after it.
  • When VBV (`-maxrate`, `-bufsize`) is too tight. A tight bitrate cap makes quality drop quickly in hard scenes and recover in easy ones, so it tends to surge. This commonly happens when you set a cap for streaming (Adaptive streaming).
  • Scene-change handling. A keyframe going in at a scene change and quality shifting suddenly is normal behavior, but it is noticeable if the interval is too short or misaligned.

How to check

Pull out the keyframe (I) timestamps and compare them with the period of the surge
# Frame type and timestamp as CSV. Pick out just the I-frame lines and look at the intervals
ffprobe -v error -select_streams v:0 -show_entries frame=pts_time,pict_type -of csv=p=0 encoded.mkv > frames.csv
# Depending on the ffprobe version, the field may be pkt_pts_time instead of pts_time
Average vmaf.json per second to see the surge over time
import json
from collections import defaultdict

fps = 25.0                      # the video's frame rate
d = json.load(open("vmaf.json"))
bucket = defaultdict(list)
for f in d["frames"]:
    bucket[int(f["frameNum"] / fps)].append(f["metrics"]["vmaf"])
for sec in sorted(bucket):
    v = bucket[sec]
    print(f"{sec:4d}s  mean {sum(v)/len(v):6.2f}  min {min(v):6.2f}")

If the per-second mean swings up and down regularly and the period matches the keyframe interval, pumping is a reasonable suspect. But what VMAF shows is the variation in the score relative to the source, not visible flicker itself. Brightness surges can be visible even when the score varies little, so always play back the suspect segment and look at it by eye.

What to do

  • If you can use CRF mode, use CRF. It fixes the quality target, so it reduces surging caused by a bitrate cap (Chapter 18).
  • When you set a cap (VBV), leave some headroom. A larger -bufsize lets the encoder borrow more bits for hard scenes. If a streaming spec sets values, adjust within them.
  • Check the keyframe interval. If it's too long, the periodic surge gets bigger, and if it's too short, there are many keyframes and efficiency drops. Adaptive streaming needs keyframes at segment boundaries, so check that constraint first (Chapter 10).
  • Check the encoder's temporal smoothing options. x264 and x265 are known to have options that smooth bit allocation between frames, but names and behavior differ by encoder and version, so check the docs.
This site did not measure flicker

The measurement articles covered the mean, 5th percentile, and minimum VMAF over whole clips, and did not measure the relationship between keyframe period and quality surging. The causes and responses above are generally known explanations and are not backed by this site's numbers.

FlickerFlicker

A phenomenon where brightness or quality varies irregularly from frame to frame and the picture shakes. It can be a source problem or created by the encode.

PumpingPumping

A phenomenon where quality regularly gets sharper and then blurrier in step with things like the keyframe period.

VBVVideo buffering verifier

A model that limits bit usage with a decoder buffer size and a maximum bitrate. In ffmpeg you set it with -maxrate and -bufsize.

Check yourself

When you see flicker, what should you do first?

Check yourself

If the per-second mean VMAF rises and falls with the same period as the keyframe interval, what is worth suspecting?