A raw 4K video clip from your camera produces about 400MB per minute. The same clip compressed with modern codecs can be under 100MB with no visible quality loss. Understanding how video compression works lets you make informed decisions — instead of blindly turning down quality sliders and hoping for the best.
How Video Compression Actually Works
Video compression exploits two types of redundancy:
- •Spatial redundancy: Adjacent pixels in the same frame are often similar. A blue sky doesn't need to encode every pixel separately — it can encode "this 16×16 block is mostly this shade of blue." This is what JPEG compression does for still images.
- •Temporal redundancy: Consecutive frames are usually very similar. Instead of storing every frame completely, codecs store a full "keyframe" (I-frame) every few seconds, then only store the differences between frames (P-frames and B-frames). A static background doesn't need to be re-encoded 30 times per second.
The result: a 30-second clip of someone talking compresses far better than a 30-second clip of a football match (lots of motion = less temporal redundancy).
Codec Comparison: H.264 vs H.265 vs AV1 vs VP9
| Codec | Compression Efficiency | Encoding Speed | Compatibility | Best For |
|---|---|---|---|---|
| H.264 (AVC) | Baseline (1×) | Fast | Universal | General sharing, max compatibility |
| H.265 (HEVC) | ~40% better than H.264 | Moderate | Good (2018+) | 4K content, smaller files |
| VP9 | ~35% better than H.264 | Moderate | Excellent (web) | YouTube, web streaming |
| AV1 | ~50% better than H.264 | Slow | Growing (2022+) | Streaming platforms, future-proof |
Compression efficiency = same visual quality at what fraction of H.264's bitrate. AV1 at 5Mbps looks as good as H.264 at 10Mbps.
Bitrate Guide by Resolution
Bitrate (measured in Mbps) determines how much data is used per second of video. Higher bitrate = better quality = larger file. These ranges represent good quality vs. visually lossless for H.264:
| Resolution | Good Quality | High Quality | H.265 equivalent |
|---|---|---|---|
| 4K (3840×2160) | 35–45 Mbps | 45–68 Mbps | 20–35 Mbps |
| 1080p (1920×1080) | 8–10 Mbps | 10–12 Mbps | 5–7 Mbps |
| 720p (1280×720) | 5–6 Mbps | 6–7.5 Mbps | 3–4 Mbps |
| 480p (854×480) | 2.5–3 Mbps | 3–4 Mbps | 1.5–2.5 Mbps |
CRF (Constant Rate Factor) Explained Simply
CRF is the quality control knob in ffmpeg and most professional video encoders. Instead of targeting a fixed bitrate, CRF targets a constant visual quality level — the encoder uses more bits on complex scenes (fast motion, details) and fewer on simple scenes (talking head, static backgrounds).
- CRF 0: Lossless. Huge files. Only useful for archiving source material.
- CRF 18–23: Visually lossless to high quality. Indistinguishable from source for most content. Good default for H.264.
- CRF 24–28: Good quality, noticeably smaller files. Fine for web delivery.
- CRF 29–35: Acceptable quality, significant compression. Useful for mobile, streaming at low bandwidths.
- CRF 51: Worst quality. Highly blocky. Only useful for previews.
For H.265, the scale shifts — CRF 24 in H.265 looks similar to CRF 18 in H.264 but produces a smaller file.
Two-Pass Encoding: What It Is and When to Use It
Two-pass encoding analyzes the entire video on pass 1 (without encoding), then uses that analysis to make optimal bitrate allocation decisions on pass 2. The result: better quality at the same file size compared to single-pass encoding at a fixed bitrate.
Use two-pass when: you're encoding for a specific target file size (e.g., "must be under 100MB"). Two-pass encoding achieves target file sizes more accurately than single-pass.
Don't bother with two-pass when: using CRF mode (CRF already does intelligent bitrate allocation within a single pass). Two-pass is mainly useful with ABR (average bitrate) targeting.
Platform-Specific Optimal Settings
| Platform | Recommended Resolution | Codec | Max Bitrate | Notes |
|---|---|---|---|---|
| YouTube | 3840×2160 (4K) | H.264 or VP9 | 68 Mbps (4K) | Upload highest quality — YouTube re-encodes. Don't pre-compress aggressively. |
| Instagram Reels | 1080×1920 (9:16) | H.264 | 10 Mbps | Instagram re-encodes heavily. Upload at 1080p, under 50MB for best results. |
| TikTok | 1080×1920 (9:16) | H.264 | 287 MB total | 8–12 Mbps for 1080p. TikTok re-encodes but preserves more quality than Instagram. |
| Vimeo | 1920×1080 minimum | H.264 | 30 Mbps | Vimeo preserves your upload quality better than YouTube. Upload high quality. |
Common Mistakes That Hurt Quality
- ✗Re-encoding already compressed video. This is the most destructive mistake. Each encode-decode cycle introduces new compression artifacts on top of existing ones. The quality loss compounds. If your source is an H.264 file, compress it once to your target — never encode the same file multiple times.
- ✗Setting bitrate too low for the content. A slow-motion video of falling snow at 2 Mbps will look terrible. Fast-moving or highly detailed content needs higher bitrates. Adjust based on content complexity, not just resolution.
- ✗Ignoring audio bitrate. Audio contributes to file size. Compressing video aggressively while keeping 320kbps audio on a 5-minute clip wastes ~12MB on audio. For web video, 128kbps stereo is perfectly adequate.
- ✗Upscaling then compressing. Compressing a 720p video to 1080p then re-compressing doesn't add quality. It just produces a larger file with the same quality as the 720p original.
When "No Quality Loss" Is a Myth vs. When It's Achievable
True lossless compression is possible but not useful in practice. Lossless H.264 (CRF 0) produces files nearly as large as uncompressed video. The term "no quality loss" in consumer tools means "visually lossless" — the compression artifacts are below the threshold of human perception under normal viewing conditions on a standard display.
Visually lossless compression is achievable in these scenarios: compressing raw camera footage (10–100×+ compression possible), re-encoding at a codec with better efficiency (H.264 to H.265 at same visual quality = ~40% smaller file), and removing unnecessary content (trimming silent sections, removing metadata).
Quality loss is unavoidable when: compressing a file that's already heavily compressed (WhatsApp video, social media download), targeting a very small file size relative to video complexity (30-minute 4K to 50MB), or re-encoding multiple times.