0

I used this example to create an animation of the font: https://zulko.github.io/moviepy/examples/moving_letters.html

If title = "Cool effect Cool effect Cool effect" then the text is displayed and animated. If title = "Lorem ipsum dolor sit amet" then the text is NOT displayed. Why?! Here is my Code:


import numpy as np
import moviepy.editor as mp

from moviepy.editor import *
from moviepy.video.tools.segmenting import findObjects

def letter_animation(intro_length):
    
    # WE CREATE THE TEXT THAT IS GOING TO MOVE, WE CENTER IT.

    screensize = (1080, 1920)
    
    title = "Lorem ipsum dolor sit amet"
    #title = "Cool effect Cool effect Cool effect"
    txtClip = TextClip(title, font="Roboto",
                    kerning = 5, fontsize=60, color = "yellow")
    cvc = CompositeVideoClip( [txtClip.set_pos('center')],
                            size=screensize)
    # THE NEXT FOUR FUNCTIONS DEFINE FOUR WAYS OF MOVING THE LETTERS

    # helper function
    rotMatrix = lambda a: np.array( [[np.cos(a),np.sin(a)], 
                                    [-np.sin(a),np.cos(a)]] )

    def vortex(screenpos,i,nletters):
        d = lambda t : 1.0/(0.3+t**8) #damping
        a = i*np.pi/ nletters # angle of the movement
        v = rotMatrix(a).dot([-1,0])
        if i%2 : v[1] = -v[1]
        return lambda t: screenpos+400*d(t)*rotMatrix(0.5*d(t)*a).dot(v)
    
    letters = findObjects(cvc) # a list of ImageClips

    random_animation = vortex
    # WE ANIMATE THE LETTERS

    def moveLetters(letters, random_animation):
        return [ letter.set_pos(random_animation(letter.screenpos,i,len(letters)))
                for i,letter in enumerate(letters)]

    clips = moveLetters(letters, random_animation)

    
    # WE CONCATENATE EVERYTHING AND WRITE TO A FILE
    intro = CompositeVideoClip(clips, size=screensize).set_duration(intro_length)

    intro.write_videofile('../../coolTextEffects18.mp4',fps=25)

letter_animation(8)

0 Answers0