I tried creating two separate colorkey filters (as these seem to work better than chromakey filters) like this:
ffmpeg -i input1.mp4 -i input2.mp4 -filter_complex '[1:v]colorkey=0x6AA999:0.1:0.2[ckout1];[0:v][ckout1]overlay[out1];[1:v]colorkey=0x4D827A:0.1:0.2[ckout2];[out1][ckout2]overlay[out2]' -map '[out2]' output.mp4
But this does not seem to filter on both keys. In thinking about why, I think the issue is that both filters are creating transparency in the pixels that match that key, but then the overlay is combining the pixels that weren't filtered out from both keys, so I'm really only getting transparency for pixels which match BOTH filters, instead of those which match either.
I also looked at the blend
filter, with the idea that perhaps I could do something like this in the filter complex:
'[0:v]colorkey='$KEY1':0.1:0.2[ckout1];[0:v]colorkey='$KEY2':0.1:0.2[ckout2];[ckout1][ckout2]blend=c3_expr=min(input1_c3,input2_c3)[out2]' -map '[out2]'
The idea being that I would take the minimum alpha value (opacity) of each input source for each pixel and make that the alpha value for the output for that pixel. I am assuming (it's not clear from the text) that the "c3" channel is referring to the alpha channel, but I don't see how to get the alpha value from each input. What would go in place of input1_c3
and input2_c3
?
Or is there another way to do this that is better?