How to Compress Video with FFmpeg

Mar 3, 2026

Large video files eat up storage and slow down uploads. FFmpeg makes it easy to compress videos from the command line. This guide covers the most practical techniques. For an in-depth look at compression strategies, also check out our video compression best practices.

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 ValueQualityUse Case
18Near losslessArchiving
23Good (default)General use
28MediumWeb sharing
32+LowSmall 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
PresetSpeedFile Size
ultrafastFastestLargest
fastFastLarger
mediumBalancedBalanced
slowSlowSmaller
veryslowSlowestSmallest

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.

Try It Online

Don't want to install FFmpeg? Use FFHub to compress your videos directly in the browser — no command line needed.

FFHub

FFHub

How to Compress Video with FFmpeg | FFHub