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?

migrated from video.stackexchange.com Jun 28 '17 at 23:55

This question came from our site for engineers, producers, editors, and enthusiasts spanning the fields of video, and media creation.


The characters that work are either ASCII (codes 32-126) or ISO-8859-1 (codes 160-255) which are all single-byte codes. The ones that aren't working for you are UTF-8, with an initial byte which an ASCII (or Latin-1) application might treat as printable. But the additional bytes fall into the range of C1 controls (128-159) and would be discarded by that type of application. Then when it tries to echo those initial bytes, a terminal expecting UTF-8 might discard those (incomplete) sequences, giving the empty boxes that are shown in the first picture.

  • So it should be possible to get the characters through somehow? I don't know how yet but I still see that very slight glimmer of hope in the distance. I played with iconv a bit but gave up. I should take another look. – Ken Sharp Jun 29 '17 at 19:33

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.