Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MoviePy: Concatenating video clips causes weird glitches in final video

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.
like image 494
JohnSmithy1266 Avatar asked Mar 08 '23 13:03

JohnSmithy1266


1 Answers

I had also glitch while concatenating different video clips. Some had different resolutions and that was making output video file with some sort of glitches. I fixed it with

final_clip = concatenate_videoclips(cliparray, method='compose')

Resulting output was without any glitch, but since they have different resolutions, the moviepy assigns highest resolution among video clips. To fix this you might just crop to same size.

like image 166
musooff Avatar answered Apr 26 '23 15:04

musooff