Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-core CPU rendering #584

Closed
rahulbagal opened this issue Jun 8, 2017 · 8 comments
Closed

Multi-core CPU rendering #584

rahulbagal opened this issue Jun 8, 2017 · 8 comments
Labels
lib-FFmpeg Issues pertaining to dependency FFmpeg. performance Speed/performance of code or individual functionality.

Comments

@rahulbagal
Copy link

When I render my MoviePy video on ubuntu it uses only one core of the machine.
As per below thread , ffmpeg supports multiprocessor based on codec ( http://www.ffmpeg-archive.org/FFMPEG-on-multiprocessor-machine-td935307.html )

Is there a way this can be leveraged ?

@ghost
Copy link

ghost commented Jun 14, 2017

try setting the threads argument in the write_videofile function.
for example to use 4 threads, you could do...

video.write_videofile("myvideo.mp4", threads=4)

@ngbien83
Copy link

@Earney threads argument won't force the action to use more machine cores. It doesn't speed up the write file proccess, even I tried "threads=100".
Is there any way to use all the machine cores and memory to rendering the videos faster?

@Zulko
Copy link
Owner

Zulko commented Sep 28, 2017

As I understand it, the thread argument should make ffmpeg use several threads, which your OS may dispatch on several processors. However, it is possible that your bottleneck is the generation of the frames, and not the encoding. If moviepy's frame generation (which is single-threaded if I remember well) is slower than the encoding, then ffmpeg will only require a single thread, even when several are provided. Not sure if this applies to your case ?

@keikoro keikoro added the lib-misc Issues pertaining to misc. 3rd-party libraries. label Nov 25, 2017
@MythicManiac
Copy link

^ I added a proof of concept multithreading support, albeit a bit gimmicky it appears to be working.

@adam-grant-hendry
Copy link

@Zulko Will multithreading work on Windows? I think it works only on Linux due to the Python GIL.

@keikoro keikoro added the performance Speed/performance of code or individual functionality. label Oct 3, 2020
@keikoro keikoro added lib-FFmpeg Issues pertaining to dependency FFmpeg. and removed lib-misc Issues pertaining to misc. 3rd-party libraries. labels Jan 14, 2022
@idan92
Copy link

idan92 commented Apr 22, 2022

Hi guys, in the past I was same problem and I solved that.

You need to use this command in your code ONLY one time.

video = CompositeVideoClip([clip1, clip2, clip3])

and export the video:

video.write_videofile(path_final_video)

while the video is export, moviepy will use all your cores.

Hope I helped :)

@keikoro
Copy link
Collaborator

keikoro commented Oct 11, 2022

Closing this older issue with a link to this Moviepy Roadmap comment regarding (potential future) multithreading support.

@keikoro keikoro closed this as completed Oct 11, 2022
@tungvv318
Copy link

tungvv318 commented Jul 1, 2024

Hi guys, in the past I was same problem and I solved that.

You need to use this command in your code ONLY one time.

video = CompositeVideoClip([clip1, clip2, clip3])

and export the video:

video.write_videofile(path_final_video)

while the video is export, moviepy will use all your cores.

Hope I helped :)

@idan92
Why do you know it slows because using CompositeVideoClip multiple times?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lib-FFmpeg Issues pertaining to dependency FFmpeg. performance Speed/performance of code or individual functionality.
Projects
None yet
Development

No branches or pull requests

8 participants