Use Commas and Semicolons in FFmpeg Filtergraphs

Understanding how to use commas and semicolons in FFmpeg filtergraphs is essential for building complex audio and video processing pipelines. This guide provides a clear and direct explanation of how these two punctuation marks function as syntax operators to define linear chains and parallel connections within FFmpeg.

Commas separate filters in a single chain

In FFmpeg, a comma (,) is used to link filters sequentially within a single stream, known as a filterchain. When you connect filters with a comma, the output of the preceding filter automatically feeds directly into the input of the next filter.

For example, in the following filtergraph: scale=1280:720,transpose=1

The video is first resized to 1280x720 by the scale filter, and then that scaled output is immediately rotated 90 degrees clockwise by the transpose filter. No explicit stream labeling is required because the comma implies a direct, automatic flow from left to right.

Semicolons separate independent filterchains

A semicolon (;) is used to separate distinct filterchains that do not automatically feed into one another. Semicolons allow you to define multiple parallel paths or separate processing steps within a single overall filtergraph. To connect these separate chains, you must use explicit link labels enclosed in square brackets.

For example, in this filtergraph: [0:v]scale=1280:720[scaled];[scaled]transpose=1[out]

The semicolon splits the command into two separate chains. The first chain takes the input video [0:v], scales it, and labels the output stream as [scaled]. The semicolon ends this chain. The second chain then starts, explicitly taking the [scaled] stream as its input, rotating it, and outputting the final result as [out].

Summary of rules