How to Reduce Video File Sizes Using FFMPEG from Linux Terminal

Video File Featured Image

Saving videos on personal storage drives, cloud services or disks can prove tricky when space is limited. Reducing file sizes makes holding onto larger files and growing collections easier, but some ways of doing this are more effective than others.

There are a lot of tools to choose from in the video-handling arena, capable of optimizing file sizes. However, many of these including VLC, Cinelerra and Blender share the same engine beneath their UI – a command-line utility entitled FFMPEG. Here we will show you how you can reduce video file sizes using FFMPEG from Linux terminal.

What Is FFMPEG?

FFMPEG is arguably the most full-featured command-line media-handling utility in the Linux software ecosystem. Among a great gamut of features, this tool can handle the creation of GIFs, chop/edit videos and record as well.

Most importantly, FFMPEG can convert videos at a surprisingly granular level, allowing for quality to be maintained to a large degree while file sizes are positively halved (or even quartered in extreme cases).

Installation

Installing FFMPEG in Ubuntu is simple enough to do with the following command:

Video File Ffmpeg Install

When the installation has finished, you are ready to get started.

Usage

Using FFMPEG can be as simple as the following:

Video File Simple Conversion

However, to truly reduce file sizes of videos in an optimal way, we’ll need to take certain extension attributes into consideration.

The Optimization Equation

When it comes to video files, not all types are created equally. For instance, avi file extensions tend to be much bigger than mp4 files.

This comes down to the logic built into the container’s intended environment, but even that can be modified by choosing the right codec for encoding your file, favoring quality with larger sizes or portability with smaller ones.

The takeaway here is that the smallest mp4 of a specific video will always be smaller than the smallest avi of the same video, but there is variability in size and quality even within either of these file types.

Interestingly enough, though, mp4s are not the lowest one can go in pursuit of the perfect tiny file size. The current crowned champions of quality retentive video file types are the various containers available for flash videos and Windows media videos (FLV and WMV). These form part of a simple equation we can use to get super-small, yet high-quality video files:

small-container + efficient-codec + low-fps + low-bitrate = tiny/high-quality video file

Note: For the purposes of this article, high-quality means minimal visible pixelation or significant loss of color. A reduction in quality is inevitable to some degree if we really want to optimize file size; however, just how noticeable this is depends on what we are optimizing. Movement speed, color variety and sound quality/density play a part in deciding how low we can go with our settings.

The options are plentiful in the world of video codecs and containers, so we’ll keep things simple by using WMV 8. (FFMPEG does not fully support WMV 9 yet.)

Optimizing a Video

When we run FFMPEG, it will convert our input video to the file type we specify using parameters we set with special flags. Here is our code:

Video File Conversion

Video File Conversion 2

The code above converts our input file into one with a bitrate of 1Mbps, a framerate of 24fps, a constant rate factor of 19 and a .wmv extension. Change “input.mp4” to suit your needs and adjust the -crf value to a higher number for a smaller file size (with progressively lower quality).

FFMPEG is powerful enough to achieve far more than was touched on here. Its complete feature-set is impressive, and there’s way more to it than just video conversions. Check out the project’s official website for more info.

3 comments

  1. Hi
    What should be command line if to keep same parameters for output.file?
    I checked yours – size is smaller but quality useless.

  2. By the way
    Recommend dmMediaConverter – it made half size vs same quality from mp4->mkv vs H265
    only back side – it use 100% cpu.

  3. ffmpeg can be as simple as ‘ffmpeg -i input.video output.video’ – but it very rarely is. That is, if you want to do something useful with it, it will never be that simple. Not a criticism, but a caveat emptor: ffmpeg is meant to do complex tasks, and there is a lot of complexity to its usage.

Leave a Comment

Yeah! You've decided to leave a comment. That's fantastic! Check out our comment policy here. Let's have a personal and meaningful conversation.