I'm trying to achieve complex effect with ffmpeg
, but I seem to be failing the syntax of -filter_complex
somewhere.
The goal is to capture part of the screen (with UScreenCapture direct show device) where I display two images side by side (called [bg]
and [key
], or [rgb]
and [alpha]
in the filter chain). On the left is the image itself, on the right its alpha channel, shown in black and white. Then I want to compose that on top of another input (some video input from a file or other capture device... but a file in this case, called [video]
in the filter chain).
To compose the three together, first I blend 'multiply' the alpha with the video, turning to black everything outside the white alpha(dumped into [out1]
), and blend 'multiply' the image background with the negative alpha (dumped into [out2]
). To end the chain I add the two outs with blend mode addition... and dump it to a pipe
Theoretically it should work but it keeps complaining about stream specifier 'alpha' matching no stream:
ffmpeg -v debug -f dshow -i video=UScreenCapture -i chroma.mp4 -filter_complex \
"[0:v]split[bg][key]; \
[bg]crop=720:576:0:0, format=gbrap,setsar=0:1[rgb]; \
[key]crop=720:576:720:0,format=gray8,setsar=0:1,scale=720:576[alpha]; \
[1:v]scale=720:576,format=yuv420p,setsar=0:1[video]; \
[alpha]negate[neg_alpha]; \
[video][neg_alpha]blend=all_mode='multiply':all_opacity=1[masked_video]; \
[rgb][alpha]blend=all_mode='multiply':all_opacity=1[masked_3d]; \
[masked_video][masked_3d]blend=all_mode='addition':all_opacity=1[out]" \
-map "[out]"-c:v mpeg2video -f avi - | ffplay -