Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ffmpeg vertically center align multiple lines of text using drawtext and subtitle both filters independent of font size

I want to vertically center align the text on video no matter what the font size is. And possibly if it could be done using drawtext filter and subtitles filter as well for subtitles filter if anyone can guide how to move the lines few columns up.

I tried multiple [in]drawtext=...,drawtext=...[out] filter but when change the font size alignment goes wrong curious to know if there is some calculated formula to do this accurately.

like image 318
Rehan Avatar asked Jul 11 '19 05:07

Rehan


1 Answers

[in]drawtext=font='Arial': text='This is text line 1':x=(w-tw)/2:y=((h-text_h)/2)-(text_h-(th/4)): fontsize=55: fontcolor=red, drawtext=font='Arial': text='This is text line 2':x=(w-tw)/2:y=((h-text_h)/2)+(text_h-(th/4)): fontsize=55: fontcolor=green[out]

The line height is based on (th/4) increase division number to decrease the line height or vice versa.

like image 179
Rehan Avatar answered Nov 07 '22 19:11

Rehan