[FFmpeg-user] Weird results with drawtext

Michael Koch astroelectronic at t-online.de
Sun Sep 19 10:20:29 EEST 2021


Am 19.09.2021 um 01:08 schrieb Cecil Westerhof via ffmpeg-user:
> Cecil Westerhof via ffmpeg-user <ffmpeg-user at ffmpeg.org> writes:
>
>> I have several of the following (simplified):
>>      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),
>>
>> I have been carefully tweaking to get them on the correct place.
>> But when I was satisfied and generated all eight places where I wanted
>> to have them the placement of the speaker and subject text is on
>> different heights. Sometimes one or the other is different, sometimes
>> both and sometimes they are the same.
>>
>> Is this a bug, or am I doing something wrong?
> 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.

Michael


More information about the ffmpeg-user mailing list