How to Compress Video with FFmpeg
Learn how to reduce video file size using FFmpeg with CRF, presets, codec selection, and resolution scaling while maintaining quality.

Compressing video with FFmpeg is the fastest way to shrink large files without paying for software — CRF, presets, codec choice, and resolution scaling give you full control over the quality-vs-size tradeoff. This guide walks through every technique you'll actually use, with copy-paste commands. For a deeper dive into the encoder math, see our video compression best practices.
Drop a video, pick a target size or quality, download the compressed file. Same FFmpeg flags under the hood — no install.
Quick Compress with CRF
The simplest way to compress a video is using CRF (Constant Rate Factor). Lower values mean higher quality, higher values mean smaller files.
ffmpeg -i input.mp4 -crf 23 output.mp4
| CRF Value | Quality | Use Case |
|---|---|---|
| 18 | Near lossless | Archiving |
| 23 | Good (default) | General use |
| 28 | Medium | Web sharing |
| 32+ | Low | Small file priority |
If you also need to change the container format (e.g., MKV to MP4), see our format conversion guide.
Choose the Right Codec
H.264 — Best Compatibility
ffmpeg -i input.mp4 -c:v libx264 -crf 23 -preset medium output.mp4
H.265 (HEVC) — 50% Smaller Files
H.265 produces significantly smaller files at the same quality, but encoding is slower.
ffmpeg -i input.mp4 -c:v libx265 -crf 28 output.mp4
Use Presets to Control Speed vs Size
Presets balance encoding speed and compression efficiency.
ffmpeg -i input.mp4 -c:v libx264 -crf 23 -preset slow output.mp4
| Preset | Speed | File Size |
|---|---|---|
| ultrafast | Fastest | Largest |
| fast | Fast | Larger |
| medium | Balanced | Balanced |
| slow | Slow | Smaller |
| veryslow | Slowest | Smallest |
Scale Down Resolution
Reducing resolution is one of the most effective ways to shrink file size.
# Scale to 720p
ffmpeg -i input.mp4 -vf "scale=-2:720" -crf 23 output.mp4
# Scale to 480p
ffmpeg -i input.mp4 -vf "scale=-2:480" -crf 23 output.mp4
The -2 keeps the aspect ratio and ensures the width is divisible by 2.
Limit Bitrate
For streaming or strict file size requirements, set a maximum bitrate:
ffmpeg -i input.mp4 -c:v libx264 -b:v 1M -maxrate 1M -bufsize 2M output.mp4
Compress Audio Too
Don't forget the audio track. Reducing audio bitrate helps:
ffmpeg -i input.mp4 -c:v libx264 -crf 23 -c:a aac -b:a 128k output.mp4
One-Command Recipe
Here's a balanced command that works well for most cases:
ffmpeg -i input.mp4 -c:v libx264 -crf 23 -preset medium -c:a aac -b:a 128k output.mp4
This produces a good quality MP4 with significantly reduced file size, compatible with virtually all devices and platforms.
Skip the command line — drop a video into FFHub and pick a target size or quality. Same FFmpeg flags work under the hood, no install.
FAQ
What's the best CRF value for compressing video?
CRF 23 is the H.264 default and the safe choice for general web video. For higher quality (archiving or streaming premium), use CRF 18–20. For aggressive compression (social media, bandwidth-constrained), CRF 26–28 works. For H.265, add ~5 to the equivalent H.264 value (CRF 28 in H.265 ≈ CRF 23 in H.264).
How much can I compress a video with FFmpeg without losing visible quality?
With H.264 at CRF 18–23 and -preset medium, you can typically cut file size by 50–80% from the original camera or screen recording with no visible quality loss. Switching to H.265 at CRF 28 cuts another 30–40% on top of that. The exact ratio depends on the source — already-compressed web video has less room to shrink than a raw recording.
H.264 vs H.265: which is better for compression?
H.265 produces files 30–40% smaller than H.264 at the same visual quality, but encoding takes 3–5x longer and playback support is narrower (Safari and modern mobile devices yes; some browsers and older devices no). Use H.264 when you need maximum compatibility, H.265 when bandwidth or storage matters more than encode time.
How do I compress a video to a specific file size?
Use two-pass bitrate encoding. Calculate the target video bitrate: (target file size in bits − audio size) / duration in seconds. Then run two passes — first analyzes complexity, second encodes optimally. For a 100MB target on a 10-minute video with 128k audio, that's about 1.2 Mbps video bitrate.
Why is my compressed video bigger than the original?
Usually one of three reasons: (1) the source was already heavily compressed and you used a low CRF (18–20) that re-encodes at higher quality than the source, (2) you used a slower codec like H.265 with a fast preset which is less efficient, or (3) you upscaled resolution. Check the source with ffprobe input.mp4 and pick a CRF that doesn't try to improve the source.
What's the fastest way to compress video with FFmpeg?
Use -c:v libx264 -preset ultrafast -crf 28. This is roughly 5x faster than -preset medium but produces files 2–3x larger at the same quality. Acceptable for proxies, drafts, or one-off conversions where storage is cheap. For final delivery, drop back to medium or slow.
Related Articles
- FFmpeg Video Compression Best Practices — Advanced strategies for optimal compression quality and file size
- How to Convert Video Format with FFmpeg — Convert between MP4, WebM, MKV, MOV with full codec control
- How to Trim and Merge Videos with FFmpeg — Cut clips and concatenate videos with simple commands