Opened 7 years ago

Closed 7 years ago

#6911 closed defect (fixed)

Drawbox & drawgrid replace source pixels if input or box color has alpha

Reported by: Gyan Owned by:
Priority: normal Component: avfilter
Version: git-master Keywords: drawbox
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

If the video input has an alpha component or the user specifies transparency in the box/grid-color, the drawbox and drawgrid filters replace the source pixels when painting the box or grid. This is almost always undesired. The alpha component of the user color is meant for blending the box/grid on top of the input. The input alpha should be left intact. Essentially, the filters draw a "hole" if alpha is involved. See attached result-drawbox-src-with-no-alpha-existing.jpg

Inputs and outputs for

ffmpeg -i view.jpg -i window.png -lavfi "[1]drawbox=200:0:400:56:c=black@0.5:t=fill[win];[0][win]overlay" result-drawbox-src-with-alpha-existing.jpg

are attached, along with expected result.

Attachments (7)

result-drawbox-src-with-alpha-existing.jpg (53.8 KB ) - added by Gyan 7 years ago.
result-drawbox-src-with-alpha-expected.jpg (53.6 KB ) - added by Gyan 7 years ago.
result-drawbox-src-with-no-alpha-existing.jpg (30.6 KB ) - added by Gyan 7 years ago.
view.jpg (78.8 KB ) - added by Gyan 7 years ago.
window.png (305.9 KB ) - added by Gyan 7 years ago.
result-drawbox-src-with-alpha-patched-replace-no-21.jpg (54.3 KB ) - added by Gyan 7 years ago.
result-drawbox-src-with-alpha-patched-replace-yes-21.jpg (54.9 KB ) - added by Gyan 7 years ago.

Download all attachments as: .zip

Change History (9)

by Gyan, 7 years ago

Attachment: view.jpg added

by Gyan, 7 years ago

Attachment: window.png added

comment:1 by Gyan, 7 years ago

Patch at https://patchwork.ffmpeg.org/patch/6701/ introduces a new boolean option 'replace'. If set to 1, yes or true, current behaviour is retained. With the default of 0, no or false, the behaviour is as shown in the 'expected' image.

comment:2 by llogan, 7 years ago

Keywords: drawbox added
Resolution: fixed
Status: newclosed

Fixed by your patch in 1c76134fe37ac20695627e3f5ce1f2bbf1245fcc. Thanks.

Note: See TracTickets for help on using tickets.