Home » Creations » Code Snippets » Video compressor with QSV using ffmpeg

Video compressor with QSV using ffmpeg

simsav

So here's a simple FFmpeg command I've used way too many times to shrink those massive videos from my phone and action cam. It uses Intel QSV hardware encoding to re-encode everything into H.265 (HEVC) — which crushes H.264 in efficiency. You get way smaller files without losing much (or any!) quality. Perfect for saving space without the hassle. Here's a single-line code:


ffmpeg -i "input.mp4" -c:v hevc_qsv -global_quality 28 -b:v 0 -preset medium -c:a aac -b:a 192k -y "input_compressed.mp4"


You could change the following attributes in the code to suit your needs:

-i "input.mp4" and -y "input_compressed.mp4": Just swap these with your own files — no magic needed.

-global_quality: This one's on a scale from 0-51. Lower number = better quality (and bigger files). For most stuff, 25-32 is the sweet spot — looks great without blowing up your file size.

-preset: Pick from ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow. Faster presets = quicker encoding but lower quality. If you're not in a rush, medium is your best bet — it's the Goldilocks option: not too fast, not too slow, just right.

-b:a: This sets your audio bitrate. Stick with 128-256 kbps for nice, clear sound. If your original video already has a specific audio bitrate (like 96 kbps), just match it — no need to overthink it.


If you don't have an Intel chip, or you just want something that works everywhere — here's the universal version using libx265:


ffmpeg -i "input.mp4" -c:v libx265 -crf 28 -preset medium -c:a aac -b:a 192k -y "input_compressed.mp4"