MoviePy: Concatenating video clips causes weird glitches in final video

Viewed 3397

Is there a way to successfully always patch up any clips together in such a way that prevents weird glitches? I put together a .mp4 from smaller .mp4 files and I got a final video with weird glitches. I am running Python 3.6.1 on Windows 10 through Sublime Text 3. I used MoviePy to do the concatenation.

The code:

from moviepy.editor import VideoFileClip, concatenate_videoclips
import os.path

path = "C:/Users/blah/videos/out/"

cliparray = []

for filename in os.listdir(path):
    cliparray.append(VideoFileClip(path + filename))

final_clip = concatenate_videoclips(cliparray)

final_clip.write_videofile(path + "concatenatedvideo.mp4", codec = "libx264")

The weird glitches:

  1. One of the clips turns into a 3x3 grid of smaller clips.
  2. Another has the audio not lined up with the video
  3. Another is sped up faster than what was normal.
2 Answers
from moviepy.editor import *

#load video 1 in to variable
video_1 = VideoFileClip('video1.mp4')

#load video 2 in to variable
video_2 = VideoFileClip('video2.mp4')


clips = [video_1, video_2]

# concatenating both the clips
final = concatenate_videoclips(clips,method='compose')

#writing the video into a file / saving the combined video
final.write_videofile("merged.mp4")
 
Related