Zulko / moviepy

Video editing with Python
https://zulko.github.io/moviepy/
MIT License
12.52k stars 1.57k forks source link

Memory leak in concatenate_videoclips #1292

Open ah-ma opened 4 years ago

ah-ma commented 4 years ago

Hi, The code below is just a rough demonstration for what i do, when i execute the code below, The process allocates about 1.5 GB of RAM but only 0.5 GB is freed, Closing and deleting concat_clip has no effect at all, the others produce a minute difference. Am i missing something, thx Python version : 3.7.6 moviepy version : 1.0.3


 from moviepy.editor import ImageClip, concatenate_videoclips, VideoFileClip, AudioClip, VideoClip, CompositeAudioClip, CompositeVideoClip
 clip = VideoFileClip('a.mp4')       # 20 secs  1920x1080 video
 frames = []
 for frame in clip.iter_frames():
         frames.append(ImageClip(frame).set_duration(1/60))

 concat_clip       = concatenate_videoclips(frames, method = "compose")
 Full_video        = CompositeVideoClip([concat_clip.set_start(0)])
 Full_video.write_videofile('outvid.mp4',fps=60,ffmpeg_params=['-crf','10','-preset','ultrafast'])
 concat_clip.close()
 Full_video.close()
 clip.close()
 del concat_clip
 del Full_video 
 del clip 
 del frames
 import gc 
 gc.collect()```
JustAnotherSoftwareDeveloper commented 2 years ago

@keikoro was this ever fixed?

keikoro commented 2 years ago

I didn't follow (up on) this issue, I originally only added tags that seemed appropriate at the time. Sorry!

ranjanvittal commented 1 year ago

Any updates on this @Zulko ? We are facing the same issue. Once write_video_file is called there is a residue of 500MB which is not getting freed.

alexdonaldsonnz commented 1 year ago

I'm also encountering this issue.