-crf 23, the libx264 default, kept a VMAF of about 97 on an 11-second clip, and -crf 28 made the file over 40% smaller for a few points. ReelSDK runs either encode for $0.02 per compute minute; the CRF 23 job cost under half a cent.

Choose a CRF value in ffmpeg

CRF sets a quality target instead of a bitrate: 0 to 51 in libx264, 23 by default. On ffmpeg 8.1, the version ReelSDK runs, the VMAF score fell fast past CRF 28, and CRF 18 made a file about a third bigger than its source.

GuidesUpdated

crf
ffmpeg -i input.mp4 -c:v libx264 -crf 23 -preset medium \
  -c:a copy crf23.mp4

-crf 23 is the libx264 default, written out. The encoder spends bits where the picture needs them and the file ends up whatever size that takes: about 4.3 MB for an 11-second phone clip.

Variations

The other commands you will need

  1. Try several values

    Encode the same clip at a few CRFs and compare. Each step of 5 gave 55 to 59% of the previous video bitrate, close to the rule of thumb that 6 steps halve it.

    sweep
    for crf in 18 23 28 33; do
      ffmpeg -i input.mp4 -c:v libx264 -crf $crf -c:a copy crf$crf.mp4
    done
  2. Score each file with VMAF

    libvmaf compares an encode with its source frame by frame and prints one score; higher is closer to the source. The encode goes first and the reference second.

    vmaf
    ffmpeg -i crf28.mp4 -i input.mp4 \
      -lavfi "[0:v][1:v]libvmaf=n_threads=8" -f null -

The flags

The flags in these commands

The flags in these commands
FlagWhat it doesUsed here
-crf 23Quality target for libx264: 0 to 51, 23 by default, lower is betterAll encodes
-preset mediumEncoder speed; slower presets compress better at the same CRFCRF 23
-c:a copyCopies the audio, so only the video changes between filesAll encodes
libvmafScores the first input against the second; default model vmaf_v0.6.1VMAF
n_threads=8Worker threads for libvmaf; the default is 0VMAF
-f null -Runs the filter and throws the frames awayVMAF

Sources: FFmpeg H.264 encoding guide, ffmpeg filters: libvmaf, checked November 2026.

What we measured

The input is an 11-second, 1080x1920 phone clip of about 5.5 MB. VMAF scores are against that input, with libvmaf's default model, so they show how much each encode lost on the way.

Each step up the CRF scale cost more quality than the one before: from CRF 18 to 23 the score barely moved while the file shrank by about 40%, but CRF 33 fell to a VMAF of about 84. The first steps cost little quality and save a lot of bytes; past 28 the score falls faster.

How to pick a value

The FFmpeg H.264 guide calls 17 to 28 the sane range and 17 or 18 visually lossless or nearly so. Start at 23, look at the result, and move in steps of 2 or 3. Use the same CRF for a batch of similar videos and they'll come out at a similar quality.

A low CRF on a file that was already compressed can grow it: our CRF 18 encode came out about a third bigger than the input. Re-encoding never adds quality the input doesn't have.

CRF in other encoders

The numbers aren't shared between encoders. libx265 defaults to CRF 28, which its guide says matches libx264 CRF 23 at about half the size. On our clip, x265 at CRF 28 made a file well under half the size of x264 at 23, with a lower score, about 94 against 97. At CRF 23, x265 matched the x264 score in a file about a third smaller. See H.265 with ffmpeg for the full comparison.

When the file has to fit a size or a bitrate, CRF is the wrong tool: see set the video bitrate with ffmpeg. For other ways to shrink a file, see compress a video with ffmpeg.

Without installing ffmpeg

The same command as one API call

Send the same args to POST /v1/ffmpeg with the video's URL in inputs. Each job runs ffmpeg 8.1 on a fresh machine at $0.02 per compute minute, billed per second; this one finished in about 14 seconds and cost under half a cent.

terminalTry it
curl "https://api.reelsdk.com/v1/ffmpeg?wait=60" \
  -H "Authorization: Bearer $REELSDK_KEY" \
  --json '{
    "inputs": {
      "input.mp4": "https://api.reelsdk.com/f/lib/demo/clip.mp4"
    },
    "args": [
      "-i", "input.mp4", "-c:v", "libx264", "-crf", "23", "-preset",
      "medium", "-c:a", "copy", "crf23.mp4"
    ],
    "outputs": ["crf23.mp4"]
  }'
crf23.mp4 from the API: libx264 at CRF 23, about 4.4 MB for 11 seconds.Input: clip.mp4

FAQ

Questions, answered

What is a good CRF value in ffmpeg?

For libx264, 23 is the default and a good start; the FFmpeg H.264 guide calls 17 to 28 the sane range. On our clip, CRF 23 kept a VMAF of about 97 and CRF 28 about 93.

Does a lower CRF mean better quality?

Yes. Lower is better and bigger: on our clip, CRF 18 gave about 7.3 MB and CRF 33 about 1.6 MB. CRF 0 is lossless for 8-bit video.

How much smaller is the file per CRF step?

The rule of thumb is that +6 halves the bitrate. We measured 55 to 59% of the video bitrate per 5 steps between CRF 18 and 33.

Is CRF 23 in x265 the same as in x264?

Not by design: each encoder has its own scale, and the x265 guide says its default CRF 28 looks like libx264 CRF 23. On our clip, VMAF disagreed: x265 at CRF 23 matched x264 at CRF 23 with a file 32% smaller, while x265 at 28 scored lower.

Can I encode with a CRF through an API?

Yes. Send the same args to POST https://api.reelsdk.com/v1/ffmpeg with the video's URL in inputs. It runs ffmpeg 8.1 on a fresh machine per job for $0.02 per compute minute, billed per second, and failed jobs are free.

Ready to build?

Ship video from your app today

Your first $0.50 is free, and one key covers every endpoint.

Moonlit lake with a lit cabin under the mountains