0

As suggested, concatenate_videoclips joins the videos, but I want a different way. It looks like concatenate_videoclips merges 2 videos together so that they are played simultaneously.

What I want from moviepy is to join 3 videos A, B and C, as a single video, D. In the joined video D, A is played first, followed by B, with C being the last video played. So I would like to join the videos in Order, instead of merging them in a single frame.

Thanks!

I tried concatenate_videoclips, which takes the paraprahsed video files via VideoFileClip.

In the joined video, I want each video to be played on after another. However, they are played simultaneously

1 Answers1

0

Here's how I do it (creating video slides A, B, C and grouping them one after another as a final clip D):

from moviepy.editor import ImageClip, concatenate_videoclips

def create_final_video(slides: list, slide_duration: int):
        videoclips = []
        for slide in slides:
            image_clip = ImageClip(img=slide["image"], duration=slide_duration)
            image_clip = image_clip.set_fps(30)
            videoclips.append(image_clip)
        video = concatenate_videoclips(videoclips, method="compose").set_position(("center", "center"))
        video.write_videofile("final_clip_D.mp4")

And then just run it like this:

my_image_slides = [
    {"image": "path/to/imageA.jpg"},
    {"image": "path/to/imageB.jpg"},
    {"image": "path/to/imageC.jpg"}
]
create_final_video(my_image_slides, 7)

final_clip_D.mp4 will be 21 seconds long.