Gamer92000 / LectureCut

LectureCut is a tool that automatically reduces the length of lectures by removing unnecessary parts.
MIT License
9 stars 3 forks source link

🏎️ Implement GPU acceleration #6

Open Gamer92000 opened 2 years ago

Gamer92000 commented 2 years ago

LectureCut needs to support GPU acceleration

This includes

Reference

On the feat/nvidia branch you can see my general idea of this and a helpful function to see what flags Ffmpeg was compiled with.

Figuring out what is best

I don't really have a good idea of how to do this. Obviously, LectureCut should use the fastest possible accelerator. So you need to figure out if Ffmpeg supports it and whether the user has the required hardware. There should be just one flag, like --enable-acceleration to use the previously determined best possible accelerator. This step can take a few seconds to figure things out if you want to go the route of brute force testing against Ffmpeg.

Applying acceleration

The acceleration does not need to be applied to all Ffmpeg calls. Only when video is involved and actual de-, en-, or transcoding takes place.

💡 NOTE

If this turns out to work really well and reliably then you can also turn it on by default and have a --force-disable-accelerator option to do everything on the CPU again.

Gamer92000 commented 2 years ago

So it turns out that Nvidia limits the number of concurrent NvENC sessions to 3. We could either

Pure GPU decoding showed no performance improvement on my setup (R9 5950X + RTX 2070S). However, I could see up to 1.6 times the performance on the transcoding step with a patched driver.