Skip to content Skip to sidebar Skip to footer

Create A Series Of Text Clip And Concatenate Them Into A Video Using Moviepy

In MoviePy there is an api to create a clip from text as well as to concatenate list of clips. I am trying to create a list of clips in a loop and then trying to concatenate them.

Solution 1:

I wasn't able to recreate your issue (maybe because the list I used doesn't raise the exception?), but the code chunk below works for me. The most significant difference from what you have above is that I set an option for MoviePy to adjust varying frame sizes.

from moviepy.editor import *

text_list = ["Piggy", "Kermit", "Gonzo", "Fozzie"]
clip_list = []

for text in text_list:
    try:
        txt_clip = TextClip(text, fontsize = 70, color = 'white').set_duration(2)
        clip_list.append(txt_clip)
    except UnicodeEncodeError:
        txt_clip = TextClip("Issue with text", fontsize = 70, color = 'white').set_duration(2) 
        clip_list.append(txt_clip)

final_clip = concatenate(clip_list, method = "compose")
final_clip.write_videofile("my_concatenation.mp4", fps = 24, codec = 'mpeg4')

If you had an example that raises the unicode encode error, maybe I would be able to reproduce your issue. You may find this other question useful: How to concatenate videos in moviepy?

Post a Comment for "Create A Series Of Text Clip And Concatenate Them Into A Video Using Moviepy"