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 -
  • You should trim your filtergraph, if possible, to keep only the minimum filters necessary for the problem to arise. You should also include the complete console output from your command.
    – llogan
    Dec 2 '14 at 18:22
  • Add a space before -c:v mpeg2video
    – user6898
    Dec 6 '14 at 10:54
  • Have you tested to see that this works?
    – Dr Mayhem
    Dec 9 '14 at 9:00

filgergraph as described can not work, you can not use [alpha] twice, you need to split it:

[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,split[alpha2][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][alpha2]blend=all_mode='multiply':all_opacity=1[masked_3d]; [masked_video][masked_3d]blend=all_mode='addition':all_opacity=1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.