0

I encountered this question, but sadly no good answers online, so I want to put the final solutions here.


Here it is:

You should never give too many videos files(.mp4) to moviepy at once.


But you can give it a parent video

Then split it to thousands of subclips in memory

Actually, in this time, they are not real clips (i mean .mp4 file)


At this moment, your memory only stored one video, the parent video, and the information about subclips (where it starts, where it ends)


In this way, you feed the clip list to concatenate function, it won't cause memory overflow anymore


Here is the demo codes:

parent_clip = VideoFileClip("./parent_video.mp4")
clip_list = []
for part in time_parts:
    time_start = part[0]
    time_end = part[1]
    clip_list.append(
        parent_clip.subclip(time_start, time_end)
    )
concat_clip = concatenate_videoclips(clip_list)
yingshao xo
  • 244
  • 7
  • 11

1 Answers1

0

If you are using Linux(Ubuntu),

you can set a swap partition as a temporary memory.

It solves all kinds of memory leaking problem.

https://www.fosslinux.com/1064/how-to-create-or-add-a-swap-partition-in-ubuntu-and-linux-mint.htm/

yingshao xo
  • 244
  • 7
  • 11