1

I'm trying to use ffmpeg drawtext filter to render Tibetan text to videos. But some characters aren't rendered correctly.

for example:

སྤྱི་སྟེགས

Expected render output

some characters which is.. vertically too long, are not rendered correctly:

Actual render output

and this is my command line for generating the output:

ffmpeg -i input.mp4 -filter_complex "drawtext=fontsize=80:fontcolor=black:fontfile=himalaya.ttf:shadowx=1:shadowy=1:text='སྤྱི་སྟེགས':x=0:y=0" -c:v libx264 -b:v 400k -c:a copy output.mp4

The font himalaya.ttf (Microsoft Himalaya) is the default built-in font for Tibetan on Windows 10. (See https://learn.microsoft.com/en-us/typography/font-list/microsoft-himalaya )

I tried text_shaping=1 and text_shaping=0, neither one is working.

I've also tried other Tibetan fonts, problem is the same.

But all of those fonts are rendered correctly in other places such as web browser.

1 Answers1

0

It's unlikely freetype fault. My bet would be on incomplete shaping support in ffmpeg itself, I see it's using fribidi functions which probably work for Arabic, but not for everything else. You'll probably need to switch to harfbuzz+fribidi or to pango.

bunglehead
  • 1,104
  • 1
  • 14
  • 22
  • Thank you, I tired using harfbuzz as shaping engine, to render Tibetan in an ass subtitle, it works correctly. now the problem is ffmpeg drawtext filter does not support to specify a shaping engine, maybe I should try to complie ffmpeg without fribidi, but will that cause new problems?.. – A-Circle Zhang Jun 19 '20 at 17:59
  • Assuming that's possible to build without it, you will lose Arabic support I imagine. Correct way is to use more capable shaping engine, or in case of subtitles, probably whole layout library, like pango. – bunglehead Jun 19 '20 at 18:17