FFmpeg filters come in two styles: a chain joined with commas, and a graph joined with labels. This lesson covers what the four symbols (, ; : [ ]) do, and when -vf is enough versus when you need -filter_complex.
In the Chapter 10 hands-on lesson (Encoding practice with FFmpeg) you only touched encoder options. In real work, though, commands get long mostly because of filters that process the video before encoding. Shrinking, cropping, deinterlacing, and adding subtitles are all filters. Before learning the filters one by one, this chapter starts with the syntax for chaining them together.
FFmpeg decodes the file into uncompressed frames, passes those frames through filters, and hands them to the encoder. A filter changes the decoded pixels, so the moment you apply one, that stream has to be re-encoded. That is why -c:v copy and -vf can't be used together (FFmpeg reports an error). The same goes for audio: -af can't be combined with -c:a copy.
If the job is to process one input video into one output, -vf (video) and -af (audio) are enough. Joining filters with a comma (,) feeds the output of the previous filter into the next one. Options within a filter are separated with a colon (:).
ffmpeg -i input.mp4 \
-vf "crop=1920:800:0:140,scale=1280:-2,format=yuv420p" \
-c:v libx264 -crf 20 -c:a copy output.mp4A chain runs left to right. If crop comes before scale, you crop in the original resolution; if you reverse them, you have to crop using coordinates from the already-shrunk frame. In general, the order "crop → scale → pad → subtitles → pixel format" makes your intent easiest to read. Subtitle placement comes up again in Lesson 6.
Placing two videos side by side, overlaying a logo on a video, or making two outputs of different resolutions from one input all involve a flow that splits and merges. For these you use `-filter_complex` and attach bracketed labels at the connection points. Multiple filter chains (groups joined with commas) are separated with a semicolon (;).
The syntax is documented under "Filtergraph description" in the official FFmpeg documentation.
ffmpeg -i original.mp4 -i encoded.mp4 \
-filter_complex "[0:v][1:v]hstack=inputs=2[v]" \
-map "[v]" -c:v libx264 -crf 18 compare.mp4ffmpeg -i input.mp4 \
-filter_complex "[0:v]split=2[a][b];[b]scale=-2:720[small]" \
-map "[a]" -c:v libx264 -crf 20 full.mp4 \
-map "[small]" -c:v libx264 -crf 22 small.mp4The result labels of -filter_complex ([v], [small]) only end up in the output if you pull them out with `-map`. If you create a label and forget -map, FFmpeg falls back to its default stream selection and may use a stream that never went through the filter. Note that an output without a label is not automatically connected to the next stage.
min(1280,iw)), the comma is read as a chain separator. Either wrap the expression in single quotes (scale='min(1280,iw)':-2) or put a backslash before the comma (\,). This is where shell quoting and FFmpeg quoting overlap, so if it doesn't work, check the [escaping section of the FFmpeg documentation](https://ffmpeg.org/ffmpeg-filters.html#Notes-on-filtergraph-escaping).ffmpeg -filters to see the filters in your build, and ffmpeg -h filter=scale (for example) to check options and defaults. Some filters are missing depending on the build (zscale, subtitles, and so on).When the filter string gets long, shell quoting turns into a nightmare. In that case you can write the filtergraph in a text file and read it with -filter_complex_script graph.txt (an option listed in the FFmpeg documentation). Line breaks and comments make it easier to read, and you avoid shell-escaping problems. For repeat jobs, you can also start by building the base command with the FFmpeg Command Builder and then adding filters to it.
The whole structure of filters connected to one another. It includes both comma-joined chains and label-joined branches and merges.
Options that apply a filter chain to a single video/audio stream. Used when there is one input and one output.
The option for filtergraphs with more than one input or output. Bracketed labels and -map go together.
A connection-point marker written as [name] inside a filtergraph. [0:v] is the video stream of input 0.
What is the fundamental reason ffmpeg -i in.mp4 -vf scale=1280:-2 -c:v copy out.mp4 fails?
You used -filter_complex and created a [v] label. How do you get this result into the output file?