videofilterffmpegvideo-processing

What is the purpose of the split filter in FFMpeg?


In complex filters specifically, is there a situation where it is necessary to use the split filter, rather than use the same input multiple times?

For example, consider the following FFmpeg command:

ffmpeg -i input.mp4 -filter_complex \
  "[0:v]hflip[out1]; \
   [0:v]boxblur=10[blurred]; \
   [out1][blurred]hstack[out]" \
 -map "[out]" output.mp4

It seems to work perfectly fine, But I saw some tutorials consistently using "split" in situations like this, where the input is split before any other filters are applied, making me wonder if there are unintended consequences to using inputs directly like this, I tried to find filters that may alter the input or optimization issues but I found no difference. So, it begs the question, what's the purpose of "split"? and when should I use it?


Solution

  • split is necessary when one wishes to reuse an already filtered stream multiple times, e.g.

    one can't do this

    [0:v]hflip[flipped];
    [flipped]scale=1920x1080[fhd];
    [flipped]scale=640x260[sd];
    

    instead,

    [0:v]hflip,split=2[flipped1][flipped2];
    [flipped1]scale=1920x1080[fhd];
    [flipped2]scale=640x260[sd];
    

    If you're feeding the raw input (e.g. 0:v, 1:a:2) that can be referenced multiple times without split.