What are the FFMPEG filters?

An FFMPEG filter is an editing action that is applied to one or more input sources, resulting in one or more outputs. This editing actions can be things like rotating an input video source, adjusting the volume level, overlaying one video source over another, and a long and long etcetera.

Back in a previous lesson (Video containers and video codecs) we explained that for editing any video or audio, FFMPEG needs to follow a fixed steps:

  1. Demuxing the data streams in the input files
  2. Decoding the data streams based on the required codec
  3. Applying any changes to the data
  4. Encoding the data again into a data stream; and
  5. Muxing the data streams into the final output file

The filters are applied in the third step, once the content is decoded and before the content is being encoded again.

We will see later in this lesson that we can chain different filters to apply multiple edititions in the same FFMPEG command, creating really amazing results. A chain of filters is called a filtergraph.

FFMPEG distinguishes between two types of filtergraphs: simple and complex.

Most common filters

There is almost an infinite list of filters, and you will probably never use half of them. But there are a few that are really common in most of the day to day operations:

You can also check our guides to:

Filters syntax

As you will notice as we get deeper into the filter usage, the FFMPEG commands can really become very complex and hard to read, so it's important that you learn step by step.

An FFMPEG filter follow the following syntax:



<filter_name>[=<filter_option>=<option_value>][:<filter_option>=<option_value>]

Thus, there is always the filter name, optionally followed by option-value pairs. The different options-value pairs are separated by a : semicolon character.

Examples of filters:

As you see above, there are filters with a single option, others with 2 and others can have 5 or 6.

With the objective of reducing the length of the commands, most of the filter options have shorter versions. For example, width can usually be abbreviated as w, height as h, etc. This is an example of equivalent filters:

A step further is ommiting the option name, assuming that the order in which the options are provided follows what the filter expect.

For example, the following commands are the same:

Chaining filters

FFMPEG filters can be chained together sequentially using a , comma character.

Example:

crop=x=100:y=100:w=400:h=300,scale=w=600:h=400

The example above crops the video and after, it scales up to 600x400.

Filtergraphs

FFMPEG filter_complex examples

Common errors with FFMPEG filters

Self-evaluation

What is a FFMPEG wrapper?

Published on February 7th, 2022

Author
Bernat Guitart
Bernat Guitart I have spent my whole life working on the Internet. First as a Developer and moving on to being a Product Manager, COO and a Digital Marketing Manager. I am now the CEO of a full-fledged Internet company, developing product and implementing our whole online eCommerce strategy.