0

I want to write text to a video and have it change mid playback, this is what I've tried but it overlays each text on eachother and only displays the text for 5 seconds?

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()

Anyone see what im doing wrong?

Edit: I've also tried the appropriate calls to subclip(pos1, pos2), ie

text_clip_secondary = text_clip_secondary.set_position('center').set_duration(15).subclip(5, 10)

With the same results

1 Answers1

1

It looks like both cutout() and subclip() aren't able to be used with TextClip() so I dug around in the library a bit and figured out that set_start() seems to work

Ex:

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)

This might be intentional but I dont see how as TextClip is a child class of VideoClip, perhaps it will be fixed in later revisions