>FFmpegLab Start free
FFmpeg Guide

How to compress video with FFmpeg without losing quality

The right way to shrink a video file: understand CRF, choose between H.264 and H.265/HEVC, use two-pass encoding when you must hit a size, and downscale only when you need to.

"How do I make this video smaller?" is the most common FFmpeg question there is. The short answer: re-encode with a modern codec and a sensible CRF. The long answer — which knobs actually move file size, and which just cost you quality — is below.

Key takeaways

The one-liner that solves 80% of cases

Constant Rate Factor (CRF) targets a perceptual quality and lets the bitrate float. For H.264, a CRF of 23 is the default; 18–28 is the useful range:

ShareRenders{ } CodeConfig
Generated CodeLogsCustomize
ffmpeg -i input.mp4 \
  -c:v libx264 -crf 23 -preset slow \
  -c:a aac -b:a 128k \
  output.mp4

A slower -preset (slow, slower, veryslow) squeezes out more size at the same quality — it just takes longer to encode.

Go smaller with H.265 / HEVC

For roughly half the size at the same visual quality, switch to libx265. Use a slightly higher CRF (28 ≈ x264's 23):

ShareRenders{ } CodeConfig
Generated CodeLogsCustomize
ffmpeg -i input.mp4 \
  -c:v libx265 -crf 28 -preset slow \
  -c:a aac -b:a 128k \
  -tag:v hvc1 output.mp4

The -tag:v hvc1 keeps the file playable in QuickTime and Apple devices.

Hit an exact file size with two-pass

When a platform caps you (say, 8 MB), compute a target bitrate and encode in two passes for accurate sizing:

ShareRenders{ } CodeConfig
Generated CodeLogsCustomize
ffmpeg -y -i in.mp4 -c:v libx264 -b:v 2400k -pass 1 -an -f null /dev/null
ffmpeg -i in.mp4 -c:v libx264 -b:v 2400k -pass 2 -c:a aac -b:a 128k out.mp4

Target bitrate ≈ (target size in bits) ÷ (duration in seconds), minus your audio bitrate.

Downscale resolution and shrink audio

If the source is 4K but the output is for the web, halving resolution can cut size dramatically. Pair this with the scale filter:

ShareRenders{ } CodeConfig
Generated CodeLogsCustomize
ffmpeg -i in.mp4 -vf "scale=1280:-2" \
  -c:v libx264 -crf 24 -c:a aac -b:a 96k out.mp4

Common mistakes

Compress without the command line

FFmpegLab runs the same encoder in your browser with a quality slider that maps to CRF, so you can preview size-vs-quality and export — all offline and private.

✦  Fresh from the render queue

Better FFmpeg workflows, delivered.

Get practical commands, new templates, and deep-dive guides for the edits that are usually hardest to get right.

✓  Copy-pasteable commands    ✓  Editor templates    ✓  No noise
One useful email at a time.

Compress, convert, and edit — privately, in your browser.

Free in your browser — nothing to install, nothing uploaded.