[FFmpeg-user] drawtext, suggestion for improvement

Michael Koch astroelectronic at t-online.de
Thu Mar 26 21:28:02 EET 2020


Am 26.03.2020 um 19:59 schrieb Carl Eugen Hoyos:
> Am Do., 26. März 2020 um 19:34 Uhr schrieb Michael Koch
> <astroelectronic at t-online.de>:
>
>> I have a suggestion for improvement for the drawtext filter.
>> If the text is read from a file, it must be in UTF-8 format. In Windows,
>> many text editors (including Notepad) insert a 3-byte "Byte order mark"
>> at the beginning of the file. This is described here:
>> https://en.wikipedia.org/wiki/UTF-8#Byte_order_mark
>>
>> The problem is that drawtext prints these 3 bytes as non-printable
>> characters (empty rectangle). You can see an example screenshot here in
>> the Zeranoe discussion forum:
>> https://ffmpeg.zeranoe.com/forum/viewtopic.php?f=7&t=7813
>>
>> My suggestion is to let the drawtext filter check the first three bytes
>> and if they are EF BB BF, then don't print them.
> This bug report is - sadly - missing the (simplified) command line
> you tested together with its complete, uncut console output and
> - equally important - a simple input file that allows to reproduce.

How to reproduce:
Use Windows Notepad to create a UTF-8 text file which contains only the 
word "test".
This is how the file looks in a hex editor:
EF BB BF 74 65 73 74

Now run this command line and have a look at the output image.

C:\Users\mKoch\Desktop>c:\ffmpeg\ffmpeg -f lavfi -i color=c=white -vf 
drawtext=t
extfile=test.txt -frames 1 -y out.png
ffmpeg version git-2020-03-23-ba698a2 Copyright (c) 2000-2020 the FFmpeg 
develop
ers
   built with gcc 9.2.1 (GCC) 20200122
   configuration: --enable-gpl --enable-version3 --enable-sdl2 
--enable-fontconfi
g --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d 
--enable-libb
luray --enable-libfreetype --enable-libmp3lame 
--enable-libopencore-amrnb --enab
le-libopencore-amrwb --enable-libopenjpeg --enable-libopus 
--enable-libshine --e
nable-libsnappy --enable-libsoxr --enable-libsrt --enable-libtheora 
--enable-lib
twolame --enable-libvpx --enable-libwavpack --enable-libwebp 
--enable-libx264 --
enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma 
--enable-zlib --e
nable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc 
--enabl
e-libmysofa --enable-libspeex --enable-libxvid --enable-libaom 
--enable-libmfx -
-enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va 
--enable-nv
enc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt 
--enable
-amf
   libavutil      56. 42.101 / 56. 42.101
   libavcodec     58. 76.100 / 58. 76.100
   libavformat    58. 42.100 / 58. 42.100
   libavdevice    58.  9.103 / 58.  9.103
   libavfilter     7. 77.100 /  7. 77.100
   libswscale      5.  6.101 /  5.  6.101
   libswresample   3.  6.100 /  3.  6.100
   libpostproc    55.  6.100 / 55.  6.100
Input #0, lavfi, from 'color=c=white':
   Duration: N/A, start: 0.000000, bitrate: N/A
     Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 320x240 
[SAR 1:1
DAR 4:3], 25 tbr, 25 tbn, 25 tbc
Stream mapping:
   Stream #0:0 -> #0:0 (rawvideo (native) -> png (native))
Press [q] to stop, [?] for help
Fontconfig error: Cannot load default config file
[Parsed_drawtext_0 @ 00000000005b2440] Using 
"C:/Windows/fonts/KievitOffcPro.ttf
"
Output #0, image2, to 'out.png':
   Metadata:
     encoder         : Lavf58.42.100
     Stream #0:0: Video: png, rgb24, 320x240 [SAR 1:1 DAR 4:3], q=2-31, 
200 kb/s,
  25 fps, 25 tbn, 25 tbc
     Metadata:
       encoder         : Lavc58.76.100 png
frame=    1 fps=0.0 q=-0.0 Lsize=N/A time=00:00:00.04 bitrate=N/A 
speed=   2x

video:1kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB 
muxing ove
rhead: unknown



More information about the ffmpeg-user mailing list