[FFmpeg-trac] #3302(avfilter:open): Cannot draw opaque text on transparent frame
FFmpeg
trac at avcodec.org
Fri Jun 20 19:08:16 CEST 2014
#3302: Cannot draw opaque text on transparent frame
------------------------------------+------------------------------------
Reporter: Krieger | Owner:
Type: defect | Status: open
Priority: normal | Component: avfilter
Version: git-master | Resolution:
Keywords: drawtext | Blocked By:
Blocking: | Reproduced by developer: 1
Analyzed by developer: 0 |
------------------------------------+------------------------------------
Comment (by Krieger):
This issue is still actual. Drawing a text over transparent background
doesn't work, although should.
This bug may be related to http://trac.ffmpeg.org/ticket/3317
Seems the problem is that ff_blend_mask() from drawutils.c treats alpha,
the 4th component on the 1st plane of dst, just like all other components
(R, G, B). And, for example, in case of
{{{ffmpeg -f lavfi -i
"color=color=white at 0.0:size=2x2,format=pix_fmts=rgba,drawtext=text=TEST:fontsize=50:fontfile=/usr/share/fonts/corefonts/verdana.ttf:fontcolor=red at 1.0,format=pix_fmts=rgba"
-vframes 1 -vcodec png /tmp/tmp.png}}}
in the end of this routine i have such contents:
{{{
Breakpoint 3, ff_blend_mask (draw=0x19e91d0, color=0x19e9200,
dst=0x19f6580, dst_linesize=0x19f65c0, dst_w=2, dst_h=2, mask=0x19f6c90
'\377' <repeats 124 times>, mask_linesize=31,
mask_w=2, mask_h=1, l2depth=3, endianness=0, x0=0, y0=1) at
libavfilter/drawutils.c:504
504 }
(gdb) x/8xb dst[0]
0x19f6840: 0xff 0xff 0xff 0x00 0xff 0xff 0xff
0x00
(gdb) x/8xb (dst[0] + dst_linesize[0])
0x19f6860: 0xff 0x00 0x00 0x00 0xff 0x00 0x00
0x00
(gdb)
}}}
It shows that topmost line is 2 white pixels (background color), and the
bottom line is 2 red pixels (color of text). However, red-colored pixels
have alpha = 0 and the whole picture is represented as fully transparent.
It is possible to parametrize the algorithm for resulting alpha. So that
old behaviour can be preserved, but also we get a new mode to preserve
alpha value of mask (i.e. ignore background alpha), which can be desired
in some cases; more strategies can be added.
--
Ticket URL: <https://trac.ffmpeg.org/ticket/3302#comment:2>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list