alexlaverty / python-reddit-youtube-bot

Automated Reddit Youtube Video Bot
https://www.youtube.com/channel/UCzIwW92D_rM5_yvWBsquSbw
83 stars 19 forks source link

How to speed render video multiprocessing? #4

Open alexdo83 opened 2 years ago

alexdo83 commented 2 years ago

I am wondering if my computer has 8 cores and 16 threads (16MB RAM, VGA Quando 1GB) is there any way to speed up the video processing it ? image

image

I find the processing speed very slow: image CPU and GPU work at low levels, especially GPUs only work at 0-3%... that's an underperformance: image

alexlaverty commented 2 years ago

I found an interesting thread about moviepy performance : https://github.com/Zulko/moviepy/issues/645

I have implemented their suggestion :

post_video.write_videofile(v.filepath, threads=settings.threads, progress_bar = False)

I have defaulted it to 4 threads in the settings.py file, but if you have more cores than that you can try increasing the value and see if that improves performance for you

alexdo83 commented 2 years ago

I'm getting an error while fixing this part

image

beezisback commented 2 years ago

thank you for the work done, I am deeply impressed. I have some suggestions related to the project. my discord is ambsd#8235

I found an interesting thread about moviepy performance : Zulko/moviepy#645

I have implemented their suggestion :

post_video.write_videofile(v.filepath, threads=settings.threads, progress_bar = False)

I have defaulted it to 4 threads in the settings.py file, but if you have more cores than that you can try increasing the value and see if that improves performance for you

alexlaverty commented 2 years ago

I've updated that line and tested it, it now runs without a progress bar as suggested in the thread, not sure how much of a performance improvement it will bring but worth a try. I notice in the thread they say that CompositeVideo clips can bog down performance, maybe there's too many layers in the composite clip, ie the background, the text, the overlay the narrator, etc.. maybe try turning off the overlay in the settings to remove a layer, the overlay is the snow effect you see over the text, might speed things up a bit.

alexdo83 commented 2 years ago

I've updated that line and tested it, it now runs without a progress bar as suggested in the thread, not sure how much of a performance improvement it will bring but worth a try. I notice in the thread they say that CompositeVideo clips can bog down performance, maybe there's too many layers in the composite clip, ie the background, the text, the overlay the narrator, etc.. maybe try turning off the overlay in the settings to remove a layer, the overlay is the snow effect you see over the text, might speed things up a bit.

Yes, I also tried removing "progress_bar = False" , it worked but didn't increase the speed.

alexlaverty commented 2 years ago

Just noticed this on stackoverflow about trying different codecs to see which one is fastest for your machine, you might want to play around with your codec :

https://stackoverflow.com/a/67815051