---
title: 'FFMPEG & Filter Complex: A Visual Guide to the Filtergraph Usage'
source: 'https://youtube.com/watch?v=Yc16I6i9xDU'
video_id: 'Yc16I6i9xDU'
date: 2026-06-18
duration_sec: 0
---

# FFMPEG & Filter Complex: A Visual Guide to the Filtergraph Usage

> Source: [FFMPEG & Filter Complex: A Visual Guide to the Filtergraph Usage](https://youtube.com/watch?v=Yc16I6i9xDU)

## Summary

This tutorial explains how to use FFmpeg's filter_complex (filtergraph) system to perform advanced video editing tasks like crossfades and RGB channel extraction. It starts with a basic crossfade between two videos, addressing common errors like timebase mismatches, then demonstrates a more complex filtergraph to split a video into its RGB components and tile them for visual analysis.

### Key Points

- **Introduction to Filter Complex** [0:00] — Filter complex in FFmpeg is for filters that require multiple inputs or outputs, such as concatenation, split, or crossfade.
- **Setup and Terminal** [1:03] — The presenter uses Windows Terminal, which allows multiple shell profiles (CMD, PowerShell, WSL) in tabs, recommended for command-line work.
- **Example Videos: Singapore Clips** [2:07] — Two short videos of Singapore (Marina Bay and night view) are used as inputs for a crossfade transition.
- **Crossfade Filter Basics** [3:03] — Basic command structure: `ffmpeg -i input1 -i input2 -filter_complex "[0][1]xfade=transition=fade:duration=1:offset=5" -c:v libx264 -preset slow -crf 15 output.mp4`. Offset is the time when first video starts fading out.
- **Timebase Error and Fix** [6:14] — Error 'first input link main time base do not match' occurs due to incompatible internal timestamps. Fix: pre-process each input with `settb=AVTB` and `setpts=PTS-STARTPTS` to normalise timebase, then name outputs (e.g., [out0], [out1]) and feed them into xfade.
- **Result: Successful Crossfade** [11:03] — After applying the timebase fix, the crossfade transition works correctly, blending the two Singapore videos smoothly.
- **RGB Channel Split with Tiling** [12:01] — Advanced example: use `split` filter to create three copies of the video, then apply `lutrgb` to isolate red, green, blue channels, and assemble them in a 2x2 grid using `hstack` and `vstack` filters.
- **RGB Filtergraph Structure** [15:05] — Filtergraph: [0]split=3[v1][v2][v3]; [v1]lutrgb=g=0:b=0[red]; [v2]lutrgb=r=0:b=0[green]; [v3]lutrgb=r=0:g=0[blue]; [0][red]hstack=inputs=2[top]; [green][blue]hstack=inputs=2[bottom]; [top][bottom]vstack=inputs=2[out]. Output is a single frame showing original + RGB channels.
- **Final Output and Verification** [19:01] — The resulting MKV file displays a tiled view: original video top-left, red channel top-right, green channel bottom-left, blue channel bottom-right.
- **Filter Complex Recap** [19:28] — General pattern: `[input_label]filter_name=param1=val1:param2=val2[output_label]`. Multiple filters separated by semicolons. Use `ffmpeg -filters` to list all filters, pipe with `findstr` on Windows to search for specific filters (e.g., split).
- **Audio Crossfader Mention** [21:59] — An audio crossfade filter (acrossfade) exists for audio streams, similar to video xfade.

### Conclusion

FFmpeg's filter_complex is a powerful tool for creating transitions and multi-source video compositions. Mastering the filtergraph syntax and handling timebase inconsistencies are essential for reliable outputs.

## Transcript

hello this is Steph and welcome to my
channel again and today I'm going to
show you how to use the complex filters
uh better the filter complex using FM
pack first of all what are the filter
complex
um the filter is complex are the complex
filters filters complex is the options
that you have in a pack is uh that
category of filters that require uh
multiple inputs or multiple outputs
and we saw something in the past for
example the concatenation for example
with the GIF we saw the split so we have
a rough idea about what a complex filter
is and now we're going to see something
a bit better in detail
uh here we have Windows ready behind me
at the moment it's time to get started
okay here we are we have the terminal at
the top uh this is the windows terminal
so I changed from the CMD uh to this
Windows terminal it's super cool because
uh what you can do is also to
select the one that you want so not only
the command prompt that I'll be using
most of the times but the windows
Powershell develop compound prompt for
visual studio
um the
um
WSL windows subsystem for Linux I
install Ubuntu I have something with a
anaconda mini counter actually
um like to switch from one in the other
or having multiple tabs here it is a
super super cool and uh
I suggested if you would like to go on
um coding and using the command line so
here we have two videos
here on the left
where
so videos about Singapore every people
who follow me on Instagram uh I take
advantage to
give the my references about the social
media here
um
so um I've been to Singapore recently
and I would like to make a video about
Singapore I have a couple of videos here
play
Singapore one and this is uh the first
video
Singapore Marina Bay and the marina here
nice place to be and on the other we
have
Singapore
night
It's a Wonderful view accelerated view
of Singapore where the
cool so we would like to make a
Crossfade so it's it is a transition
from a video to another but in a linear
way so we don't want an Abrupt change
from one to the other it's not a
concatenation even if we did a
concatenation
advantage to show you
part about the concatenation here we use
the a filter complex actually but what
we would like to use is a so-called
Crossfade so here we have a
the
um the Crossfade filter there is a
called The X fade so the base code
stayed like this
and
what you would like to use is a F10 pack
minus I and the filter the freight and
the Fellas we want this input so here if
from Peg minus I single
one and then minus I single port two
these are the input files and then we
are immediately using the filter complex
so the filter complex is uh something
that accepts uh
multiple inputs multiple outputs and you
can also apply multiple filters here so
here we have for example the first input
and the second input so here we can put
zero and one like this so the input is
uh put it this way before the name of
the field name of the and
after
the equal sign we got to put the filter
configuration so here we've got to put
the parameter transition
here my transition I want to be a Fades
it's fading from a video to another
I got to set the duration of the fade in
this case it is one second
and also
um we got to put the offset what is the
offset the offset is the
um the time I want the first video to
start fading out so here in this case I
have a video that is more or less 10
seconds long so I can put it in the
middle five seconds
and in the end I can put the name of the
parameters so the name of the parameters
uh the code sorry the collect parameters
leave x264
preset
slow minus CR f
at 15 so not so so a fairly high quality
but not the super high quality in order
to keep this phase
the space contained and
then
we can put the name of the files in this
case we can say Singapore
xfader.np4 and let's see what happens
in this case we have an error what is
the the error here it says the first
input linked main time base do not match
the corresponding second input link X3
so we have the time base so the let's
say the internal clock with which we are
ticking the advancement from one frame
and the other that is uh not set
correctly here this is faster than this
this has nothing to do with the frame
rate is only the advancement in terms of
time stamp that is present within the
file so what it would like to do is uh
to set the time base to the
um
photo audio video time based it usually
is calculated with the frame rate if I'm
not wrong so this is the what I found
out so if you um
correct me but this is a calculated
based
audio and the video time based
and so what we can do is to apply this
before the Crossfade so what can we do
we are still or we can use the previous
command so we have the
Singapore one Singapore two files this
uh still accepts the two inputs so here
let's put a bit of space then later we
are packing everything back
so what shall we do with the first input
with the first input we said that we
want to set the time base in order to
put it to the audio video time based so
set TB
equals to a b t b
so capital letters and then we're going
to put the set PTS
to the B the beginning of the uh
as you can do so start PTS
in this case we need to give an output
name so in this case it can be out
zero
the output file zero and then we got to
put the uh
semicolon the semicolon separates the
different filters so we have a first
um
set TB
and the set BTS then we got this output
there is a
by semicolon to the second output and in
the set sorry the second input file
second input file needs the same thing
so in this case we have the set TV
set PTS
equal to the pts and start BTS
and in this case we're going to call
this out one so we have the output uh so
we got just to sum up
first input that we call the zero file
zero that passes through the set time
base set BTS and it exit as out zero
then we got the second that is called
one it's a right here second one then
it's going it's going through the same
thing so we've got the the set TB set
time base and the set pts and it's
called the out one so we got out zero
and out one after we have the out zero
and the out one we're going to merge
them together in order to obtain a
single output in this case there's a no
need to call the output
um
because
it's like a sink we put the output
unnamed it and here
we got to put the first input and the
first a second in sorry the first output
of the previous
pipe and the output of the second pipe
coming from the second file so here we
got to put out zero
and uh out
Crossfade transition and blah blah with
everything that we said before and let's
see if now it's working
it asks if you want to overwrite the
file and we click yes
and it seems the thing is working cool
so we wait a bit of time until this is
finished
and uh you will see the speed
yeah it is more or less recorded no
video and now it's time to play uh
Beautiful video so we've got the
Singapore X fade
and here we go with the first input
there is a transition from the first
video to the second
cool so I got to say that this thing
about the set time base is a bit uh
say not the forecast it's something that
I didn't know so
um
most normally this is a thing that you
shouldn't do but the
the Crossfade is the necessary one but
so we saw a slightly more complex filter
complex so-called filter graph
that
um
fine
that's fine feel the complex
okay we have our Crossfade video we just
created and now we are going to use it
to make a video with the rgmb together
all in a single video with a tiling so
original video red Channel green Channel
blue Channel
and we use a filtered complex so to
understand that how the filter complex
are working so we are using FM pack and
seeing Apple X fade.mp4 is our input
file here we can repeat the input
multiple times but we use the split
filter which is a bit more clever and so
it makes us understand better how the
filter graph is working so we have the
inputs and the outputs explained better
with a complex field you're going to use
so then we're going to use the filter
complex
we use the accent go to the new line the
triangle accent
and uh the next line would be the first
line of the filter so here we put the
quote and our input is the file so we
have the zero then we put a split the
split requires the outputs
parameter the outputs parameter we have
three channels so we have a one two and
three in this case uh how can we call
them we call them
um let's say uh V1
V2 and V3
so we have a
zero there is an input then B1 V2 V3
where that will be the input for the
next filters and what are the next
filters the next filters will be
so the filter is a loot RGB
if this stands for lookup table RGB in
this case we can make correspondences
between inputs and outputs uh
different channels in the RGB color
space and uh
so root RGB
this is a red channel so we got to put
the green at zero
and the blue at zero
and this will be our red Channel
and
colon
Uline
we have a steal the loot RGB where we
put in this case the red is zero and the
blue at zero since we want the the green
Channel
RG
okay and the third line will be V3
loot RGB equals to a red of zero and a
green of zero since we want the blue
Channel
and now we separate the three rgmp
then now we want to put on the top line
the input and the red channel so we put
a h stack horizontal stack of these two
inputs and the same thing will be done
at the bottom where the the green and
the blue channel so here the next will
be the input video Zero and a red
Channel
this case it is on each stack
equal to inputs
so this is the parameter that we need to
accept the H stack accepts the inputs
equals to two since we have the uh zero
and Dr and
we name it top
oh
okay and we do the same thing with the G
and the B
right here there is on each stack
with two inputs
and this will be our bottom
okay
and now the final filter uh the final
one will be a vertical stack so we put
the top and the bottom together
and so we have the top and we have the
bottom
with this stack equals to
inputs to the same as each stack to be
in the v stack go to two here we can
select if we wanted to give an output to
the output a name or not so here we can
for example put out
is a output but you got to keep in mind
that here we got to put a map
out
in this way if you want you can put it
in this case just to avoid since the
notation is quite long and putting
something like this is a bit more
um
shorter and won't stand back we
understand better what it's doing since
the output is one so it's okay
now it's time to put our options so
there is the lead backs 264
preset
let's put the slow
and as a constant rate Factor we put 18
so a fairly good quality but not the
maximum just to contain the size of the
file and finally we give a name
[Music]
to do it so we can it can be Singapore
it's fader RGB
as format we can put MKV let's see
how it can be
good uh I think everything is okay so to
sum up we have the splitting three
channels then we take the red green and
blue of the three Channel we just output
from the split then we have the
horizontal Stacks we put the two videos
together respectively the input and the
red channels
um then we have the green and the blue
together and then we
see if it is working and it's working
now we wait for the output to be
generated uh now maybe it is a
bit slow but the video is not that long
and we wait until the end of the
processing
[Music]
okay now the processing has finished and
now it's time to play the video so I
think that the video will be too big for
the screen so
um I'm trying to open it with the oclc
and here we go we have the input the red
channel the green Channel and the blue
as we wanted again if you would like to
take a look about how the complex
filters work and to build your
photograph so again we make a sum up
so to set your filter complex it should
be set with a filter from Flex
and then here we put the input
then the name of the filter
with its parameter iron one
uh equals to Value one then the second
value will be in the
uh
a colon then W2
Etc and here we put our output
if we generate from a single input
multiple outputs like the split filter
we put the out one and out to
so here we have all then
with a semicolon we decided what to put
in the next filter and here we put
out one
and
I'll
then we put the name of the filter and
so on and so forth so the fundamental
thing is
input here then output output or outputs
after the filter itself and we go on to
have a better picture about the filters
that we have here in contact we can go
with FM pack minus h
feel this no I'm sorry
if I met if I'm packed minus filters
will show the list of all the filters
that we have available if you want to
look for the filter of choice in Windows
you can use with a pipe fine Str
ucture let's find Str
Ike this
um let's say split
it will find the
dirt is up to you so here we have a
single video with a multiple video
outputs and here we have also
things regarding the audio so same thing
that we did with the video we can do it
with the audio so there's a cross fader
for the audio as well
it's called I think a cross fade check
across fader
um we have a Crossfade of two you've got
the audio streams and here we got the
the X faded ah we also have a x-fit
opens
parameters if I want to check we have
the final meters here we have X fader so
the thing is a FM pack minus h
ilton equals to Theta
and we can take a look at the
type okay it's a transition
who
okay so we saw something about the
filter complex
um I hope you enjoyed this one of the
most complicated things you can do with
fmpeg actually but it will help you a
lot in case you want to automate your uh
video generation process so if you would
like to make crossfades you want to make
fancy facts to your video
substantially sometimes you want to make
a slideshow of your vacation video
essentially you're doing something like
this or either you concatenate or you
Crossfade from one video to the other
there might be something else to say
about the cross fading if you want to do
it in a
good way so maybe it's a bit
uncomfortable to have the offset from
the beginning of the first video
um but knowing if you want to make a
concatenation with a Crossfade or
something but anyway this is a powerful
tool you can look yourself on how to do
it so it's like an overlay
anyway thank you very much if you reach
up to this point I hope you liked it if
you liked it like share and subscribe
and hit the notification Bell to be
always notified with the new video I'll
be releasing and um
I remember you to subscribe and follow
me on the social media uh I maintaining
and trying to maintain at least so
Instagram and Tick Tock uh for new
content
here and uh I hope to see you next time
with new content relative to multimedia
and much much more thank you very much
and ciao ciao
[Music]
foreign
