I am joining 50s or more videos of 1,2,3 minutes using MoviePY but it's giving me 20 hours, even though I have 64 GB of ram, i7 and GTX 670, not top of range yet reasonable. Is there anyway I can speed this process up ?
padding = 10 # padding option
video_clips = [VideoFileClip(video_dir + video) for video in os.listdir(video_dir)]
video_fx_list = [video_clips[0]]
idx = video_clips[0].duration - padding
for video in video_clips[1:]:
video_fx_list.append(video.set_start(idx).crossfadein(padding))
idx += video.duration - padding
final_video = CompositeVideoClip(video_fx_list)
final_video.write_videofile(video_dir + 'myoutfile.mp4', fps=24)
I don't need original audio these clips have, would removing it going to speed things up ? not sure how to remove audio though/
You can specify a number of threads
in write_videofile
. It will significantly speed up the export by using all cores of your machine.
final_video.write_videofile(video_dir + 'myoutfile.mp4', threads = 8, fps=24)
Aditionnal notes:
You could resize
all videos to a lower resolution (e.g. 720p)
Decreasing fps
makes also a big difference, but 24 fps is already well optimized
Moviepy uses only the CPU to render the video. Consider to upgrade your CPU or run your program on cloud services (e.g. Amazon AWS, Google Cloud, MS Azure..) for better performance
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With