Make text auto-size between a width and height in MoviePy as TextClip

Viewed 1540

I am trying to get the text in my code in MoviePy to automatically adjust to the center of the screen (which it is currently doing), but I don't want to set a fontsize. I am trying to get the text size to fit between a width and height so it autoadjusts its own size, but I can not for the life of me figure out what I am doing wrong.

I can get it to appear at a set font size, but as soon as I try autosizing, the text just does load.

screensize = (1000,500)

credits = (TextClip(txt_credits, color='black',
        font="Keep-Calm-Medium", kerning=-2, interline=-1, size = 
screensize)
      .set_duration(25)
      .set_start(5)
      )
1 Answers

You can use the method='caption' property of the TextClip class:

Method: either ‘label’ (default, the picture will be autosized so as to fit exactly the size) or ‘caption’ (the text will be drawn in a picture with fixed size provided with the size argument). If caption, the text will be wrapped automagically (sometimes it is buggy, not my fault, complain to the ImageMagick crew) and can be aligned or centered (see parameter align).

screensize = (1000,500)

credits = (TextClip(txt_credits, color='black',
        font="Keep-Calm-Medium", kerning=-2, interline=-1, size = 
screensize, method='caption')
      .set_duration(25)
      .set_start(5)
      )
Related