Iam try to create a large video(longer than 3h)by CompositeVideoClip using moviepy.
The problem is it take too much ram (i have 32gb ram).It takes the whole ram (99%) by create a bunch of ffmpeg-win64-v4.2.2.exe ffmpeg-win64-v4.2.2.exe
after it a while it said Unable to allocate 47.5 MiB for an array with shape (1080, 1920, 3) and data type float64. here is my code :
def CombieVideo():
global curentVideoLengt
masterVideo = NULL
for videoUrl in videoFiles:
print(videoUrl)
video = VideoFileClip(videoUrl).fx(vfx.fadein,1).fx(vfx.fadeout,1)
curentVideoLengt += video.duration
if curentVideoLengt >= (audioLen*60*60):
break
if masterVideo== NULL:
masterVideo= video
else:
masterVideo = CompositeVideoClip([masterVideo,video])
if curentVideoLengt < (audioLen*60*60):
videoUrl=random.choice(videoFiles)
print(videoUrl)
video =video(videoUrl).fx(vfx.fadein,1).fx(vfx.fadeout,1)
curentVideoLengt= curentVideoLengt+video.duration
masterVideo = CompositeVideoClip([masterVideo,video])
CombieVideo()
else:
masterVideo.audio = CompositeAudioClip(audios)
masterVideo.write_videofile('./MasterVideo/output_video.avi', fps=30, threads=4, codec="png")
CombieVideo()