JA EN
LearnMedia in Production
·★ MEMBER·7 min read

How to Read Encoder Settings — What CRF, Presets, and 2-Pass Actually Change

The flags in an ffmpeg command — -crf 23, -preset slow, -pass 2 — each answer a different question: what to hold constant (CRF), how hard to search (preset), and whether to read the whole video first (2-pass). We derive why each knob works from the quantization-step formula and rate-distortion optimization, then land on copy-paste-ready commands and the mistakes that bite in production.

ModalityimageTaskpractice

An Analogy: Three Instructions for a Moving Company

Video encoder settings map surprisingly well onto instructions you might give a moving company.

The first instruction: do you fix the budget, or fix the outcome? If you book two trucks' worth of budget, the cost is fixed no matter how much stuff you own. That is a bitrate target. If instead you say "don't break a single dish — use as many trucks as it takes," the outcome is fixed and the cost floats. That is CRF (a quality target).

The second: how carefully do the movers pack? Given more time, they pack boxes with no wasted space, and the same outcome needs fewer boxes. That is the preset. Fast presets pack sloppily; slow presets pack tightly.

The third: do they walk through the house before packing? Scouting the whole place first lets them plan — big boxes for the bookshelf, small ones for the bathroom. That is 2-pass encoding.

These are three independent knobs. Most confusion about encoder settings comes from mixing them up, so let's open each one.

Intuition: Three Knobs, Three Different Questions

Take a command you'll see everywhere and split it into the questions it answers:

ffmpeg -i input.mp4 -c:v libx264 -crf 23 -preset slow -c:a copy output.mp4

A widespread misconception is "a slower preset gives you better quality." Under CRF that's half wrong: the correct statement is quality stays roughly the same and the file gets smaller. The preset is not a quality knob; it's a knob for how much it costs to reach that quality.

The Root of Everything: QP, or "How Coarsely Do We Round?"

To understand what the three knobs do, you need the single number sitting underneath them all: the quantization parameter (QP).

As covered in video compression from scratch, an encoder splits frames into blocks, transforms them into frequency coefficients, and throws information away by dividing and rounding those coefficients. The divisor — the quantization step — is set in H.264 by an integer QP from 0 to 51, through this relation:

Qstep2QP/6Q_{\text{step}} \propto 2^{QP/6}
(1)

In plain words: every time QP goes up by 6, the rounding gets twice as coarse. Here QstepQ_{\text{step}} is the divisor (larger means more information discarded), and QPQP is the integer the encoder picks scene by scene. A small QP keeps the coefficients nearly intact — high quality, big file. A large QP flattens most of them to zero — low quality, small file. Every quality/size trade in video encoding is, at bottom, a tug-of-war over this one number.

You can feel what coarse rounding does to a picture right here — this demo is still images, but the principle is identical:

FIG 1Crank up the quantization and coefficients collapse to zero while block noise surfaces. CRF and QP are, at heart, turning exactly this knob

So what does `-crf 23` do? The naive version of "constant quality" would use the same QP for every block (that mode exists — CQP). CRF (Constant Rate Factor) goes a step further.

What's behind this

§

Members-only from here

371 walkthroughs, 26 textbook chapters, 48 student units and 6 close readings — all included for $4.99/mo, with three new explainers every day. Cancel any time; access runs to the end of the period.

Already a member? Sign in to keep reading

Comments

Sign in to comment