我试图让我在 MoviePy 中的代码中的文本自动调整到屏幕中心(目前正在这样做),但我不想设置字体大小。我试图让文本大小适应宽度和高度,以便它自动调整自己的大小,但我无法终生弄清楚我做错了什么。
我可以让它以设定的字体大小显示,但只要我尝试自动调整大小,文本就会加载。
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)
)
最佳答案
您可以使用 TextClip 类的method='caption' 属性:
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)
)
关于python - 使 MoviePy 中的文本在宽度和高度之间自动调整大小作为 TextClip,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53880756/