[FFmpeg-user] blend: subtract to alpha video

Stefan de Konink stefan at konink.de
Sun Sep 26 14:22:54 EEST 2021


The blend video filter allows to 'subtract' two frames from each other. But 
I am unable to get this to work as I would expect with Gimp's color-erase.

This gives me an all transparent png (including the reversed input), it is 
not what I expect, but at least it has a transparent output.

ffmpeg -i input.png -i input-green.png -filter_complex 
"blend=all_mode=subtract" -vcodec png /tmp/test-blend.png


My input video gives me either a black background with green outlines, or a 
black background with a fuchsia where white was.

ffmpeg -i test.mkv -i green.png -filter_complex "blend=all_mode=subtract" 
-vcodec png /tmp/test-blend.mkv


The root cause seems to be that my input MPNG file is rgb24, and should be 
rgba. The line below gives me a fully transparent image.

ffmpeg -y -i test.mkv -i green.png -filter_complex 
"[0:v]format=rgba[v];[v][1:v]blend=all_mode=subtract[outv]" -map "[outv]" 
-vcodec png /tmp/test-blend.mkv



What I am looking for is the output similar to color-erase.png. Is this 
already possible with ffmpeg?


-- 
Stefan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: color-erase.png
Type: image/png
Size: 28044 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-user/attachments/20210926/73f91167/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: input.png
Type: image/png
Size: 25235 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-user/attachments/20210926/73f91167/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: input-green.png
Type: image/png
Size: 6144 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-user/attachments/20210926/73f91167/attachment-0002.png>


More information about the ffmpeg-user mailing list