Zulko / moviepy

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

Multi-threading support #139

Open Netherdrake opened 9 years ago

Netherdrake commented 9 years ago

Suppose I have 8-core server or 32-core mac pro.

Is there any way to make moviepy/ffmpeg utilize all CPU cores for each rendering job?

Zulko commented 9 years ago

You can either start different python scripts (your os will do the job of dispatching them to the different CPUs) or use the python module called "multiprocessing" (it's in the standard library) which enables you to spawns processes in different threads, one in each core.

Netherdrake commented 9 years ago

For that I already have a solution.

I am interested in multi-threading support within 1 rendering job.

eterevsky commented 9 years ago

It would be great to have several instances of make_frame working simultaneously in VideoClip creation.

ghost commented 8 years ago

Multithreading for a single composition would be awesome.

denisergashbaev commented 7 years ago

@Zulko we are facing an issue that our backend goes down once in a while which is using moviepy in a multithreading setting. Our suspicion is that it may have to be with concurrent use. Could you please advice whether the moviepy is thread-safe or needs to be started in a separate process.

Also, i am wondering if, when the conversion is underway, the GIL is released. We are serving quite a few users on a multi-core machine and would like to utilize the CPU to the max. Thanks

MythicManiac commented 6 years ago

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

nguyenanhtuan1008 commented 3 years ago

@MythicManiac I'm following your guide from https://github.com/Zulko/moviepy/pull/698#issuecomment-359198640

from moviepy.multithreading import multithread_write_videofile

But I got "Exception has occurred: ModuleNotFoundError No module named 'moviepy.multithreading' What happening?

MythicManiac commented 3 years ago

Quoting what I already mentioned in that PR:

I'm not able to provide support on this given that it's already over 2 years old and was never merged, not to mention it was more of a proof of concept anyway.

https://github.com/MythicManiac/moviepy/blob/18e1bd817b6e554319567b82f921fa6f09ab0530/tests/test_multithreading.py the test here is a working example, refer to that and the code itself.

Do realize that the example code was from a fork, which was never merged