[Solved] Cannot render non-ASCII characters with ffmpeg’s drawtext

Ken Sharp Asks: Cannot render non-ASCII characters with ffmpeg’s drawtext
Using the drawtext filter in ffmpeg I am unable to use anything but ASCII characters.

This command creates a five second test video, as expected (nothing pretty):

ffmpeg -f lavfi -i testsrc -to 5 -vf "drawtext=text='AT 05 ーポン 攢ð':fontcolor=white" test.mpg

But the output fails to render any non-ASCII characters:


Note from left to right:

AT – Double spaced characters

05 – Simple numbers

ーポン – CJK characters

æ”¢ð – AltGr + a,b,c,d in my locale (en_GB.UTF-8)

At first I assumed the font was at fault, but I’ve checked numerous fonts and they have the relevant glyphs. Indeed my entire system has no problems with these characters at all. I then assumed it must be ffmpeg but I tried the following:

convert -background black -size 800x480 -fill "#ff0080" -family "Ubuntu Mono" -pointsize 72 -gravity center label:'AT 05 ーポン 攢ð' output.png

The result being:


So I’m back to assuming there is something wrong with my environment. I’ve tried on Ubuntu Trusty and Ubuntu Xenial but the results are the same.

$ locale

$ ffmpeg
ffmpeg version 3.2.4-static http://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 5.4.1 (Debian 5.4.1-5) 20170205
  configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-5 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gray --enable-libass --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzimg
  libavutil      55. 34.101 / 55. 34.101
  libavcodec     57. 64.101 / 57. 64.101
  libavformat    57. 56.101 / 57. 56.101
  libavdevice    57.  1.100 / 57.  1.100
  libavfilter     6. 65.100 /  6. 65.100
  libswscale      4.  2.100 /  4.  2.100
  libswresample   2.  3.100 /  2.  3.100
  libpostproc    54.  1.100 / 54.  1.100

$ convert -version
Version: ImageMagick 6.7.7-10 2017-05-26 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP

I don’t know where else to look given that my locale appears to be correct, and any font I use correctly renders the font, but when passed to either ffmpeg or convert the text shown is useless.

I’ve done the usual hours and hours of Googling to no avail. I’m amazed nobody else has seen this problem before me.

Can anyone shed any light?

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.