Video Compression 12 min read

How to Compress Video Without Losing Quality

Reduce video file size by 50-80% using modern codecs, CRF encoding, and smart resolution settings. Works with HandBrake, FFmpeg, and other tools.

Difficulty Intermediate
Compression 50-80%
Quality Loss Imperceptible

Understanding "Lossless" Video Compression

Let's clarify terminology: true lossless video compression (like HuffYUV or FFV1) creates enormous files. When we say "compress without quality loss," we mean:

Visually lossless: Using modern codecs and optimal settings to achieve compression where quality loss is imperceptible to human eyes, even on high-quality displays.

This is possible because:

  • Perceptual encoding: Modern codecs like H.265 prioritize areas of the frame humans notice
  • Temporal redundancy: Most video frames are similar to adjacent frames
  • Spatial redundancy: Large areas of frames often contain similar colors/patterns
  • Bit depth optimization: 8-bit color is sufficient for most content (10-bit for HDR only)
Compression TypeFile SizeQualityUse Case
True Lossless Huge (10-50 GB/min) Pixel-perfect Archival, editing masters
Visually Lossless Medium (500 MB-2 GB/min) Indistinguishable High-quality distribution
High Quality Lossy Small (100-500 MB/min) Excellent Streaming, sharing
Web Optimized Very small (20-100 MB/min) Good Social media, mobile

Codec Selection: H.265 vs H.264

Your codec choice is the single biggest factor in compression efficiency. Here's the breakdown:

H.264 (AVC)

Release: 2003 | Efficiency: Baseline

Advantages:

  • Universal compatibility (plays everywhere)
  • Fast encoding/decoding
  • Hardware support on all devices
  • Well-understood, mature technology

Disadvantages:

  • Larger file sizes (reference point)
  • Less efficient at 4K resolution

Best for: Maximum compatibility, real-time encoding, older devices

H.265 (HEVC)

Release: 2013 | Efficiency: 40-50% better than H.264

Advantages:

  • 50% smaller files at same quality
  • Excellent for 4K/HDR content
  • Better detail preservation
  • Hardware support on devices 2016+

Disadvantages:

  • Slower encoding (2-5x longer)
  • Not supported on older devices
  • Some browsers lack support

Best for: Archival, large files, 4K video, modern devices

AV1 (Future)

Release: 2018 | Efficiency: 30% better than H.265

Advantages:

  • Royalty-free, open standard
  • Best compression available
  • Designed for streaming

Disadvantages:

  • Very slow encoding (10-20x H.264)
  • Limited hardware support
  • Not yet mainstream

Best for: Web video, YouTube uploads (2024+), patient users

Recommendation: Use H.265 for file size reduction with modern devices. Use H.264 when you need guaranteed compatibility or fast encoding.

Method 1: HandBrake (GUI Tool)

HandBrake is free, open-source, and offers the perfect balance of power and usability.

1

Install HandBrake

Download from handbrake.fr (free, cross-platform).

# macOS (Homebrew) brew install --cask handbrake # Windows (Chocolatey) choco install handbrake # Linux (Ubuntu/Debian) sudo apt install handbrake
2

Import Your Video

Open HandBrake and click Open Source. Select your video file. HandBrake will analyze it and display duration, resolution, and codec info.

3

Choose Preset

On the right sidebar, select from the presets panel:

  • General → "Very Fast 1080p30": H.264, fast encode, good quality
  • General → "HQ 1080p30 Surround": H.264, slower encode, excellent quality
  • General → "Super HQ 1080p30 Surround": H.265, very slow, visually lossless
Start here: Use "HQ 1080p30 Surround" for H.264 or "Super HQ 1080p30" for H.265. Then tweak settings below.
4

Configure Video Settings

Click the Video tab. These are the critical settings:

SettingRecommended ValueExplanation
Video Codec H.265 (x265) or H.264 (x264) H.265 = smaller files, H.264 = compatibility
Framerate Same as source Don't change unless necessary
Quality (CRF) 18-23 (H.264) or 22-28 (H.265) Lower = better quality, higher file size
Encoder Preset Slow or Medium Slower = smaller files (encoding takes longer)
Critical: Use Constant Quality (CRF) mode, not Average Bitrate. CRF adapts to scene complexity for better quality/size ratio.
5

Audio Settings (Optional)

Click the Audio tab:

  • Codec: AAC (universal) or Opus (better quality, smaller)
  • Bitrate: 128 kbps (stereo) or 256 kbps (5.1 surround)
  • Sample Rate: Auto (or 48 kHz)

Audio is usually 1-5% of total file size, so don't over-optimize.

6

Start Encoding

Click Start Encode (green play button). HandBrake will show:

  • Estimated time remaining
  • Current FPS (frames per second encoding speed)
  • File size as it grows

Encoding time: H.264 Medium preset ≈ 0.5-2x realtime. H.265 Slow preset ≈ 2-5x realtime.

Expected Results with HandBrake:

  • H.264 "HQ 1080p30" preset: 30-50% size reduction vs. source
  • H.265 "Super HQ" preset: 50-70% size reduction vs. H.264 source
  • Quality: Indistinguishable on standard displays

Method 2: FFmpeg (Command Line)

FFmpeg offers maximum control and is ideal for automation and batch processing.

1

Install FFmpeg

# macOS brew install ffmpeg # Ubuntu/Debian sudo apt install ffmpeg # Windows (download from ffmpeg.org or use Chocolatey) choco install ffmpeg
2

Basic H.264 Compression (High Quality)

ffmpeg -i input.mp4 \ -c:v libx264 \ -preset slow \ -crf 20 \ -c:a aac -b:a 128k \ output.mp4

Breakdown: -c:v libx264 (H.264 codec), -preset slow (encoding speed), -crf 20 (quality level), -c:a aac -b:a 128k (audio codec and bitrate)

3

H.265 Compression (Maximum Efficiency)

ffmpeg -i input.mp4 \ -c:v libx265 \ -preset medium \ -crf 24 \ -c:a aac -b:a 128k \ -tag:v hvc1 \ output.mp4

Note: -tag:v hvc1 ensures compatibility with QuickTime/Apple devices.

4

Two-Pass Encoding (Targeted File Size)

If you need a specific file size (e.g., under 100 MB):

# Calculate bitrate: (target size MB × 8192) / duration seconds # Example: 100 MB for 600-second video = (100 × 8192) / 600 = 1365 kbps # Pass 1 (analysis) ffmpeg -i input.mp4 -c:v libx264 -b:v 1365k -preset slow \ -pass 1 -an -f null /dev/null # Pass 2 (encoding) ffmpeg -i input.mp4 -c:v libx264 -b:v 1365k -preset slow \ -pass 2 -c:a aac -b:a 128k output.mp4
5

Advanced: Hardware Acceleration

Use GPU encoding for 5-10x faster speeds (slight quality trade-off):

# NVIDIA GPU (NVENC) ffmpeg -i input.mp4 -c:v h264_nvenc -preset slow -crf 20 output.mp4 # Intel QuickSync ffmpeg -i input.mp4 -c:v h264_qsv -preset slow -global_quality 20 output.mp4 # Apple VideoToolbox (Mac) ffmpeg -i input.mp4 -c:v h264_videotoolbox -b:v 5000k output.mp4

Understanding CRF (Constant Rate Factor)

CRF is the quality dial for video encoding. Lower = higher quality, larger files.

CRF Value (H.264)CRF Value (H.265)QualityUse Case
0-17 0-21 Visually lossless Archival, editing, Blu-ray mastering
18-20 22-24 Excellent (imperceptible loss) Recommended for most uses
21-23 25-27 High quality Streaming, sharing, storage savings
24-27 28-31 Good quality Web video, social media
28+ 32+ Acceptable to poor Low-bandwidth situations only
Sweet spot: CRF 20 for H.264, CRF 24 for H.265. These values are imperceptible to most viewers while providing excellent compression.

How to test CRF values:

# Encode a 30-second sample at different CRF values ffmpeg -i input.mp4 -t 30 -c:v libx264 -crf 18 -c:a copy test_crf18.mp4 ffmpeg -i input.mp4 -t 30 -c:v libx264 -crf 20 -c:a copy test_crf20.mp4 ffmpeg -i input.mp4 -t 30 -c:v libx264 -crf 23 -c:a copy test_crf23.mp4 # Compare file sizes and visual quality on your target display

Resolution vs File Size

Reducing resolution is the nuclear option—massive file size savings but permanent quality loss. Use judiciously.

Resolution Impact on File Size

4K (3840×2160) 100% Reference
1080p (1920×1080) ~25% 75% reduction

Dropping from 4K to 1080p typically reduces file size by 70-80% at the same bitrate/CRF.

When to Downscale Resolution

  • Do downscale: If source is 4K but target display is 1080p or less
  • Do downscale: For mobile viewing or strict size limits
  • Don't downscale: If viewers have 4K displays
  • Don't downscale: If you can achieve size targets with codec/CRF alone

How to Downscale in FFmpeg

# Downscale 4K to 1080p ffmpeg -i input_4k.mp4 -vf "scale=1920:1080" -c:v libx265 -crf 24 output_1080p.mp4 # Downscale to 720p ffmpeg -i input.mp4 -vf "scale=1280:720" -c:v libx264 -crf 20 output_720p.mp4 # Auto-scale maintaining aspect ratio (width = 1920, height = auto) ffmpeg -i input.mp4 -vf "scale=1920:-2" -c:v libx264 -crf 20 output.mp4

Note: -2 maintains aspect ratio and ensures even dimensions (required for H.264/H.265).

Real-World Compression Results

Test Case 1: GoPro 4K Footage

Original (H.264 High Bitrate) 8.2 GB 10 min, 4K 60fps
H.265 CRF 24 1.8 GB 78% reduction

Settings: FFmpeg, libx265, preset medium, CRF 24

Encoding time: 45 minutes (2.25x realtime)

Quality assessment: Indistinguishable on 4K TV at normal viewing distance

Test Case 2: Screen Recording (Tutorial)

Original (Uncompressed) 12.4 GB 30 min, 1080p 30fps
H.264 CRF 18 580 MB 95% reduction

Settings: HandBrake, x264, preset slow, CRF 18

Encoding time: 22 minutes (0.73x realtime)

Quality assessment: Perfect for screen content, text remains razor-sharp

Test Case 3: Wedding Video (1080p)

Original (H.264 from Camera) 18.6 GB 90 min, 1080p 24fps
H.265 CRF 22 4.2 GB 77% reduction

Settings: FFmpeg, libx265, preset slow, CRF 22

Encoding time: 6 hours (4x realtime)

Quality assessment: Archival quality, no visible artifacts in dark/bright scenes

Troubleshooting Common Issues

Problem: Video is too large even after compression

Solutions:

  • Increase CRF value by 2-3 (e.g., 20 → 23)
  • Switch from H.264 to H.265 (50% size reduction)
  • Downscale resolution (4K → 1080p = 75% reduction)
  • Use two-pass encoding with target bitrate
  • Reduce framerate (60fps → 30fps = 50% reduction)

Problem: Video looks worse after compression

Causes and fixes:

  • CRF too high: Lower CRF by 2-3 (better quality, larger file)
  • Wrong preset: Use "slow" or "slower" preset for better quality
  • Color space issue: Add -pix_fmt yuv420p to FFmpeg command
  • Already compressed source: You can't improve compressed video; only degrade further

Problem: Video won't play on certain devices

Solutions:

  • H.265 compatibility: Use H.264 instead, or ensure H.265 Main profile (not Main10)
  • Container format: Use MP4 (most universal) instead of MKV
  • Audio codec: Use AAC instead of Opus or FLAC
  • QuickTime/Apple devices: Add -tag:v hvc1 for H.265, -pix_fmt yuv420p for H.264

Problem: Encoding is extremely slow

Solutions:

  • Use faster preset: Change from "slow" to "medium" or "fast" (10-20% larger files)
  • Hardware acceleration: Use NVENC, QuickSync, or VideoToolbox (see FFmpeg section)
  • Parallel encoding: Split video into chunks, encode simultaneously
  • Lower resolution first: Encoding 4K is 4× slower than 1080p

Frequently Asked Questions

What's the best video compression software?

For beginners: HandBrake (free, GUI, cross-platform, excellent presets)

For power users: FFmpeg (free, command-line, unlimited control, batch processing)

For professionals: Adobe Media Encoder or DaVinci Resolve (paid, advanced features)

All produce similar quality; choice depends on workflow and technical comfort.

Should I use H.264 or H.265?

Use H.265 when:

  • File size is critical (archival, storage limits)
  • Video is 4K or higher resolution
  • Target devices are 2016 or newer
  • Encoding time isn't critical

Use H.264 when:

  • Maximum compatibility needed (old devices, web browsers)
  • Fast encoding required (live streaming, quick turnaround)
  • Source is already 1080p or lower
What is the difference between bitrate and CRF?

Bitrate (CBR/VBR): Fixed data rate (e.g., 5 Mbps). Simple scenes waste bits, complex scenes get starved. Predictable file size but inconsistent quality.

CRF (Constant Rate Factor): Fixed quality target. Encoder uses more bits for complex scenes, fewer for simple scenes. Variable file size but consistent quality.

Recommendation: Use CRF for archival/personal video. Use bitrate for streaming (where bandwidth is constrained).

How much quality loss is acceptable?

It depends on your use case:

  • Archival/master copies: CRF 17-18 (H.264) or 21-22 (H.265) – virtually no perceptible loss
  • Personal viewing/sharing: CRF 20-23 (H.264) or 24-27 (H.265) – imperceptible on most displays
  • Web/social media: CRF 23-27 (H.264) or 28-32 (H.265) – acceptable quality, small files

Test with a 30-second sample and view on your target display before encoding the full video.

Can I compress video multiple times?

Short answer: Don't. Each re-encoding degrades quality (generation loss).

Long answer: If you must re-compress:

  • Use a lower CRF value (higher quality) to minimize additional loss
  • Never compress more than 2-3 times total
  • Keep original uncompressed/lossless master for future re-encoding
  • Use the same or better codec (don't go H.265 → H.264)
How do I compress video for YouTube/Vimeo?

Both platforms re-encode uploads, so your goal is to give them the highest quality source possible:

YouTube recommended:

ffmpeg -i input.mp4 -c:v libx264 -preset slow -crf 18 \ -c:a aac -b:a 192k -pix_fmt yuv420p output.mp4

Vimeo recommended:

ffmpeg -i input.mp4 -c:v libx264 -preset slow -crf 16 \ -c:a aac -b:a 320k -pix_fmt yuv420p output.mp4

Use H.264 (not H.265) for faster platform processing. Platforms will handle compression for streaming.

What's the optimal encoding preset?

Encoding presets trade encoding time for file size/quality:

  • ultrafast: 10x realtime encoding, 50% larger files, lower quality
  • fast: 3-5x realtime, 20% larger files, good quality
  • medium (default): 1-2x realtime, balanced, recommended for most
  • slow: 0.5x realtime (2x duration), 5-10% smaller, better quality
  • slower: 0.25x realtime, 10-15% smaller, best quality

Recommendation: Use slow for important/archival video. Use medium for quick jobs.