{
  "schemaVersion": 1,
  "contentVersion": "ca42e61ede0a24f789d7287a0001244ad22f4abf",
  "id": "docs/guides/quality-controls",
  "collection": "docs",
  "title": "Quality controls: CRF, bitrate and presets",
  "description": "How CRF, constant QP, average-bitrate, constant-bitrate, VBV-capped and two-pass encoding work, and when to use each.",
  "canonicalUrl": "https://encode.wiki/guides/quality-controls/",
  "apiUrl": "https://encode.wiki/api/v1/documents/docs/guides/quality-controls.json",
  "markdownUrl": "https://encode.wiki/api/v1/markdown/docs/guides/quality-controls.md",
  "status": "current",
  "tags": [
    "rate-control",
    "quality"
  ],
  "license": "CC BY-SA 4.0",
  "dates": {
    "lastVerified": "2026-10-08T00:00:00.000Z"
  },
  "authors": [],
  "sources": [
    {
      "title": "FFmpeg encoders documentation — libx264, libx265, libvpx, libaom and libsvtav1 options",
      "url": "https://ffmpeg.org/ffmpeg-codecs.html",
      "accessedAt": "2026-10-08T00:00:00.000Z"
    },
    {
      "title": "FFmpeg wiki — H.264 encoding guide (CRF and two-pass)",
      "url": "https://trac.ffmpeg.org/wiki/Encode/H.264",
      "accessedAt": "2026-10-08T00:00:00.000Z"
    },
    {
      "title": "SVT-AV1 v4.2.0 — common questions (rate control and multi-pass)",
      "url": "https://gitlab.com/AOMediaCodec/SVT-AV1/-/blob/v4.2.0/Docs/CommonQuestions.md",
      "accessedAt": "2026-10-08T00:00:00.000Z"
    },
    {
      "title": "SVT-AV1 v4.2.0 — parameters",
      "url": "https://gitlab.com/AOMediaCodec/SVT-AV1/-/blob/v4.2.0/Docs/Parameters.md",
      "accessedAt": "2026-10-08T00:00:00.000Z"
    },
    {
      "title": "FFmpeg libvpxenc.c at n9.0.2 (CRF without a bitrate selects constant quality)",
      "url": "https://github.com/FFmpeg/FFmpeg/blob/n9.0.2/libavcodec/libvpxenc.c",
      "accessedAt": "2026-10-08T00:00:00.000Z"
    },
    {
      "title": "FFmpeg libaomenc.c at n9.0.2 (default CRF and constrained quality)",
      "url": "https://github.com/FFmpeg/FFmpeg/blob/n9.0.2/libavcodec/libaomenc.c",
      "accessedAt": "2026-10-08T00:00:00.000Z"
    }
  ],
  "headings": [
    {
      "depth": 2,
      "text": "CRF and constant quality",
      "anchor": "crf-and-constant-quality"
    },
    {
      "depth": 2,
      "text": "Cap the bitrate with VBV",
      "anchor": "cap-the-bitrate-with-vbv"
    },
    {
      "depth": 2,
      "text": "Hit a file size with two passes",
      "anchor": "hit-a-file-size-with-two-passes"
    },
    {
      "depth": 2,
      "text": "Testing settings",
      "anchor": "testing-settings"
    }
  ],
  "sections": [
    {
      "id": "_preamble",
      "title": "Page introduction",
      "depth": 0,
      "canonicalUrl": "https://encode.wiki/guides/quality-controls/",
      "apiUrl": "https://encode.wiki/api/v1/sections/docs/guides/quality-controls/_preamble.json",
      "markdownUrl": "https://encode.wiki/api/v1/sections/docs/guides/quality-controls/_preamble.md",
      "checksum": "70a33816e155450e7e93ce4450f8eca9d413fb52eff01caad95a04c642a4223c",
      "bytes": 1588
    },
    {
      "id": "crf-and-constant-quality",
      "title": "CRF and constant quality",
      "depth": 2,
      "anchor": "crf-and-constant-quality",
      "canonicalUrl": "https://encode.wiki/guides/quality-controls/#crf-and-constant-quality",
      "apiUrl": "https://encode.wiki/api/v1/sections/docs/guides/quality-controls/crf-and-constant-quality.json",
      "markdownUrl": "https://encode.wiki/api/v1/sections/docs/guides/quality-controls/crf-and-constant-quality.md",
      "checksum": "e5448d7761adc2b257d27a696b57cd802cf1dbb00af4c85b9542eec246aadfe8",
      "bytes": 2127
    },
    {
      "id": "cap-the-bitrate-with-vbv",
      "title": "Cap the bitrate with VBV",
      "depth": 2,
      "anchor": "cap-the-bitrate-with-vbv",
      "canonicalUrl": "https://encode.wiki/guides/quality-controls/#cap-the-bitrate-with-vbv",
      "apiUrl": "https://encode.wiki/api/v1/sections/docs/guides/quality-controls/cap-the-bitrate-with-vbv.json",
      "markdownUrl": "https://encode.wiki/api/v1/sections/docs/guides/quality-controls/cap-the-bitrate-with-vbv.md",
      "checksum": "a29035665d1fed6397d85a747aac8bcb9a7eab69d6c39c474c95e407f3a01735",
      "bytes": 808
    },
    {
      "id": "hit-a-file-size-with-two-passes",
      "title": "Hit a file size with two passes",
      "depth": 2,
      "anchor": "hit-a-file-size-with-two-passes",
      "canonicalUrl": "https://encode.wiki/guides/quality-controls/#hit-a-file-size-with-two-passes",
      "apiUrl": "https://encode.wiki/api/v1/sections/docs/guides/quality-controls/hit-a-file-size-with-two-passes.json",
      "markdownUrl": "https://encode.wiki/api/v1/sections/docs/guides/quality-controls/hit-a-file-size-with-two-passes.md",
      "checksum": "ffc9b1f8da193250edbd849278592516520caf4944d00b92764bc93e6882cd06",
      "bytes": 987
    },
    {
      "id": "testing-settings",
      "title": "Testing settings",
      "depth": 2,
      "anchor": "testing-settings",
      "canonicalUrl": "https://encode.wiki/guides/quality-controls/#testing-settings",
      "apiUrl": "https://encode.wiki/api/v1/sections/docs/guides/quality-controls/testing-settings.json",
      "markdownUrl": "https://encode.wiki/api/v1/sections/docs/guides/quality-controls/testing-settings.md",
      "checksum": "f43a1029abf934c20af409a1eac8007c80d22a730af6f71f5698c7c0ffd69b3e",
      "bytes": 319
    }
  ],
  "outboundReferences": [
    "/guides/compare-encoding-quality/",
    "/tools/hardware-encoders/nvenc/"
  ],
  "checksum": "46e83c8174e67dd3200c7b64b71f169c1da1a75aecde3a4ffe33fbbd9de0bbb7",
  "contentFormat": "markdown",
  "markdown": "Rate control decides how many bits each frame gets. Choose the mode by what has to stay fixed:\nthe quality, the file size, or the bitrate at every moment.\n\n| Mode                   | You set                             | Result                                                  | Use it for                                            |\n| ---------------------- | ----------------------------------- | ------------------------------------------------------- | ----------------------------------------------------- |\n| CRF / constant quality | A quality value                     | Consistent quality; file size depends on the content    | Almost every encode you keep, archive or upload       |\n| Capped CRF (CRF + VBV) | Quality value plus peak rate/buffer | Constant quality, except that peaks are limited         | Streaming and devices with a bitrate limit            |\n| Two-pass VBR           | Average bitrate                     | Predictable size; quality close to CRF at the same size | Hitting a file size or an average-bitrate requirement |\n| One-pass ABR           | Average bitrate                     | Roughly the right size; bits are spent poorly           | Live encoding where two passes are impossible         |\n| CBR                    | Constant bitrate                    | Bitrate held constant, with padding if needed           | Broadcast and some live transport                     |\n| Constant QP (CQP)      | A fixed quantizer                   | Same quantizer everywhere; wastes bits on hard scenes   | Codec development and testing, not delivery           |\n\n## CRF and constant quality\n\nCRF (constant rate factor) is quality-based variable bitrate. The encoder raises or lowers the\nquantizer from frame to frame and block to block, spending fewer bits where loss is hard to see\n(fast motion, complex texture) and more where it shows. At the same file size this looks better\nthan constant QP, which ignores where the eye notices errors.\n\nCRF numbers are encoder-specific. They do not mean the same quality across encoders, and sometimes\nnot across versions of one encoder.\n\n| Encoder (FFmpeg name) | Option | Default | Notes                                                                                              |\n| --------------------- | ------ | ------- | -------------------------------------------------------------------------------------------------- |\n| x264 (`libx264`)      | `-crf` | 23      | Lower is better; about ±6 halves or doubles the bitrate. 18–24 covers most uses.                   |\n| x265 (`libx265`)      | `-crf` | 28      | Same 0–51 scale as x264, but the same number does not give the same quality.                       |\n| SVT-AV1 (`libsvtav1`) | `-crf` | 35      | Range 1–70 (FFmpeg's `-crf` accepts up to 63). Upstream suggests 30 as a starting point for 1080p. |\n| libaom (`libaom-av1`) | `-crf` | 32      | Range 0–63. `-crf` alone is constant quality; adding `-b:v` makes it constrained quality.          |\n| libvpx (`libvpx-vp9`) | `-crf` | 32      | Range 0–63. In current FFmpeg, `-crf` alone is constant quality; the old `-b:v 0` is not needed.   |\n\nHardware encoders have their own constant-quality modes (NVENC `-cq`, Quick Sync ICQ, and others).\nThey are not interchangeable with software CRF values; see the\n[hardware encoder pages](/tools/hardware-encoders/nvenc/).\n\n**Presets** trade speed for compression efficiency and are also encoder-specific: x264 and x265 use\nnames (`ultrafast` … `placebo`), SVT-AV1 uses numbers where lower is slower and better. Change the\npreset to fit your time budget, then adjust CRF until the result looks right. At the same CRF a\nslower preset usually gives a smaller file or more detail.\n\n## Cap the bitrate with VBV\n\nVBV (video buffering verifier) models a decoder's input buffer: data arrives at up to `-maxrate`\nand the buffer holds `-bufsize` bits. Combined with CRF it keeps constant-quality behaviour but\nstops peaks from exceeding what a player or connection can take:\n\n```sh\nffmpeg -i input.mkv -c:v libx264 -preset slow -crf 20 -maxrate 6M -bufsize 12M -c:a copy output.mkv\n```\n\n`-maxrate` is the peak rate and `-bufsize` the buffer it is averaged over; you need both. A larger\nbuffer allows short bursts; a smaller one enforces the limit more strictly. When the cap kicks in,\nquality drops in those scenes, so set it from the real limit of the target, not lower. The same\n`-maxrate`/`-bufsize` options work with libx265, and `-maxrate` with libsvtav1 turns its CRF mode\ninto capped CRF.\n\n## Hit a file size with two passes\n\nWork out the video bitrate from the size you want:\n\n```text\nvideo kbit/s = target MiB × 8388.608 / duration in seconds − audio kbit/s\n```\n\nFor a 60-minute file of 1,500 MiB with 128 kbit/s audio: 1500 × 8388.608 / 3600 − 128 ≈ 3367 kbit/s.\n\n```sh\nffmpeg -i input.mkv -c:v libx264 -preset slow -b:v 3367k -pass 1 -an -f null /dev/null\nffmpeg -i input.mkv -c:v libx264 -preset slow -b:v 3367k -pass 2 -c:a libopus -b:a 128k output.mkv\n```\n\nThe first pass analyses the whole video and writes a stats file (`ffmpeg2pass-0.log`); its output\nis discarded, and `-an` skips audio work in that pass. The second pass uses the stats to put bits\nwhere they are needed. With x264, a two-pass encode looks about the same as a CRF encode\nthat happens to produce the same size, so use two passes when the size matters and CRF otherwise.\n\nFor SVT-AV1, multi-pass mainly serves VBR; upstream describes it as not critical in CRF mode. CBR is\nalways single-pass.\n\n## Testing settings\n\nTest on a short clip that includes the hardest material in the source, and change one thing at a\ntime. Compare the clips by watching them, not just by file size or a single metric score; the\n[quality comparison guide](/guides/compare-encoding-quality/) covers metrics and how to use them\nproperly.\n"
}
