我正试图添加一个白色的背景,我的文字与moviepy和我想添加一个黑色的中风线,这个背景。
目前我有
for step in data["steps"]:
image_file = f"image{str(idx)}.png" # Replace with your actual image file names
text1 = TextClip(wrap_text(step["text1"]), fontsize=48, color='black', font='Stanberry.ttf')
text2 = TextClip(wrap_text(step["text2"]), fontsize=48, color='black', font='Stanberry.ttf')
imageDuration = 5
videoDuration += imageDuration
image = ImageClip(image_file).set_duration(imageDuration).resize(height=1920).resize(width=1080).margin(5, color=(0, 0, 0))
text1_bg = ColorClip(size=(text1.size[0] + 20, text1.size[1] + 20), color=(255, 255, 255)).set_duration(imageDuration)
text2_bg = ColorClip(size=(text2.size[0] + 20, text2.size[1] + 20), color=(255, 255, 255)).set_duration(imageDuration)
text1_pos = ('center', 50)
text2_pos = ('center', image.size[1] - text2.size[1] - 50)
text1 = text1.set_position(text1_pos).set_duration(imageDuration)
text2 = text2.set_position(text2_pos).set_duration(imageDuration)
text1_bg = text1_bg.set_position((image.w // 2 - text1.w // 2 - 10, text1_pos[1] - 10))
text2_bg = text2_bg.set_position((image.w // 2 - text2.w // 2 - 10, text2_pos[1] - 10))
composite = CompositeVideoClip([image, text1_bg, text1.set_start(0), text2_bg, text2.set_start(0)], size=(1080, 1920))
images.append(composite)
idx += 1
字符串
1条答案
按热度按时间o4hqfura1#
如果您在TextClip函数中将参数“bg_color”设置为可接受的颜色,则应该会显示该参数。
movepy TextClip文档:https://moviepy-tburrows13.readthedocs.io/en/improve-docs/ref/VideoClip/TextClip.html