VideoRx Learn
You're viewing a free preview lesson. Get the full course

Controlling quality

Hands-on lab

CRF vs. target bitrate

The single most misunderstood choice in the whole pipeline.

CRF is a quality target: the encoder spends whatever bitrate it needs to hold that quality. A bitrate target is a size target: the encoder gives up quality to hit it. Neither is correct in the abstract — they answer different questions.

Run both commands below on the same source and compare the output sizes against the A/B player. Note that:

  • the CRF encode is unpredictable in size and consistent in quality
  • the ABR encode is exactly the reverse

Rule of thumb: CRF for masters and VOD, ABR when a delivery spec dictates the bitrate and you have no say in it.

Hands-on lab 3 steps
  1. 1

    Constant quality (CRF 20)

    Constant quality (CRF 20)
    ffmpeg -i input.mov -c:v libx264 -crf 20 -preset medium -c:a aac -b:a 128k output-crf20.mp4

    Size varies with content. This is what you want for archival and VOD masters.

  2. 2

    Average bitrate (5 Mbps)

    Average bitrate (5 Mbps)
    ffmpeg -i input.mov -c:v libx264 -b:v 5M -maxrate 5.35M -bufsize 7.5M -preset medium -c:a aac -b:a 128k output-abr.mp4

    Predictable size. Use when a delivery spec dictates the bitrate.

  3. 3

    Inspect the result

    Inspect the result
    ffprobe -v error -show_entries format=size,duration,bit_rate -of default=noprint_wrappers=1 output-crf20.mp4

    Always verify rather than assume.

Enroll to tick steps off and track your way through this lab.

Compare the encodes

Both clips play in sync. Scrub either one.

CRF 20
No sample uploaded yet
Size
— MB
VMAF
—
Bitrate
variable
CRF 28
No sample uploaded yet
Size
— MB
VMAF
—
Bitrate
variable