1

I do splitscreens with ffmpeg xstack - these get really large after some iterations, so I want to scale them down in the process. But I get the error "Filter scale has an unconnected output". This is my code (called from Python but for the filter it should make no difference):

subprocess.call(['ffmpeg', '-i', input_clips[j + 0], '-i', input_clips[j + 1], '-i', input_clips[j + 2], '-i', input_clips[j + 3], '-filter_complex', '[0:v]scale=3840:1920[v0];[1:v]scale=3840:1920[v1];[2:v]scale=3840:1920[v2];[3:v]scale=3840:1920[v3];[0:v][1:v][2:v][3:v]xstack=inputs=4:layout=0_0|0_h0|w0_0|w0_h0[v]', '-map', '[v]', '-c:v', 'libx265', '-crf', '12', '-preset', 'ultrafast', '-an', output])

I know the problem is in the in- and output syntax, but I just don't find any comprehensible explanation on this (it's too short to google): What do eg. [0:v] [v0] and [v] really mean?

1 Answer 1

4

Give xstack the scaled videos. Your command is providing the original unscaled video to xstack.

Use:

subprocess.call(['ffmpeg', '-i', input_clips[j + 0], '-i', input_clips[j + 1], '-i', input_clips[j + 2], '-i', input_clips[j + 3], '-filter_complex', '[0:v]scale=3840:1920[v0];[1:v]scale=3840:1920[v1];[2:v]scale=3840:1920[v2];[3:v]scale=3840:1920[v3];[v0][v1][v2][v3]xstack=inputs=4:layout=0_0|0_h0|w0_0|w0_h0[v]', '-map', '[v]', '-c:v', 'libx265', '-crf', '12', '-preset', 'ultrafast', '-an', output])

You're getting the error Filter scale has an unconnected output because all filter outputs must be consumed: usually either by other filters or by directing it into an output file. But your command just orphaned the outputs from the scale filters.

What do eg. [0:v] [v0] and [v] really mean?

  • [0:v] 0 is input #0. v is all video from input #0. So it is referring to the video from your first input which is named input_clips[j + 0] in your command.
  • [v0] is an arbitrary name for the output from one of the scale filters. You could name it whatever you want such as [superamazingscaledvideo] if you prefer.
  • [v] is another arbitrary name referring to the final output from xstack which is then used in the -map option to choose the output from xstack and put it in the output file. Again, you can use whatever name you want. In this case [v] and -map [v] can be optionally be omitted because by default the output from -filter_complex will be included into the output file, but it's not a bad idea to be specific.

See FFmpeg filtering introduction for more info.

1
  • this is super awesome (and also works), thanks for the explanation! i wish i would have known this earlier... : ) Commented Jan 8, 2021 at 1:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .