Create video from Text Clips using Python and moviepy.

Free Python Code - Sep 4 '23 - - Dev Community

Hi 🙂🖐

In this post, I will share with you Create video from Text Clips using Python and moviepy.

To generate or create video from Text Clips you need to install
imagemagick from here : https://imagemagick.org/script/download.php

and install moviepy from here : pip install moviepy

If this error happend with you :
Moviepy can't detect ImageMagick binary

you can use this code to solve this problem


from moviepy.config import change_settings

IMAGEMAGICK_PATH = r"C:\Program Files\ImageMagick-7.1.1-Q16-HDRI\magick.exe"
change_settings({"IMAGEMAGICK_BINARY": IMAGEMAGICK_PATH})
Enter fullscreen mode Exit fullscreen mode

Now i will create the video

from moviepy.config import change_settings

IMAGEMAGICK_PATH = r"C:\Program Files\ImageMagick-7.1.1-Q16-HDRI\magick.exe"
change_settings({"IMAGEMAGICK_BINARY": IMAGEMAGICK_PATH})


import moviepy.editor as mp

clips = [mp.TextClip(f'Text {n}', 
                     size = (450, 320),
                     align='center', 
                     fontsize = 20,
                     color='white').set_duration(2) for n in range(5)]

video = mp.concatenate_videoclips(clips)
video.write_videofile('test.mp4', fps = 20)
Enter fullscreen mode Exit fullscreen mode

result

Image description

Now we're done 🤗

Don't forget to like and follow 🙂

Support me on PayPal 🤗
https://www.paypal.com/paypalme/amr396

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .