[FFmpeg-user] Weird results with drawtext

Cecil Westerhof Cecil at decebal.nl
Sun Sep 19 15:11:29 EEST 2021


Michael Koch <astroelectronic at t-online.de> writes:

> 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.

Aah, I was wondering if there was a solution like that. Thanks I will
try it out.

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof


More information about the ffmpeg-user mailing list