WinX Video Converter

Home > Video > Resize Video > Compress Video in FFmpeg

Posted by Kaley Torres- | Contact Author

FFmpeg Guide - How to Reduce Video File Size with FFmpeg

FFmpeg can compress video size on Windows, macOS, or Linux for YouTube, Facebook, Instagram, email, etc. For novice users, however, it's difficult to get started with FFmpeg. Forums like StackExchange and superuser are flooded with questions about compressing video in FFmpeg. For example,

"I have a 1080p video 3 minutes long and want to bring it down to 100MB in size. Tried changing bit rate ffmpeg -i input.mp4 -b 1000000 output.mp4, also tried ffmpeg -i input.mp4 -vcodec libx265 -crf 20 output.mp4 Tried changing -crf between 18 to 24, used both libx264,265 but it all resulted in nearly same output size, sometimes it even got bigger instead of smaller."

To compress videos in FFmpeg, you should make sure the common-line is right. Start with the common-line examples below using FFmpeg. You can also reduce video size using FFmpeg in Python. If you can't handle FFmpeg, or FFmpeg compression performance is not satisfying, try the FFmpeg alternative below.

Can't Handle FFmpeg? Try Video Compression Software

FFmpeg is not easy to get started for novice users. To make video compression easier and more efficient, use a solid video compression tool, WinX HD Video Converter Deluxe.

  • No skills required, simple to use. Compress videos within 3 clicks!
  • Convert video codec formats, cut out unwanted parts, lower down video resolution/frame rate/bit rate, etc.
  • Cut video size up to 90% off thanks to advanced intraframe and interframe coding and compression algorithms.
  • No noticeable quality loss after compression with the built-in HQ engine and de-interlacing engine.
  • Blazing fast compression speed with the support for hardware acceleration.

Part 1. How to Reduce Video Size with FFmpeg (Command-Line)

1. Set up FFmpeg on Windows, macOS, or Linux

Download FFmpeg and finish the setup process on your computer. For Windows users, Windows Powershell is recommended over Command-Line. Open Windows Powershell from the start menu, and start with the compression command-line in FFmpeg.

2. Input video compression command-line

There are few ways to make video size smaller, such as a more efficient codec format (H.265 compresses data 30% smaller than H.264), lower bitrate or fps, shorter video length. Here we take some typical command-line examples to show you how to compress MP4/MOV/4K video size using FFmpeg.

Command-line - Compress and Convert MP4 to WMV
ffmpeg -i input.mp4 -b 1000k -vcodec wmv2 -acodec wmav2 -crf 19 -filter:v fps=fps=24 output.wmv

Command-line - Compress and Convert MP4 to Webm for YouTube, Ins, Facebook
ffmpeg -i source.mp4 -c:v libvpx-vp9 -b:v 0.33M -c:a libopus -b:a 96k \
-filter:v scale=960x540 target.webm

Command-line - Compress and Convert H.264 to H.265 for Higher Compression
ffmpeg -i input.mp4 -vcodec libx265 -crf 28 output.mp4

Command-line -Set CRF in FFmpeg to Reduce Video File Size
ffmpeg -i input.mp4 -vcodec libx264 -crf 24 output.mp4

Command-line - Reduce video frame size to make 4K/1080P FHD video smaller
ffmpeg -i input.avi -vf scale=1280:720 output.avi

compress video FFmpeg

To make the command line clearer, below are what some common FFmpeg command-line options specify, including -c:v, -b:v, -c:a, -b:a, CRF. These options are frequently used for reducing video size in FFmpeg.

  • -c:v: video codec
  • -b:v: video bitrate
  • -c:a: audio codec
  • -b:a: audio bitrate
  • -filter:v: a filter to video stream
  • -f is used to explicitly specify the container format, -f mp4, -f wmv, -f webm, etc.

CRF (Constant Rate Factor): set the CRF to lower the bit rate but retain better quality. The lower crf, the higher the bitrate. According to test, setting crf to 24 reduce a 250MB video to 70MB without losing the quality noticeably. Use ffmpeg -i input.avi -vcodec libx264 -crf 24 output.avi, a 1GB video can be compressed to 200MB.

3. Start reducing video file size in FFmpeg

Hit enter and the video compression process should begin. Now, FFmpeg is running to do the video compression job. The video processing progress is showing at the bottom. Tips: compressing 4K UHD videos in FFmpeg is CPU intensive, you'd better shut down other programs running background on your device.

4. Done!

When the video compression completes, the output video file should appear at your specified location. Check for the output video file size and figure out the FFmpeg video compression ratio.

Part 2. How to Compress Video Size using FFmpeg in Python?

FFmpeg-python is a Python wrapper for FFmpeg. Install FFmpeg on Windows or macOS and make the following script for reducing (MP4/MKV/MOV, etc.) video size in Python. Subprocess is the only module being required. Make sure you run the command in run() function. It's more complicated to compress video size using FFmpeg in Python. If you can't handle it, resort to other easy-to-use video compression software.

import subprocess
result = subprocess.run('ffmpeg -i output.mp4 -b 800k output.mp4')
print(result)

compress video FFmpeg Python

ABOUT THE AUTHOR

author - Kaley Torres

Kaley Torres twitter icon

Kaley Torres is a self-motivated, creative editor with eight years of marketing and SEO experience, specializing in writing on DVD, video, audio, images, new digital contents etc. With a partiality DVD collection, Kaley also enjoys digitizing DVD and is keen to share her DVD video conversion solutions as well as video sharing tips on social media.

Home > Video > Resize Video > Compress Video in Adobe Premiere Pro

Newsletter

Stay up-to-date with our news, updates, guides.