If you're shipping videos on the web, file size matters—a lot. Large videos slow down page loads, hurt performance, and burn bandwidth.
I recently optimized a video and reduced it from 137MB to just 29MB (~79% smaller) using a single FFmpeg command.
Here’s exactly what I used:
ffmpeg -hide_banner -loglevel info -stats \
-i input.mp4 \
-c:v libx264 -preset slow -crf 23 \
-profile:v high -level 4.1 \
-movflags +faststart \
-vf "scale=1920:-2" \
-c:a aac -b:a 128k \
output-optimized.mp4
🔍 What each part does
1. Efficient video encoding
-c:v libx264
Uses H.264 — the most widely supported codec for web.
2. Better compression (smaller file size)
-preset slow
Slower encoding = better compression efficiency.
Worth it when you're preparing assets ahead of time.
3. Quality control
-crf 23
CRF (Constant Rate Factor) controls quality:
- Lower = higher quality
- Higher = smaller file
23 is the sweet spot for most web use cases.
4. Web compatibility
-profile:v high -level 4.1
Ensures the video works smoothly across browsers and devices.
5. Faster playback on websites
-movflags +faststart
Moves metadata to the beginning of the file so the video can start playing immediately (no full download required).
6. Resize smartly
-vf "scale=1920:-2"
- Limits width to 1920px
- Keeps aspect ratio intact
- Prevents unnecessarily large resolutions
7. Optimize audio
-c:a aac -b:a 128k
AAC audio at 128 kbps — good balance between quality and size.
📊 Final Result
| Metric | Before | After |
|---|---|---|
| File Size | 137 MB | 29 MB |
| Reduction | — | ~79% |
| Quality | High | Visually similar |
🚀 When to use this
This setup is perfect for:
- Landing pages
- Product demos
- Background videos
- Marketing assets
- Any web-delivered video
💡 Pro tip
If you need:
-
Higher quality: use
-crf 20–22 -
Smaller size: use
-crf 24–28
Final Thoughts
You don’t need fancy tools to optimize video for the web.
FFmpeg alone can dramatically cut file size while keeping quality intact.
If you're still uploading raw videos to production—this is low-hanging fruit worth fixing.
Let me know if you want a version tuned for mobile, ultra-low bandwidth, or streaming 👇
Top comments (0)