[FFmpeg-trac] #10531(avfilter:new): vf_drawtext causing font rendering jitter after libharfbuz commit

FFmpeg trac at avcodec.org
Tue Aug 29 23:10:21 EEST 2023


#10531: vf_drawtext causing font rendering jitter after libharfbuz commit
-------------------------------------+------------------------------------
             Reporter:  Mark Burton  |                    Owner:  (none)
                 Type:  defect       |                   Status:  new
             Priority:  important    |                Component:  avfilter
              Version:  git-master   |               Resolution:
             Keywords:  drawtext     |               Blocked By:
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
-------------------------------------+------------------------------------
Description changed by Mark Burton:

Old description:

> Summary of the bug:
>
> Prior to 1 or more of the below commits to vf_drawtext, it was possible
> to draw running timecode, justified to the centre or right edge and not
> have any horizontal jitter as the numbers ticked up. After the below
> commits, this is no longer the case and the numbers move around
> horizontally as the width of the characters changes, even though a
> monospaced font is being used.
>
> avfilter/vf_drawtext: improve glyph shaping and positioning
> [https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/1eeb59a2099479eeead8cdc0d4586443fb301a8a]
>
> avfilter/vf_drawtext: implement text alignment
> [https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/5f2d907de2ddefd024d161b66d63f8da6208d4d0]
>
> avfilter/vf_drawtext: use flags type of option for text_align
> [https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/ea190b8a2385ae527c2539ab63e668d02ca56b00]
>
> How to reproduce:
> {{{
> % ffmpeg -f lavfi -i "color=black:size=300x100:rate=24" -t 2 -vf
> "drawtext=fontfile=/Library/Fonts/DroidSansMono.ttf: fontcolor=white:
> fontsize=40: x=(w-tw)/2: y=(h-th)/2: rate=24: timecode='01\:14\:13\:19'"
> timecode.mov
> ffmpeg version N-111793-gcb1479faca-https://www.martin-riedl.de Copyright
> (c) 2000-2023 the FFmpeg developers
>   built with Apple clang version 14.0.0 (clang-1400.0.29.102)
>   configuration: --prefix=/Volumes/ffmpeg_arm64/out --pkg-config-
> flags=--static --extra-version='https://www.martin-riedl.de' --enable-
> gray --enable-libxml2 --enable-gpl --enable-libfreetype --enable-
> fontconfig --enable-libharfbuzz --enable-libbluray --enable-libsnappy
> --enable-libvmaf --enable-libass --enable-libklvanc --enable-libzimg
> --enable-libzvbi --enable-libaom --enable-libopenh264 --enable-
> libopenjpeg --enable-librav1e --enable-libsvtav1 --enable-libvpx
> --enable-libwebp --enable-libx264 --enable-libx265 --enable-libmp3lame
> --enable-libopus --enable-libvorbis --enable-libtheora
>   libavutil      58. 17.100 / 58. 17.100
>   libavcodec     60. 23.100 / 60. 23.100
>   libavformat    60. 10.100 / 60. 10.100
>   libavdevice    60.  2.101 / 60.  2.101
>   libavfilter     9. 11.100 /  9. 11.100
>   libswscale      7.  3.100 /  7.  3.100
>   libswresample   4. 11.100 /  4. 11.100
>   libpostproc    57.  2.100 / 57.  2.100
> Input #0, lavfi, from 'color=black:size=300x100:rate=24':
>   Duration: N/A, start: 0.000000, bitrate: N/A
>   Stream #0:0: Video: wrapped_avframe, yuv420p, 300x100 [SAR 1:1 DAR
> 3:1], 24 fps, 24 tbr, 24 tbn
> Stream mapping:
>   Stream #0:0 -> #0:0 (wrapped_avframe (native) -> h264 (libx264))
> Press [q] to stop, [?] for help
> [libx264 @ 0x1326070e0] using SAR=1/1
> [libx264 @ 0x1326070e0] using cpu capabilities: ARMv8 NEON
> [libx264 @ 0x1326070e0] profile High, level 1.2, 4:2:0, 8-bit
> [libx264 @ 0x1326070e0] 264 - core 164 - H.264/MPEG-4 AVC codec -
> Copyleft 2003-2023 - 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=3
> lookahead_threads=1 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=24
> 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, mov, to 'timecode.mov':
>   Metadata:
>     encoder         : Lavf60.10.100
>   Stream #0:0: Video: h264 (avc1 / 0x31637661), yuv420p(progressive),
> 300x100 [SAR 1:1 DAR 3:1], q=2-31, 24 fps, 12288 tbn
>     Metadata:
>       encoder         : Lavc60.23.100 libx264
>     Side data:
>       cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
> [out#0/mov @ 0x600003f583c0] video:11kB audio:0kB subtitle:0kB other
> streams:0kB global headers:0kB muxing overhead: 12.111263%
> frame=   48 fps=0.0 q=-1.0 Lsize=      12kB time=00:00:01.87 bitrate=
> 52.5kbits/s speed=59.3x
> [libx264 @ 0x1326070e0] frame I:1     Avg QP:12.89  size:  1394
> [libx264 @ 0x1326070e0] frame P:14    Avg QP:18.93  size:   239
> [libx264 @ 0x1326070e0] frame B:33    Avg QP:25.90  size:   168
> [libx264 @ 0x1326070e0] consecutive B-frames:  2.1%  0.0% 56.2% 41.7%
> [libx264 @ 0x1326070e0] mb I  I16..4: 68.4%  3.0% 28.6%
> [libx264 @ 0x1326070e0] mb P  I16..4:  1.0%  0.3%  1.5%  P16..4:  0.6%
> 1.5%  1.5%  0.0%  0.0%    skip:93.6%
> [libx264 @ 0x1326070e0] mb B  I16..4:  2.9%  0.3%  0.9%  B16..8: 18.4%
> 2.8%  0.8%  direct: 0.2%  skip:73.6%  L0:31.1% L1:68.4% BI: 0.5%
> [libx264 @ 0x1326070e0] 8x8 transform intra:6.8% inter:30.9%
> [libx264 @ 0x1326070e0] coded y,uvDC,uvAC intra: 17.4% 0.0% 0.0% inter:
> 2.4% 0.0% 0.0%
> [libx264 @ 0x1326070e0] i16 v,h,dc,p: 81% 11%  8%  0%
> [libx264 @ 0x1326070e0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 44% 22% 32%  0%
> 0%  0%  1%  0%  1%
> [libx264 @ 0x1326070e0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 44% 10% 22%  6%
> 3%  2%  3%  7%  2%
> [libx264 @ 0x1326070e0] i8c dc,h,v,p: 100%  0%  0%  0%
> [libx264 @ 0x1326070e0] Weighted P-Frames: Y:0.0% UV:0.0%
> [libx264 @ 0x1326070e0] ref P L0: 66.0%  8.6% 13.1% 12.3%
> [libx264 @ 0x1326070e0] ref B L0: 56.9% 41.0%  2.2%
> [libx264 @ 0x1326070e0] ref B L1: 98.9%  1.1%
> [libx264 @ 0x1326070e0] kb/s:41.16
> }}}
> Patches should be submitted to the ffmpeg-devel mailing list and not this
> bug tracker.

New description:

 Summary of the bug:

 Prior to the below commit to vf_drawtext, it was possible to draw running
 timecode, justified to the centre or right edge and not have any
 horizontal jitter as the numbers ticked up. After the commit, this is no
 longer the case and the numbers move around horizontally as the width of
 the characters changes, even though a monospaced font is being used.

 avfilter/vf_drawtext: improve glyph shaping and positioning
 [https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/1eeb59a2099479eeead8cdc0d4586443fb301a8a]

 How to reproduce:
 {{{
 % ffmpeg -f lavfi -i "color=black:size=300x100:rate=24" -t 2 -vf
 "drawtext=fontfile=/Library/Fonts/DroidSansMono.ttf: fontcolor=white:
 fontsize=40: x=(w-tw)/2: y=(h-th)/2: rate=24: timecode='01\:14\:13\:19'"
 timecode.mov
 ffmpeg version N-111793-gcb1479faca-https://www.martin-riedl.de Copyright
 (c) 2000-2023 the FFmpeg developers
   built with Apple clang version 14.0.0 (clang-1400.0.29.102)
   configuration: --prefix=/Volumes/ffmpeg_arm64/out --pkg-config-
 flags=--static --extra-version='https://www.martin-riedl.de' --enable-gray
 --enable-libxml2 --enable-gpl --enable-libfreetype --enable-fontconfig
 --enable-libharfbuzz --enable-libbluray --enable-libsnappy --enable-
 libvmaf --enable-libass --enable-libklvanc --enable-libzimg --enable-
 libzvbi --enable-libaom --enable-libopenh264 --enable-libopenjpeg
 --enable-librav1e --enable-libsvtav1 --enable-libvpx --enable-libwebp
 --enable-libx264 --enable-libx265 --enable-libmp3lame --enable-libopus
 --enable-libvorbis --enable-libtheora
   libavutil      58. 17.100 / 58. 17.100
   libavcodec     60. 23.100 / 60. 23.100
   libavformat    60. 10.100 / 60. 10.100
   libavdevice    60.  2.101 / 60.  2.101
   libavfilter     9. 11.100 /  9. 11.100
   libswscale      7.  3.100 /  7.  3.100
   libswresample   4. 11.100 /  4. 11.100
   libpostproc    57.  2.100 / 57.  2.100
 Input #0, lavfi, from 'color=black:size=300x100:rate=24':
   Duration: N/A, start: 0.000000, bitrate: N/A
   Stream #0:0: Video: wrapped_avframe, yuv420p, 300x100 [SAR 1:1 DAR 3:1],
 24 fps, 24 tbr, 24 tbn
 Stream mapping:
   Stream #0:0 -> #0:0 (wrapped_avframe (native) -> h264 (libx264))
 Press [q] to stop, [?] for help
 [libx264 @ 0x1326070e0] using SAR=1/1
 [libx264 @ 0x1326070e0] using cpu capabilities: ARMv8 NEON
 [libx264 @ 0x1326070e0] profile High, level 1.2, 4:2:0, 8-bit
 [libx264 @ 0x1326070e0] 264 - core 164 - H.264/MPEG-4 AVC codec - Copyleft
 2003-2023 - 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=3
 lookahead_threads=1 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=24
 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, mov, to 'timecode.mov':
   Metadata:
     encoder         : Lavf60.10.100
   Stream #0:0: Video: h264 (avc1 / 0x31637661), yuv420p(progressive),
 300x100 [SAR 1:1 DAR 3:1], q=2-31, 24 fps, 12288 tbn
     Metadata:
       encoder         : Lavc60.23.100 libx264
     Side data:
       cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
 [out#0/mov @ 0x600003f583c0] video:11kB audio:0kB subtitle:0kB other
 streams:0kB global headers:0kB muxing overhead: 12.111263%
 frame=   48 fps=0.0 q=-1.0 Lsize=      12kB time=00:00:01.87 bitrate=
 52.5kbits/s speed=59.3x
 [libx264 @ 0x1326070e0] frame I:1     Avg QP:12.89  size:  1394
 [libx264 @ 0x1326070e0] frame P:14    Avg QP:18.93  size:   239
 [libx264 @ 0x1326070e0] frame B:33    Avg QP:25.90  size:   168
 [libx264 @ 0x1326070e0] consecutive B-frames:  2.1%  0.0% 56.2% 41.7%
 [libx264 @ 0x1326070e0] mb I  I16..4: 68.4%  3.0% 28.6%
 [libx264 @ 0x1326070e0] mb P  I16..4:  1.0%  0.3%  1.5%  P16..4:  0.6%
 1.5%  1.5%  0.0%  0.0%    skip:93.6%
 [libx264 @ 0x1326070e0] mb B  I16..4:  2.9%  0.3%  0.9%  B16..8: 18.4%
 2.8%  0.8%  direct: 0.2%  skip:73.6%  L0:31.1% L1:68.4% BI: 0.5%
 [libx264 @ 0x1326070e0] 8x8 transform intra:6.8% inter:30.9%
 [libx264 @ 0x1326070e0] coded y,uvDC,uvAC intra: 17.4% 0.0% 0.0% inter:
 2.4% 0.0% 0.0%
 [libx264 @ 0x1326070e0] i16 v,h,dc,p: 81% 11%  8%  0%
 [libx264 @ 0x1326070e0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 44% 22% 32%  0%  0%
 0%  1%  0%  1%
 [libx264 @ 0x1326070e0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 44% 10% 22%  6%  3%
 2%  3%  7%  2%
 [libx264 @ 0x1326070e0] i8c dc,h,v,p: 100%  0%  0%  0%
 [libx264 @ 0x1326070e0] Weighted P-Frames: Y:0.0% UV:0.0%
 [libx264 @ 0x1326070e0] ref P L0: 66.0%  8.6% 13.1% 12.3%
 [libx264 @ 0x1326070e0] ref B L0: 56.9% 41.0%  2.2%
 [libx264 @ 0x1326070e0] ref B L1: 98.9%  1.1%
 [libx264 @ 0x1326070e0] kb/s:41.16
 }}}
 Patches should be submitted to the ffmpeg-devel mailing list and not this
 bug tracker.

--
-- 
Ticket URL: <https://trac.ffmpeg.org/ticket/10531#comment:2>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list