pulsejet / memories

Fast, modern and advanced photo management suite. Runs as a Nextcloud app.
https://memories.gallery
GNU Affero General Public License v3.0
3.19k stars 86 forks source link

Video transcoding using GPU #194

Closed karpiq24 closed 1 year ago

karpiq24 commented 2 years ago

Is it possible to setup transcoding to use GPU? Transcoding is using quite a lot processing power, especially with H.265 source videos. CPU usage goes to 100% while playing video in memories. I have dedicated GPU I'm using for plex on my server and I'd love to also use it for transcoding videos in memories.

pulsejet commented 2 years ago

I assume the question is about NVIDIA? I don't have access to a GPU, so someone else needs to implement this. Should be fairly straightforward:

  1. Check for device and ask admin to enable it similar to QSV https://github.com/pulsejet/memories/blob/63990e524043b5048abcf2ec421b97322c038491/lib/Command/VideoSetup.php#L134
  2. Pass the value to go-vod https://github.com/pulsejet/memories/blob/63990e524043b5048abcf2ec421b97322c038491/lib/Controller/VideoController.php#L99
  3. Add the extra ffmpeg configuration to make it work https://github.com/pulsejet/go-vod/blob/3bfdc856039a6dc812e4518d27fa95c6d3f36dcf/stream.go#L292
karpiq24 commented 2 years ago

Well, yes I currently use NVIDIA GPU, but I'll be soon upgrading to some card supporting AV1 codec, propably AMD or Intel. I might take a look at implementing this when I have some free time, but no promises, I never touched PHP or Go before.

pulsejet commented 2 years ago

Sure. As I mentioned, it should be fairly easy. Not sure what transcoding on AMD/Intel need (AFAIK AMD has some VAAPI support, so might be even easier).

keesfluitman commented 2 years ago

would be great to see this feature. Or even an option to direct play? Aren't most browsers quite compatible? With whatsapp pictures/videos, it's unfortunate if my users can't watch these videos as well and have to go to a different app for that. Im not a programmer at all unfortunately.

pulsejet commented 2 years ago

With whatsapp pictures/videos, it's unfortunate if my users can't watch these videos as well and have to go to a different app for that.

You can turn off transcoding in video-setup if it's not usable. That should play whatever your browser is compatible with.

karpiq24 commented 1 year ago

I took a look at this, and as of right now I won't be able to get this working. I'm using Linux Alpine based docker image for Nextcloud, and there are no nvidia drivers for Alpine. I might return to this issue if I decide to change docker image or sometime next year when I change GPU in my server (not Nvidia).

pulsejet commented 1 year ago

I don't know why linuxserver uses alpine in the first place. It's got zero advantages especially when you're running a storage system (so not many constraints on image size), and makes life difficult for developers because you've to support both glibc and musl 🤷🏻

pulsejet commented 1 year ago

Marking this for the next release (hopefully) https://github.com/pulsejet/go-vod/pull/3

pulsejet commented 1 year ago

Contributed by @MB-Finski for v4.9.0 See https://github.com/pulsejet/memories/wiki/Configuration

keesfluitman commented 1 year ago

nice. video on external shares seems to work for me as well now. Now the preview size and then Im a really happy fellow.

So technically I could now add my gpu to the nextcloud container for transcoding?

pulsejet commented 1 year ago

I've no idea if/how GPUs can be passed to containers. If you can do that, you probably just need to install the correct drivers in the container and compile ffmpeg from source if that's needed (this is easier than it sounds).

It's probaby possible https://www.reddit.com/r/jellyfin/comments/jbbz8t/nvidia_gpu_transcoding_in_jellyfin_docker_success/ If you (or anyone else) get around to this, please update here so the wiki can be updated. As I mentioned, I don't have NVIDIA (or the money for it).

keesfluitman commented 1 year ago

Ill try. Jellyfin was easy to setup.