Apply Multiple Filters to One Video Using FFmpeg Split

This guide explains how to use the FFmpeg split filter to duplicate a single video stream, apply different filters to each stream, and save them as separate output files in a single command execution. This method is highly efficient because FFmpeg only decodes the source video once, saving significant processing time and CPU resources.

The FFmpeg Command Syntax

To process a video stream with multiple filters and output different files, you must use FFmpeg’s -filter_complex option.

Here is the template command to achieve this:

ffmpeg -i input.mp4 -filter_complex "[0:v]split=2[temp1][temp2]; [temp1]filter_one[out1]; [temp2]filter_two[out2]" -map "[out1]" output1.mp4 -map "[out2]" output2.mp4

Practical Example

In this practical example, we will take an input video (input.mp4), split it, apply a grayscale filter to the first stream, scale the second stream to 720p, and output them as two distinct files while retaining the original audio.

Run the following command:

ffmpeg -i input.mp4 -filter_complex \
"[0:v]split=2[stream1][stream2]; \
 [stream1]hue=s=0[gray]; \
 [stream2]scale=1280:720[scaled]" \
-map "[gray]" -map 0:a? black_and_white.mp4 \
-map "[scaled]" -map 0:a? scaled_720p.mp4

Command Breakdown