Douglas
Douglas

Reputation: 21

How to concatenate multiple videos using moviepy

Yeah, basically we want to join multiple videos like this: 1 + 1 + ...= 11... (1:video) sorry that's the best example i could come up with on the spot. and export them to be one video

Upvotes: 1

Views: 2872

Answers (2)

LetzerWille
LetzerWille

Reputation: 5668

A had problems with the solution when tried to concatenate two .avi videos. I used the solution by 'night vision', to create not .avi, but mp4 instead, using mp4 codec

def concatenate_videos(list_videos,newname):
    
    from moviepy.editor import VideoFileClip, concatenate_videoclips

    concatinated = concatenate_videoclips([VideoFileClip(v) for v in list_videos])

    concatinated.write_videofile(newname + '.mp4', codec='libx264')

Upvotes: 0

night vision
night vision

Reputation: 134

Refer this Example:

from moviepy.editor import VideoFileClip, concatenate_videoclips

# Read files
vid1 = VideoFileClip("video1.mp4")
vid2 = VideoFileClip("video2.mp4")
vid3 = VideoFileClip("video3.mp4")

# Concat them
final = concatenate_videoclips([vid1, vid2, vid3])

# Write output to the file
final.write_videofile("newVideo.mp4")

Hope this helps you!

Upvotes: 5

Related Questions