[FFmpeg-user] Weird results with drawtext

Michael Koch astroelectronic at t-online.de
Sun Sep 19 14:04:31 EEST 2021


Am 19.09.2021 um 12:42 schrieb Cecil Westerhof via ffmpeg-user:
> Michael Koch <astroelectronic at t-online.de> writes:
>
>>> As Michael Koch said:
>>>       The content of the variable "text_h" depends on which characters
>>>       you are printing.
>>>
>>> So I changed:
>>>       drawtext=
>>>          enable     = 'between(t, 105, 115)':
>>>          text       = 'speaker':
>>>          y          = main_h - (text_h * 4),
>>>       drawtext=
>>>          enable     = 'between(t, 105, 115)':
>>>          text       = 'subject':
>>>          y          = main_h - (text_h * 2.2),
>>>
>>> to:
>>>       drawtext=
>>>          enable     = 'between(t, 105, 115)':
>>>          text       = 'speaker':
>>>          y          = main_h - 200,
>>>       drawtext=
>>>          enable     = 'between(t, 105, 115)':
>>>          text       = 'subject':
>>>          y          = main_h - 140,
>>>
>>> That gives satisfactory results. The only problem is when the font
>>> size changes. Then I have to remember I need to change these two
>>> values also. But I do not expect that to happen often, so I can live
>>> with that.
>> In your case with the words "speaker" and "subject" it works, but
>> generally it fails.
>> For example if you remove the character "k" from "speaker", then the
>> vertical alignment will be wrong.
> Speaker and subject where only templates, in reality there is a
> speaker and a subject.
> I made a video with eight sets of speakers and subjects and all look
> good (enough). So I think (hope) that it works.
> But who knows, maybe I need to go back to the drawing-board next time.
> (But I certainly hope not.)

I found a simple solution. Replace
y=100-text_h
by
y=100-ascent

This seems to work for all characters.

Michael


More information about the ffmpeg-user mailing list