问题描述
我正在使用 MoviePY 加入 50 秒或更多的 1、2、3 分钟视频,但它给了我 20 小时,即使我有 64 GB 的内存、i7 和 GTX 670,虽然不是顶级但合理.无论如何我可以加快这个过程吗?
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/
推荐答案
您可以在 write_videofile
中指定多个 threads
.它将通过使用您机器的所有内核显着加快导出速度.
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)
附加说明:
您可以
resize
所有视频到较低的分辨率(例如 720p)
You could
resize
all videos to a lower resolution (e.g. 720p)
降低 fps
也有很大的不同,但 24 fps 已经优化得很好
Decreasing fps
makes also a big difference, but 24 fps is already well optimized
Moviepy 仅使用 CPU 来渲染视频.考虑升级您的 CPU 或在云服务(例如 Amazon AWS、Google Cloud、MS Azure..)上运行您的程序以获得更好的性能
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
这篇关于使用 Python MoviePY 连接视频太慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!