FFmpeg Split Filter: Split Video Into Three Streams
This article explains how to use the FFmpeg split filter
to duplicate a single video input into three identical, independent
streams for multi-filter processing. You will learn the correct
filtergraph syntax, how to label the split streams, and how to apply
different filters to each stream in a single command execution.
The Split Filter Syntax
To split a video stream in FFmpeg, you use the split
filter within a complex filtergraph (-filter_complex). By
default, the split filter creates two outputs, but you can
specify the exact number of outputs by passing a parameter. For three
streams, the syntax is split=3.
Here is the basic template for splitting an input video into three streams:
-filter_complex "[0:v]split=3[temp1][temp2][temp3]"In this command: * [0:v] represents the video stream of
the first input file. * split=3 instructs FFmpeg to create
three identical copies of the input stream. *
[temp1][temp2][temp3] are arbitrary custom labels assigned
to each of the three resulting streams so they can be referenced later
in the filtergraph.
Real-World Example: Processing Three Streams Simultaneously
Once you have split the video into three streams, you can apply different filters to each stream. In the example below, we split the input video and apply three different effects: one stream is scaled, the second is converted to grayscale, and the third has an edge detection filter applied.
ffmpeg -i input.mp4 -filter_complex \
"[0:v]split=3[v1][v2][v3]; \
[v1]scale=1280:720[out_scaled]; \
[v2]format=gray[out_gray]; \
[v3]edgedetect[out_edges]" \
-map "[out_scaled]" output_scaled.mp4 \
-map "[out_gray]" output_gray.mp4 \
-map "[out_edges]" output_edges.mp4Command Breakdown
-i input.mp4: Defines the source video file.[0:v]split=3[v1][v2][v3]: Takes the video stream from the first input (0:v), duplicates it three times, and labels the outputs as[v1],[v2], and[v3].[v1]scale=1280:720[out_scaled]: Takes the first split stream[v1], resizes it to 720p, and labels the result[out_scaled].[v2]format=gray[out_gray]: Takes the second split stream[v2], converts it to grayscale, and labels the result[out_gray].[v3]edgedetect[out_edges]: Takes the third split stream[v3], applies an edge detection filter, and labels the result[out_edges].-mapflags: Maps each processed stream to its respective output file (output_scaled.mp4,output_gray.mp4, andoutput_edges.mp4).
This approach processes the input file once and generates three distinct outputs, saving significant CPU and disk I/O resources compared to running three separate FFmpeg commands.