Compress a Video with FFmpeg Using CRF

Re-encode a video with a constant rate factor to shrink file size while controlling quality. Higher CRF values mean smaller files and lower quality.

LinuxvideocrfcompressionffmpegLow risk
Run ffmpeg -i input.mp4 -c:v libx264 -crf 28 -preset slow -c:a copy output.mp4 to compress the video with modest quality loss.

01Command

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

02What it does

The -crf (constant rate factor) option tells libx264 to target a constant perceived quality instead of a fixed bitrate: 18 is visually lossless, 23 is the default, and 28 shrinks files dramatically with acceptable quality for sharing. The -preset slow flag spends more CPU during encoding to squeeze out extra compression at the same quality. Because quality is declared rather than guessed at, CRF is almost always the right choice when the goal is 'make this file smaller'.

03Risk

RiskLow risk
Requirementsffmpeg (sudo apt install ffmpeg / sudo dnf install ffmpeg)
!Warning: Don't combine -crf with a bitrate option like -b:v; the encoder honors one rate-control mode, and mixing them produces confusing results.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • FFmpeg Documentation
    FFmpeg · vendor-doc · 2026-09-17
    Evidence: Official ffmpeg CLI documentation covering input/output options including -crf and -preset.
  • FFmpeg Wiki: H.264 Encoding Guide
    FFmpeg · community · 2026-09-17
    Evidence: Documents the -crf range (0-51, 23 default, 18 visually lossless) and -preset speed/compression tradeoff for libx264.

Last verified: 2026-09-17 · Category: Media