FFmpeg recipe

FFmpeg: Compress an MP4 with H.264 + CRF

CRF compression keeps quality consistent across the clip. Lower CRF = better quality + larger file. CRF 23 is the visually-lossless default.

Command

ffmpeg -i input.mp4 -c:v libx264 -crf 23 -preset slow -c:a copy -y output.mp4
Prefer no terminal?
Use the Video Compressor in your browser
Open Video Compressor

What each flag does

-iInput file. Can be a video, audio, or image. Repeat for multiple inputs.
-c:vVideo codec for output. e.g. libx264, libx265, libvpx-vp9.
-crfConstant Rate Factor — quality target (lower = better, larger file). 23 is visually lossless for libx264.
-c:aAudio codec for output. e.g. aac, libmp3lame, copy.
-preset slowSlower preset → smaller file at the same CRF. Use ultrafast for live, slow for archival.

Notes & gotchas

  • Common CRF values: 18 (near-lossless), 23 (default), 28 (web/email), 32 (chat apps).
  • Stream-copy the audio (-c:a copy) when you only need video compression.

Related recipes