[英]Moviepy swap text mid video
我想在视频中写入文本并让它在播放中更改,这是我尝试过的,但它会将每个文本叠加在彼此上并且只显示文本 5 秒?
def generateVideo(initial_text, secondary_text, tertiary_text):
text_clip = TextClip(txt=initial_text, color='AntiqueWhite1', font='Arial-Bold', fontsize=100)
text_clip = text_clip.set_position('center').set_duration(5)
text_clip_secondary = TextClip(txt=secondary_text, color='AntiqueWhite1', font='Arial-Bold', fontsize=100)
text_clip_secondary = text_clip_secondary.set_position('center').set_duration(10).cutout(0, 5)
text_clip_tertiary = TextClip(txt=tertiary_text, color='AntiqueWhite1', font='Arial-Bold', fontsize=100)
text_clip_tertiary = text_clip_tertiary.set_position('center').set_duration(15).cutout(0, 10)
new_video = ColorClip(size=(1920, 1080), color=(0,0,0), duration=15)
new_video.fps = 24
new_video = CompositeVideoClip([new_video, text_clip, text_clip_secondary, text_clip_tertiary])
new_video.write_videofile(codec='mpeg4', filename="test.mp4")
new_video.close()
有人看到我做错了什么吗?
编辑:我也尝试了对 subclip(pos1, pos2) 的适当调用,即
text_clip_secondary = text_clip_secondary.set_position('center').set_duration(15).subclip(5, 10)
结果相同
看起来cutout() 和 subclip() 都不能与 TextClip() 一起使用,所以我在图书馆里挖了一下,发现set_start()似乎有效
前任:
text_clip = TextClip(txt=initial_text, color='AntiqueWhite1', font='Arial-Bold', fontsize=100)
text_clip = text_clip.set_position('center').set_duration(5)
text_clip_secondary = TextClip(txt=secondary_text, color='AntiqueWhite1', font='Arial-Bold', fontsize=100)
text_clip_secondary = text_clip_secondary.set_position('center').set_duration(5).set_start(5)
这可能是故意的,但我不明白 TextClip 如何是 VideoClip 的子类,也许它将在以后的修订中修复
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.