[FFmpeg-user] Weird results with drawtext

Michael Koch astroelectronic at t-online.de
Sat Sep 18 19:51:03 EEST 2021


Am 18.09.2021 um 18:22 schrieb Michael Koch:
> Am 18.09.2021 um 18:07 schrieb Cecil Westerhof via ffmpeg-user:
>> 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?
>>
>
> The content of the variable "text_h" depends on which characters you 
> are printing.
>
> If you don't use "text_h", then the characters "a" and "q" are printed 
> at the same height:
> ffmpeg -f lavfi -i color=yellow -lavfi 
> drawtext=text='a':x=20:y=50,drawtext=text='q':x=40:y=50 -frames 1 -y 
> out1.png
>
> But if you use "text_h", then they are printed at different heights:
> ffmpeg -f lavfi -i color=yellow -lavfi 
> drawtext=text='a':x=20:y=50-text_h,drawtext=text='q':x=40:y=50-text_h 
> -frames 1 -y out2.png

It gets even worse when you try to print apostrophes. It's impossible to 
print all characters at the same height.

It doesn't wok without text_h:

ffmpeg -f lavfi -i color=yellow -lavfi 
drawtext=text='a_':x=20:y=50,drawtext=text='_gG':x=40:y=50,drawtext=text='``':x=60:y=50 
-frames 1 -y out1.png

And it also doesn't work with text_h subtracted:

ffmpeg -f lavfi -i color=yellow -lavfi 
drawtext=text='a_':x=20:y=50-text_h,drawtext=text='_gG':x=40:y=50-text_h,drawtext=text='``':x=60:y=50-text_h 
-frames 1 -y out2.png

Michael



More information about the ffmpeg-user mailing list