Opened 13 years ago

Closed 13 years ago

#763 closed defect (fixed)

Using -boxcolor=black@0.5 in drawtext filter results in green (regression)

Reported by: dave rice Owned by:
Priority: important Component: avfilter
Version: git-master Keywords: drawtext regression
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: yes

Description

I think I found a regression in the drawtext filter. If I specify boxcolor=black@0.5 in the command, I used to get a black box with 50% alpha as expected. In an ffmpeg built from git yesterday I am now getting a green box with 50% alpha. Note that if I run ffmpeg without the alpha specifier and just say boxcolor=black then I do get a black box, but the alpha value now gives unexpected results.
I have another (related?) drawtext bug here: http://ffmpeg.org/trac/ffmpeg/ticket/737.
Dave

drawtext with ffmpeg built from git yesterday (ask for black and get green)

ffmpeg -report -y -i example.mp4 -vf "drawtext=fontcolor=white:fontsize=16:fontfile=/Library/Fonts/Courier New.ttf:box=1:boxcolor=black@0.5:x=100:y=100:text='Is this black?'" out2.mp4
ffmpeg started on 2011-12-15 at 10:07:41
Report written to "ffmpeg-20111215-100741.log"
ffmpeg version N-32298-g7862bd3, Copyright (c) 2000-2011 the FFmpeg developers
  built on Dec 14 2011 09:38:30 with gcc 4.2.1 (Apple Inc. build 5666) (dot 3)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/HEAD --enable-shared --enable-gpl --enable-version3 --enable-libfreetype --enable-nonfree --enable-hardcoded-tables --cc=/usr/bin/gcc-4.2 --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libxvid
  libavutil    51. 32. 0 / 51. 32. 0
  libavcodec   53. 44. 0 / 53. 44. 0
  libavformat  53. 25. 0 / 53. 25. 0
  libavdevice  53.  4. 0 / 53.  4. 0
  libavfilter   2. 53. 0 /  2. 53. 0
  libswscale    2.  1. 0 /  2.  1. 0
  libpostproc  51.  2. 0 / 51.  2. 0
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'example.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    creation_time   : 2011-11-18 06:00:00
    encoder         : Lavf53.22.0
  Duration: 00:00:05.93, start: 0.000000, bitrate: 58180 kb/s
    Stream #0:0(eng): Video: h264 (High 4:4:4 Predictive) (avc1 / 0x31637661), yuv420p, 720x486 [SAR 9:10 DAR 4:3], 58178 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc
    Metadata:
      creation_time   : 2011-11-18 06:00:00
      handler_name    : 
[buffer @ 0x7fc0714199c0] w:720 h:486 pixfmt:yuv420p tb:1/1000000 sar:9/10 sws_param:
[libx264 @ 0x7fc07184fa00] using SAR=9/10
[libx264 @ 0x7fc07184fa00] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2 AVX
[libx264 @ 0x7fc07184fa00] profile High, level 3.1
[libx264 @ 0x7fc07184fa00] 264 - core 119 - H.264/MPEG-4 AVC codec - Copyleft 2003-2011 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'out2.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    creation_time   : 2011-11-18 06:00:00
    encoder         : Lavf53.25.0
    Stream #0:0(eng): Video: h264 (![0][0][0] / 0x0021), yuv420p, 720x486 [SAR 9:10 DAR 4:3], q=-1--1, 30k tbn, 29.97 tbc
    Metadata:
      creation_time   : 2011-11-18 06:00:00
      handler_name    : 
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> libx264)
Press [q] to stop, [?] for help
frame=  178 fps= 29 q=-1.0 Lsize=    1333kB time=00:00:05.87 bitrate=1859.6kbits/s    
video:1330kB audio:0kB global headers:0kB muxing overhead 0.207823%
[libx264 @ 0x7fc07184fa00] frame I:3     Avg QP:24.39  size: 30080
[libx264 @ 0x7fc07184fa00] frame P:95    Avg QP:26.50  size: 10918
[libx264 @ 0x7fc07184fa00] frame B:80    Avg QP:29.37  size:  2926
[libx264 @ 0x7fc07184fa00] consecutive B-frames: 10.1% 89.9%  0.0%  0.0%
[libx264 @ 0x7fc07184fa00] mb I  I16..4: 16.8% 73.8%  9.4%
[libx264 @ 0x7fc07184fa00] mb P  I16..4:  1.5%  6.5%  0.8%  P16..4: 48.4% 18.2% 13.3%  0.0%  0.0%    skip:11.3%
[libx264 @ 0x7fc07184fa00] mb B  I16..4:  0.0%  0.7%  0.0%  B16..8: 47.5%  3.7%  1.0%  direct: 3.3%  skip:43.8%  L0:45.1% L1:49.8% BI: 5.0%
[libx264 @ 0x7fc07184fa00] 8x8 transform intra:74.6% inter:71.3%
[libx264 @ 0x7fc07184fa00] coded y,uvDC,uvAC intra: 73.8% 72.8% 45.8% inter: 30.6% 24.2% 1.4%
[libx264 @ 0x7fc07184fa00] i16 v,h,dc,p: 22% 68%  4%  5%
[libx264 @ 0x7fc07184fa00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 10% 12% 36%  7%  6%  6%  8%  7%  9%
[libx264 @ 0x7fc07184fa00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu:  7% 59%  9%  4%  4%  3%  5%  3%  5%
[libx264 @ 0x7fc07184fa00] i8c dc,h,v,p: 58% 23% 14%  5%
[libx264 @ 0x7fc07184fa00] Weighted P-Frames: Y:61.1% UV:27.4%
[libx264 @ 0x7fc07184fa00] ref P L0: 47.2% 18.3% 17.2% 11.4%  6.0%
[libx264 @ 0x7fc07184fa00] ref B L0: 83.1% 16.9%
[libx264 @ 0x7fc07184fa00] kb/s:1833.92

ffmpeg built from git on July 12, 2011 accurately produces a black box with 50% alpha on the same input file and drawtext specs.

/Users/drice/Desktop/usb/scripts_deriv/Resources/ffmpeg  -y -i example.mp4 -vf "drawtext=fontcolor=white:fontsize=16:fontfile=/Library/Fonts/Courier New.ttf:box=1:boxcolor=black@0.5:x=100:y=100:text='Is this black?'" out2.mp4
ffmpeg version N-31437-gbb258fb, Copyright (c) 2000-2011 the FFmpeg developers
  built on Jul 12 2011 21:43:46 with gcc 4.2.1 (Apple Inc. build 5666) (dot 3)
  configuration: --prefix=/Users/davidrice/ffmpeg-head/runtime --enable-static --disable-shared --enable-postproc --enable-nonfree --enable-libx264 --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libtheora --enable-libxvid --enable-libvorbis --enable-libgsm --enable-libvpx --enable-avfilter --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-version3 --enable-libfreetype --disable-ffplay --disable-ffserver --disable-ffprobe --disable-network --disable-devices --disable-doc --extra-cflags=--static --extra-ldflags= --bindir=/Users/davidrice/ffmpeg-head/dist/bin --incdir=/Users/davidrice/ffmpeg-head/dist/include --libdir=/Users/davidrice/ffmpeg-head/dist/lib --prefix=/usr/local
  libavutil    51. 11. 0 / 51. 11. 0
  libavcodec   53.  7. 0 / 53.  7. 0
  libavformat  53.  5. 0 / 53.  5. 0
  libavdevice  53.  2. 0 / 53.  2. 0
  libavfilter   2. 24. 4 /  2. 24. 4
  libswscale    2.  0. 0 /  2.  0. 0
  libpostproc  51.  2. 0 / 51.  2. 0
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'example.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    creation_time   : 2011-11-18 06:00:00
    encoder         : Lavf53.22.0
  Duration: 00:00:05.93, start: 0.000000, bitrate: 58180 kb/s
    Stream #0.0(eng): Video: h264 (High 4:4:4 Predictive), yuv420p, 720x486 [PAR 9:10 DAR 4:3], 58178 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc
    Metadata:
      creation_time   : 2011-11-18 06:00:00
[buffer @ 0x101514d20] w:720 h:486 pixfmt:yuv420p tb:1/1000000 sar:9/10 sws_param:
Output #0, mp4, to 'out2.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    creation_time   : 2011-11-18 06:00:00
    encoder         : Lavf53.5.0
    Stream #0.0(eng): Video: mpeg4, yuv420p, 720x486 [PAR 9:10 DAR 4:3], q=2-31, 200 kb/s, 30k tbn, 29.97 tbc
    Metadata:
      creation_time   : 2011-11-18 06:00:00
Stream mapping:
  Stream #0.0 -> #0.0
Press [q] to stop, [?] for help
frame=  178 fps= 32 q=31.0 Lsize=     481kB time=00:00:05.93 bitrate= 663.0kbits/s    
video:478kB audio:0kB global headers:0kB muxing overhead 0.462671%

Change History (2)

comment:1 by Carl Eugen Hoyos, 13 years ago

Keywords: regression added
Reproduced by developer: set
Status: newopen

in reply to:  description comment:2 by Stefano Sabatini, 13 years ago

Analyzed by developer: set
Resolution: fixed
Status: openclosed

Replying to dericed:

I think I found a regression in the drawtext filter. If I specify boxcolor=black@0.5 in the command, I used to get a black box with 50% alpha as expected. In an ffmpeg built from git yesterday I am now getting a green box with 50% alpha. Note that if I run ffmpeg without the alpha specifier and just say boxcolor=black then I do get a black box, but the alpha value now gives unexpected results.
I have another (related?) drawtext bug here: http://ffmpeg.org/trac/ffmpeg/ticket/737.
Dave


drawtext with ffmpeg built from git yesterday (ask for black and get green)

 ffmpeg -report -y -i example.mp4 -vf "drawtext=fontcolor=white:fontsize=16:fontfile=/Library/Fonts/Courier New.ttf:box=1:boxcolor=black@0.5:x=100:y=100:text='Is this black?'" out2.mp4
 ffmpeg started on 2011-12-15 at 10:07:41
 Report written to "ffmpeg-20111215-100741.log"
 ffmpeg version N-32298-g7862bd3, Copyright (c) 2000-2011 the FFmpeg developers
   built on Dec 14 2011 09:38:30 with gcc 4.2.1 (Apple Inc. build 5666) (dot 3)
   configuration: --prefix=/usr/local/Cellar/ffmpeg/HEAD --enable-shared --enable-gpl --enable-version3 --enable-libfreetype --enable-nonfree --enable-hardcoded-tables --cc=/usr/bin/gcc-4.2 --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libxvid
   libavutil    51. 32. 0 / 51. 32. 0
   libavcodec   53. 44. 0 / 53. 44. 0
   libavformat  53. 25. 0 / 53. 25. 0
   libavdevice  53.  4. 0 / 53.  4. 0
   libavfilter   2. 53. 0 /  2. 53. 0
   libswscale    2.  1. 0 /  2.  1. 0
   libpostproc  51.  2. 0 / 51.  2. 0
 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'example.mp4':
   Metadata:
     major_brand     : isom
     minor_version   : 512
     compatible_brands: isomiso2avc1mp41
     creation_time   : 2011-11-18 06:00:00
     encoder         : Lavf53.22.0
   Duration: 00:00:05.93, start: 0.000000, bitrate: 58180 kb/s
     Stream #0:0(eng): Video: h264 (High 4:4:4 Predictive) (avc1 / 0x31637661), yuv420p, 720x486 [SAR 9:10 DAR 4:3], 58178 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc
[...]

It was not a regression, but a bug which survived since the first version (only affecting YUV video), should be fixed in commit:

commit 1858a5c25ee1ccb8089339d20138116a46cc6c77
Author: Stefano Sabatini <stefasab@gmail.com>
Date:   Sat Dec 24 16:17:18 2011 +0100

    vf_drawtext: select YUV color for drawbox() in case YUV colorspace is used
    
    Fix box alpha rendering when a YUV colorspace is selected, in particular
    fix trac ticket #763.

Thanks for reporting.

Note: See TracTickets for help on using tickets.