docs: add nvidis gpu examples. #502

This commit is contained in:
Miroslav Šedivý 2025-04-05 21:45:19 +02:00
parent 972d16031e
commit 81c259cdc9
2 changed files with 150 additions and 27 deletions

View file

@ -188,8 +188,9 @@ See documentation for [ximagesrc](https://gstreamer.freedesktop.org/documentatio
hq:
gst_pipeline: |
ximagesrc display-name={display} show-pointer=true use-damage=false
! videoconvert
! videoconvert ! queue
! vp8enc
name=encoder
target-bitrate=3072000
cpu-used=4
end-usage=cbr
@ -206,8 +207,9 @@ See documentation for [ximagesrc](https://gstreamer.freedesktop.org/documentatio
lq:
gst_pipeline: |
ximagesrc display-name={display} show-pointer=true use-damage=false
! videoconvert
! videoconvert ! queue
! vp8enc
name=encoder
target-bitrate=1024000
cpu-used=4
end-usage=cbr
@ -235,8 +237,9 @@ See documentation for [ximagesrc](https://gstreamer.freedesktop.org/documentatio
main:
gst_pipeline: |
ximagesrc display-name={display} show-pointer=true use-damage=false
! videoconvert
! videoconvert ! queue
! x264enc
name=encoder
threads=4
bitrate=4096
key-int-max=15
@ -247,6 +250,36 @@ See documentation for [ximagesrc](https://gstreamer.freedesktop.org/documentatio
! appsink name=appsink
```
</TabItem>
<TabItem value="nvh264enc" label="NVENC H264 configuration">
```yaml title="config.yaml"
capture:
video:
codec: h264
ids: [ main ]
pipelines:
main:
gst_pipeline: |
ximagesrc display-name={display} show-pointer=true use-damage=false
! videoconvert ! queue
! video/x-raw,format=NV12
! nvh264enc
name=encoder
preset=2
gop-size=25
spatial-aq=true
temporal-aq=true
bitrate=4096
vbv-buffer-size=4096
rc-mode=6
! h264parse config-interval=-1
! video/x-h264,stream-format=byte-stream
! appsink name=appsink
```
This configuration requires [Nvidia GPU](https://developer.nvidia.com/cuda-gpus) with [NVENC](https://developer.nvidia.com/nvidia-video-codec-sdk) support.
</TabItem>
</Tabs>
</details>

View file

@ -76,30 +76,11 @@ services:
NEKO_WEBRTC_NAT1TO1: <your-IP>
```
## Raspberry Pi {#raspberry-pi}
```yaml title="config.yaml"
capture:
video:
codec: h264
ids: [ main ]
pipelines:
main:
gst_pipeline: |
ximagesrc display-name=%s use-damage=0 show-pointer=true use-damage=false
! video/x-raw,framerate=30/1
! videoconvert
! queue
! video/x-raw,framerate=30/1,format=NV12
! v4l2h264enc extra-controls="controls,h264_profile=1,video_bitrate=1250000;"
! h264parse config-interval=3
! video/x-h264,stream-format=byte-stream,profile=constrained-baseline
```
## Raspberry Pi GPU Acceleration {#raspberry-pi}
```yaml title="docker-compose.yaml"
services:
neko:
# see docs for more variants
image: "ghcr.io/m1k1o/neko/chromium:latest"
restart: "unless-stopped"
# increase on rpi's with more then 1gb ram.
@ -110,12 +91,121 @@ services:
# note: this is important since we need a GPU for hardware acceleration alternatively
# mount the devices into the docker.
privileged: true
volumes:
- "./config.yaml:/etc/neko/neko.yaml"
environment:
NEKO_CAPTURE_VIDEO_PIPELINE: |
ximagesrc display-name={display} show-pointer=true use-damage=false
! video/x-raw,framerate=25/1
! videoconvert ! queue
! video/x-raw,format=NV12
! v4l2h264enc
name=encoder
extra-controls="controls,h264_profile=1,video_bitrate=1250000;"
! h264parse config-interval=-1
! video/x-h264,stream-format=byte-stream
! appsink name=appsink
NEKO_CAPTURE_VIDEO_CODEC: "h264"
NEKO_DESKTOP_SCREEN: '1280x720@30'
NEKO_MEMBER_MULTIUSER_USER_PASSWORD: 'neko'
NEKO_MEMBER_MULTIUSER_ADMIN_PASSWORD: 'admin'
NEKO_MEMBER_MULTIUSER_USER_PASSWORD: neko
NEKO_MEMBER_MULTIUSER_ADMIN_PASSWORD: admin
NEKO_WEBRTC_EPR: 52000-52100
NEKO_WEBRTC_ICELITE: 1
```
## Nvidia GPU Acceleration {#nvidia}
Neko supports hardware acceleration using Nvidia GPUs. To use this feature, you need to have the Nvidia Container Toolkit installed on your system. You can find the installation instructions [here](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html).
This example shows how to accelerate video encoding and as well the browser rendering using the GPU. You can test if the GPU is used by running `nvidia-smi`, which should show the GPU usage of both the browser and neko. In the browser, you can run the [WebGL Aquarium Demo](https://webglsamples.org/aquarium/aquarium.html) to test the GPU usage.
```yaml title="docker-compose.yaml"
services:
neko:
image: "ghcr.io/m1k1o/neko/nvidia-firefox:latest"
restart: "unless-stopped"
shm_size: "2gb"
ports:
- "8080:8080"
- "52000-52100:52000-52100/udp"
environment:
NEKO_CAPTURE_VIDEO_PIPELINE: |
ximagesrc display-name={display} show-pointer=true use-damage=false
! video/x-raw,framerate=25/1
! videoconvert ! queue
! video/x-raw,format=NV12
! nvh264enc
name=encoder
preset=2
gop-size=25
spatial-aq=true
temporal-aq=true
bitrate=4096
vbv-buffer-size=4096
rc-mode=6
! h264parse config-interval=-1
! video/x-h264,stream-format=byte-stream
! appsink name=appsink
NEKO_CAPTURE_VIDEO_CODEC: "h264"
NEKO_DESKTOP_SCREEN: 1920x1080@30
NEKO_MEMBER_MULTIUSER_USER_PASSWORD: neko
NEKO_MEMBER_MULTIUSER_ADMIN_PASSWORD: admin
NEKO_WEBRTC_EPR: 52000-52100
NEKO_WEBRTC_ICELITE: 1
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: 1
capabilities: [gpu]
```
See available [Nvidia Docker Images](/docs/v3/installation/docker-images#nvidia).
If you only want to accelerate the encoding, **not the browser rendering**, you can use the default image with additional environment variables:
```yaml title="docker-compose.yaml"
services:
neko:
# highlight-next-line
image: "ghcr.io/m1k1o/neko/firefox:latest"
restart: "unless-stopped"
shm_size: "2gb"
ports:
- "8080:8080"
- "52000-52100:52000-52100/udp"
environment:
# highlight-start
NVIDIA_VISIBLE_DEVICES: all
NVIDIA_DRIVER_CAPABILITIES: all
# highlight-end
NEKO_CAPTURE_VIDEO_PIPELINE: |
ximagesrc display-name={display} show-pointer=true use-damage=false
! video/x-raw,framerate=25/1
! videoconvert ! queue
! video/x-raw,format=NV12
! nvh264enc
name=encoder
preset=2
gop-size=25
spatial-aq=true
temporal-aq=true
bitrate=4096
vbv-buffer-size=4096
rc-mode=6
! h264parse config-interval=-1
! video/x-h264,stream-format=byte-stream
! appsink name=appsink
NEKO_CAPTURE_VIDEO_CODEC: "h264"
NEKO_DESKTOP_SCREEN: 1920x1080@30
NEKO_MEMBER_MULTIUSER_USER_PASSWORD: neko
NEKO_MEMBER_MULTIUSER_ADMIN_PASSWORD: admin
NEKO_WEBRTC_EPR: 52000-52100
NEKO_WEBRTC_ICELITE: 1
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: 1
capabilities: [gpu]
```