I am trying to center a text horizontally and vertically with ffmpeg python but I can't seem to get it right. The mid point shifts depending on the amount of characters in the text.
How do I always center the text to the centre of the screen no matter the length of the text?
Here is my code.
v_width = 1080
v_height = 1633
def create_video():
overlay1 = ffmpeg.input("sukuna.gif").filter("scale", 1080, -1, height = 1633 / 2)
overlay2 = ffmpeg.input("akaza_long.mp4").filter("scale", 1080, -1, height = 1633 / 2 )
(
ffmpeg.input('letsgo.mp4')
.overlay(overlay1)
.overlay(overlay2, x = 0, y = v_height / 2)
.drawtext(textfile = "char_names.txt", fontfile = "/storage/emulated/0/PyFiles/Helvetica-Bold.ttf", fontcolor = "yellow", bordercolor = "black", escape_text = True, start_number = 0, fontsize = "80", x = (v_width / 2) - 40, y = (v_height / 2) - 40, borderw = 4, line_spacing = 3)
.output("newVideo.mp4")
.run()
)
The - 40 is for adding some extra padding to the text.
How do I go about this?
I want the below position always no matter how big or amount of characters in the text. Centred text
Already tried adding a couple of offset to the text but once the text gets longer, it loses its alignment.