Opened 4 years ago

Last modified 4 years ago

#8724 new enhancement

chromakey does not observe existing transparency

Reported by: Gavin Owned by:
Priority: wish Component: avfilter
Version: git-master Keywords: chromakey, alpha
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:

The chromakey filter does not observe the existing alpha transparency in the source AVFrame when generating the output.

How to reproduce:

% ffmpeg -i video.mxf -i green_screen4.png -filter_complex "[1:v]chromakey=color=0x00ff00:similarity=0.24:blend=0.01[ckout];[0:v][ckout]overlay[out]" -map "[out]" output.mp4


ffmpeg version git-2020-06-08-d29aaf1 (Windows nightly automated build)

I have created a test image (attached):

  • There is a transparent circle in each of the 4 corners of the image
  • There is a semi-transparent pink circle in the middle of the image.

Compare the input image to the output image and note the differences.

Attachments (2)

green_screen4.png (10.7 KB ) - added by Gavin 4 years ago.
Green screen test clip with semi-transparency
0001-avfilter-vf_chromakey-The-chromakey-filter-preserves.patch (4.1 KB ) - added by Gavin 4 years ago.
Proposed patch

Download all attachments as: .zip

Change History (8)

by Gavin, 4 years ago

Attachment: green_screen4.png added

Green screen test clip with semi-transparency

comment:1 by Elon Musk, 4 years ago

And why it should? Use two chromakeys and blend filter with or mode for alpha plane.

in reply to:  1 comment:2 by Gavin, 4 years ago

Replying to richardpl:

And why it should? Use two chromakeys and blend filter with or mode for alpha plane.

I'm not experienced with chroma key, so I'll turn that around and ask why it shouldn't respect alpha transparency? That is not meant to be a witty retort.

Can you please elaborate on the solution you propose? I don't understand.

comment:3 by Elon Musk, 4 years ago

Priority: normalwish
Type: defectenhancement

comment:4 by Gavin, 4 years ago

I believe I have the necessary changes to make this work. I'll submit in the next few hours using the correct channels.

comment:5 by pdr0, 4 years ago

Here is a workaround using blend on the alpha channel

(using "gray" as the background and your chromkey arguments)

ffmpeg -f lavfi -i color=c=gray:s=640x400 -i green_screen4.png -filter_complex "[1:v]extractplanes=a[origa];[1:v]chromakey=color=0x00ff00:similarity=0.24:blend=0.01,format=gbrap,split[ckout1][ckout2];[ckout1]extractplanes=a[cka];[origa][cka]blend=all_mode=darken,format=gbrap[blend];[ckout2][blend]mergeplanes=0x00010210:gbrap[merge]" -map [merge] merge.png

comment:6 by Gavin, 4 years ago

I have submitted a patch to the devel mailing list for review. Patch is now attached to ticket.

Note: See TracTickets for help on using tickets.