🥝GuideKiwi
Free Guide

Free Guide to FFmpeg Video Compression Basics

What FFmpeg Is and Why Video Compression Matters FFmpeg is a free, open-source software tool that works with video and audio files. It's a command-line progr...

GuideKiwi Editorial Team·

What FFmpeg Is and Why Video Compression Matters

FFmpeg is a free, open-source software tool that works with video and audio files. It's a command-line program, meaning you type text commands rather than clicking buttons in a visual interface. Despite this text-based approach, FFmpeg is one of the most powerful video processing tools available and runs on Windows, Mac, and Linux computers.

Video files can be extremely large. A single hour of video recorded on a smartphone might take up 3 to 10 gigabytes of storage space. When you need to send videos over the internet, store them on limited devices, or archive footage, file size becomes a real problem. This is where compression comes in. Compression reduces a video's file size while trying to maintain acceptable picture quality.

Video compression works by removing information from the video in ways that are less noticeable to human eyes. There are two main types of compression. Lossless compression removes only unnecessary data that doesn't affect how the video looks—like duplicate information between frames. Lossy compression removes some actual visual information, but it's designed to remove details humans rarely notice, like slight color variations in backgrounds or minor details in distant objects.

The relationship between file size and quality matters for practical reasons. A high-resolution 4K video might be unwatchable over a slow internet connection without compression. A compressed version at lower quality might stream smoothly. Understanding these tradeoffs helps you make decisions about which settings to use for your specific situation.

FFmpeg handles compression through video codecs. A codec is a set of instructions that tells the computer how to compress and decompress video. Common codecs include H.264, H.265 (also called HEVC), and VP9. Each codec works differently and produces different results at the same file sizes.

Practical takeaway: Before using FFmpeg, identify what matters most for your project. Do you need maximum quality for professional editing, or is smaller file size more important for streaming? Understanding your priority helps you choose the right compression settings.

Installing FFmpeg and Getting Started

Installing FFmpeg depends on your operating system. On Windows, you can visit the FFmpeg website's download page and select the Windows builds. The most straightforward option is downloading a pre-built executable file. After downloading, extract the files to a folder on your computer. You'll then need to add this folder to your system's PATH, which tells Windows where to find FFmpeg when you type commands.

Mac users can install FFmpeg through package managers like Homebrew. Open Terminal and type a simple command, and Homebrew automatically downloads and installs FFmpeg. This is typically faster and cleaner than manual installation. Linux users generally have FFmpeg available through their distribution's package manager—Ubuntu users can install it with a single terminal command.

After installation, you need to access the command line. Windows users open Command Prompt or PowerShell. Mac and Linux users open Terminal. Once the command line is open, you can test if FFmpeg installed correctly by typing "ffmpeg -version" and pressing Enter. If you see version information displayed, the installation worked.

Understanding the basic structure of an FFmpeg command matters because every compression task follows a similar pattern. The basic format is: ffmpeg -i input.mp4 -c:v libx264 output.mp4. This structure has four main parts: "ffmpeg" tells the computer to run the program, "-i input.mp4" specifies your source video file, "-c:v libx264" specifies which codec to use for video compression, and "output.mp4" names the resulting file.

Most video files contain multiple data streams. A video file might have a video stream (the picture), an audio stream (the sound), and even subtitle streams. FFmpeg lets you handle each stream separately. You can compress the video stream while leaving the audio untouched, or vice versa. This flexibility is one reason FFmpeg is preferred by many professionals.

Practical takeaway: Take time to properly install FFmpeg for your system and confirm it works with a version check. Having FFmpeg correctly installed prevents frustrating error messages when you start compressing videos.

Understanding Video Codecs and Their Tradeoffs

H.264, also called AVC or MPEG-4 Part 10, has been the standard video codec for roughly 15 years. It's widely supported across devices, cameras, and streaming platforms. YouTube, Netflix, and most video sharing sites accept and use H.264. A typical H.264 file achieves reasonable file sizes with acceptable quality. However, H.264 encodes videos more slowly than some newer codecs, and it doesn't compress quite as efficiently as newer options.

H.265, also called HEVC, is H.264's successor. It can achieve roughly 50% better compression than H.264 at the same quality level, or put another way, it produces similar quality files at half the size. This sounds ideal, but H.265 has limitations. It encodes much more slowly—sometimes 5 to 10 times slower. It also isn't supported on all older devices or platforms. Some streaming services still don't fully support H.265, though this is gradually changing.

VP9, developed by Google, is another modern codec offering compression similar to H.265. VP9 is open-source and free from patent restrictions, which appeals to many developers. However, VP9 also encodes very slowly and has less universal support than H.264. AV1 is an even newer codec that promises better compression than both H.265 and VP9, but it encodes so slowly that it's primarily used for streaming services to prepare videos in advance, not for real-time or quick processing.

Choosing between these codecs requires understanding your constraints. If you need broad compatibility and reasonable file sizes, H.264 remains a solid choice. If maximum compression matters and you can wait for encoding to finish, H.265 makes sense. If you prioritize open standards and long-term freedom from patent concerns, VP9 is worth considering. For archival purposes where you won't need to re-encode later, choosing the most efficient codec available today makes sense because you'll only process it once.

Beyond the codec choice, you'll encounter the concept of bitrate. Bitrate measures how much data per second is used to represent the video. A bitrate of 5000 kbps (kilobits per second) means roughly 5 megabits of data flow into each second of video. Higher bitrates preserve more detail but create larger files. Lower bitrates reduce file size but decrease visible quality. Finding the right bitrate for your content and purpose is crucial to balancing quality and file size.

Practical takeaway: H.264 is the safest default choice for most users because of its broad compatibility and reasonable speed. Reserve H.265 for projects where file size savings justify longer processing times or where the target platform supports it.

Basic Compression Commands and Quality Settings

The simplest FFmpeg compression command takes a video file and re-encodes it with default settings. Typing "ffmpeg -i input.mp4 output.mp4" tells FFmpeg to convert input.mp4 using H.264 codec and save it as output.mp4. This command works, but it doesn't give you control over quality. FFmpeg uses default settings that may or may not match your needs.

Adding a preset parameter gives you quality control. FFmpeg's presets range from ultrafast to veryslow, with options like superfast, veryfast, fast, medium, slow, and slower. These presets control the balance between encoding speed and file size. A "ultrafast" preset encodes quickly but produces larger files. A "veryslow" preset takes much longer but creates smaller files. The command "ffmpeg -i input.mp4 -preset fast output.mp4" uses the fast preset, which provides reasonable compression in reasonable time.

For more direct control, you can specify a bitrate. The command "ffmpeg -i input.mp4 -b:v 2500k output.mp4" sets the video bitrate to 2500 kilobits per second. This directly controls file size—use 2500k for reasonable quality at moderate file sizes, or 1000k for smaller files at lower quality. You might use 5000k or higher for high-quality work.

Combining multiple parameters gives you fine control. A command like "ffmpeg -i input.mp4 -c:v libx264 -preset medium

🥝

More guides on the way

Browse our full collection of free guides on topics that matter.

Browse All Guides →