How to Compress Video Size Without Losing Quality Using FFmpeg

Ever tried sharing a video and been hit with the dreaded message: “File too large”? You’re not alone! Whether you’re uploading to YouTube, sending via email, or just saving space on your device, big video files can be a pain.

But don’t worry. There’s a powerful tool called FFmpeg that can help. Even better, you can reduce the file size without making your video look like it was shot with a potato.

In this article, we’ll explore how to shrink your videos using FFmpeg while keeping that sweet high quality intact. It’ll be simple, fast, and yes—actually kind of fun.

🎬 What is FFmpeg Anyway?

FFmpeg is a free and open-source command-line tool. It’s like a Swiss Army knife for video and audio files. You can use it to convert files, extract audio, merge clips, and—you guessed it—compress your videos.

Best of all, it’s lightning fast and works on Windows, macOS, Linux… pretty much everything.

If you haven’t installed it yet, you can download it from the official site: https://ffmpeg.org/download.html

💾 Why Compress Without Losing Quality?

When we talk about “quality,” we usually mean resolution, sharpness, and smoothness. We want our videos to stay crisp without killing our hard drive or mobile data.

Lossless compression would be ideal, but sometimes we just want visually lossless results—meaning it looks just as good to the human eye.

And that’s where FFmpeg swoops in like a compression superhero.

📦 Let’s Get Compressin’

Ready for some FFmpeg magic? Open Terminal (macOS/Linux) or Command Prompt (Windows), and let’s type some commands.

Here’s a simple one to get you started:

ffmpeg -i input.mp4 -vcodec libx264 -crf 23 output.mp4

Let’s break it down:

  • -i input.mp4: Your original video file.
  • -vcodec libx264: Use the H.264 codec, great for compression.
  • -crf 23: Constant Rate Factor – lower means better quality. 18–28 is typical. 23 is the default (and a good balance).
  • output.mp4: Your shiny new, smaller video.

Go ahead and run that if you’re feeling adventurous. But don’t go away—we’ve got more tricks up our sleeve!

🎛️ Tweaking Compression Settings

You can control how much quality you’re willing to trade for size. Here’s how:

Play With CRF

CRF (Constant Rate Factor) is your BFF. Want higher quality?

-crf 18

Want a smaller file?

-crf 28

The magic is finding the balance. Try starting around 23 and adjusting up or down based on your needs.

Use Presets for Speed

FFmpeg offers presets like ultrafast, superfast, veryfast, and so on up to veryslow.

Example:

ffmpeg -i input.mp4 -vcodec libx264 -preset slow -crf 23 output.mp4

The slower the preset, the better the compression efficiency. It will take more time, but shrink your video more.

Remove Unneeded Audio

If your video doesn’t need sound (hello, silent tutorials?), toss it out:

ffmpeg -i input.mp4 -an -vcodec libx264 -crf 23 output.mp4

-an just removes the audio stream. Simple and effective.

⚖️ Resize to Reduce

Resolution takes up a lot of space. Do you really need 4K for that birthday video of your cat?

You can scale it like this:

ffmpeg -i input.mp4 -vf scale=1280:-2 -vcodec libx264 -crf 23 output.mp4

The -vf scale=1280:-2 part resizes your video to 1280 pixels wide—height is adjusted automatically to keep aspect ratio.

Common sizes:

  • 1920×1080 (Full HD)
  • 1280×720 (HD)
  • 854×480 (SD)

Pick what makes sense based on where you’ll be posting the video.

🔇 Lower the Audio Bitrate

Sometimes, it’s not just video hogging the space. Audio counts too! You can reduce the audio bitrate without a big quality hit:

ffmpeg -i input.mp4 -b:a 128k -vcodec libx264 -crf 23 output.mp4

-b:a 128k sets the audio to 128kbps—a good default for speech and general use.

🪄 Combine the Magic

Want to scale, reduce audio bitrate, and compress all at once? Here’s your dream combo:

ffmpeg -i input.mp4 -vf scale=1280:-2 -c:v libx264 -preset slower -crf 22 -c:a aac -b:a 128k output.mp4

This command:

  • Resizes video
  • Uses slow preset for better compression
  • Keeps good video quality
  • Compresses audio smartly

Cool, right?

🧪 A Quick Before/After Test

Want to see the difference? Try this:

du -h input.mp4
du -h output.mp4

The du -h command shows file sizes. Spoiler alert: your new video is way smaller.

📁 Batch Compress Multiple Videos

Got a folder full of giant videos? Compress ’em all with a short script.

Here’s an example for macOS/Linux:

for f in *.mp4; do ffmpeg -i "$f" -vcodec libx264 -crf 23 "compressed_$f"; done

On Windows, you can use a batch (.bat) script instead.

💡 Bonus Tips

  • Try HEVC (libx265) for even better compression. Just note it’s a bit slower and not compatible everywhere.
  • Use a video analyzer like MediaInfo to check resolution and bitrate before and after.
  • Always preview your output before deleting the original!

🏁 Wrap Up

Congrats! You’ve just learned how to slim down your video files like a pro. With a bit of tweaking, FFmpeg can save tons of space without making your video look fuzzy or pixelated.

From adjusting CRF to smart resizing and cautious audio tweaking—you’ve got all the tools you need.

Remember: Play around. Experiment. View the results. Soon, you’ll find the sweet spot that works perfectly for your projects.

Happy compressing! 🎉

Lucas Anderson
Lucas Anderson

I'm Lucas Anderson, an IT consultant and blogger. Specializing in digital transformation and enterprise tech solutions, I write to help businesses leverage technology effectively.

Articles: 305