m1k1o / neko

A self hosted virtual browser that runs in docker and uses WebRTC.
https://neko.m1k1o.net/
Apache License 2.0
5.96k stars 449 forks source link

Hardware acceleration? #228

Closed IngwiePhoenix closed 1 year ago

IngwiePhoenix commented 1 year ago

I have moved my Neko instance across servers several times by now and really love it. But I finally have a server that has some good GPU to it and I would love to utilize that, mainly because software rendering is a bit troublesome on this specific system.

So, I would like to know if:

The device is a FriendlyElec NanoPi R6s - 4+4 ARMv8 with a pretty neat iGPU.

Thanks!

m1k1o commented 1 year ago

Currently there has been added support for only vdpau/vaapi hardware acceleration for encoding the video stream. I don'ŧ know if that can be used in your NanoPi.

For hardware acceleration inside neko, so that the apps (browser) can use GPU, there is already similar issue.

You could be able to install Neko "natively", I have tried it in one VM. Although there is not proper documentation about this, you would just need to follow steps that are in Dockerfile, install on your host system and then just run it. However, I recommend starting with exsiting system that has GUI with desktop manager, is based on Xorg and uses Pulseaudio. For that matter you only need to install gstreamer dependencies, configure pulseaudio properly and run neko binary (you don't need to build it from scratch, you can copy it from docker image). This process would be nice to have documented.

You could theoretically just expose your host's Xorg server inside neko container and it would control your host system. In that case, it would be a nice addition to create lightweight container only for this puropse. You could use m1k1o/neko:base for it, but it contains Xserver that would not be used by you. But getting audio to work this way is additional effort.

IngwiePhoenix commented 1 year ago

Currently there has been added support for only vdpau/vaapi hardware acceleration for encoding the video stream. I don'ŧ know if that can be used in your NanoPi.

root@FriendlyWrt /sdcard# ffmpeg -hide_banner -hwaccels
Hardware acceleration methods:
vdpau
vaapi
drm
vulkan

root@FriendlyWrt /sdcard# tree -a /dev/dri
/dev/dri
├── card0
├── card1
├── renderD128
└── renderD129

No problem :)

ollow steps that are in Dockerfile,

Good call...will give it a shot. I also have not spotted any documentation about native installation.

You could theoretically just expose your host's Xorg server inside neko container and it would control your host system.

That is possible? I never really got the hang of Xorg/Wayland...so I wouldn't know. But this might work quite well.

Thank you for your insights, this'll definitively keep me occupied for a while =)

yatli commented 1 year ago

I've hacked together a working POC here: https://github.com/yatli/neko/commit/59df4c661e13acf0c172c8a513fce95668f3c37f

m1k1o commented 1 year ago

@yatli what run command did you use? It fails for me: image

Did it use your external screen?

yatli commented 1 year ago

Nothing special, just docker-compose up the locally built image.

Did it use your external screen?

Yes. My home server is connected to the TV.

You can shell into the container and "neko" the Xorg.99.0.log file to see what's gone wrong. Usually it's a permission issue. Aside from SYS_ADMIN, I also need to chown -R 1000:1000 /dev/nvidia* etc. etc.

m1k1o commented 1 year ago

Nvidia GPU acceleration has been merged.