Skip to content

Commit 81c259c

Browse files
committed
docs: add nvidis gpu examples. #502
1 parent 972d160 commit 81c259c

File tree

2 files changed

+150
-27
lines changed

2 files changed

+150
-27
lines changed

webpage/docs/configuration/capture.md

+36-3
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,9 @@ See documentation for [ximagesrc](https://gstreamer.freedesktop.org/documentatio
188188
hq:
189189
gst_pipeline: |
190190
ximagesrc display-name={display} show-pointer=true use-damage=false
191-
! videoconvert
191+
! videoconvert ! queue
192192
! vp8enc
193+
name=encoder
193194
target-bitrate=3072000
194195
cpu-used=4
195196
end-usage=cbr
@@ -206,8 +207,9 @@ See documentation for [ximagesrc](https://gstreamer.freedesktop.org/documentatio
206207
lq:
207208
gst_pipeline: |
208209
ximagesrc display-name={display} show-pointer=true use-damage=false
209-
! videoconvert
210+
! videoconvert ! queue
210211
! vp8enc
212+
name=encoder
211213
target-bitrate=1024000
212214
cpu-used=4
213215
end-usage=cbr
@@ -235,8 +237,9 @@ See documentation for [ximagesrc](https://gstreamer.freedesktop.org/documentatio
235237
main:
236238
gst_pipeline: |
237239
ximagesrc display-name={display} show-pointer=true use-damage=false
238-
! videoconvert
240+
! videoconvert ! queue
239241
! x264enc
242+
name=encoder
240243
threads=4
241244
bitrate=4096
242245
key-int-max=15
@@ -247,6 +250,36 @@ See documentation for [ximagesrc](https://gstreamer.freedesktop.org/documentatio
247250
! appsink name=appsink
248251
```
249252
</TabItem>
253+
<TabItem value="nvh264enc" label="NVENC H264 configuration">
254+
255+
```yaml title="config.yaml"
256+
capture:
257+
video:
258+
codec: h264
259+
ids: [ main ]
260+
pipelines:
261+
main:
262+
gst_pipeline: |
263+
ximagesrc display-name={display} show-pointer=true use-damage=false
264+
! videoconvert ! queue
265+
! video/x-raw,format=NV12
266+
! nvh264enc
267+
name=encoder
268+
preset=2
269+
gop-size=25
270+
spatial-aq=true
271+
temporal-aq=true
272+
bitrate=4096
273+
vbv-buffer-size=4096
274+
rc-mode=6
275+
! h264parse config-interval=-1
276+
! video/x-h264,stream-format=byte-stream
277+
! appsink name=appsink
278+
```
279+
280+
This configuration requires [Nvidia GPU](https://developer.nvidia.com/cuda-gpus) with [NVENC](https://developer.nvidia.com/nvidia-video-codec-sdk) support.
281+
282+
</TabItem>
250283
</Tabs>
251284

252285
</details>

webpage/docs/installation/examples.md

+114-24
Original file line numberDiff line numberDiff line change
@@ -76,30 +76,11 @@ services:
7676
NEKO_WEBRTC_NAT1TO1: <your-IP>
7777
```
7878
79-
## Raspberry Pi {#raspberry-pi}
80-
81-
```yaml title="config.yaml"
82-
capture:
83-
video:
84-
codec: h264
85-
ids: [ main ]
86-
pipelines:
87-
main:
88-
gst_pipeline: |
89-
ximagesrc display-name=%s use-damage=0 show-pointer=true use-damage=false
90-
! video/x-raw,framerate=30/1
91-
! videoconvert
92-
! queue
93-
! video/x-raw,framerate=30/1,format=NV12
94-
! v4l2h264enc extra-controls="controls,h264_profile=1,video_bitrate=1250000;"
95-
! h264parse config-interval=3
96-
! video/x-h264,stream-format=byte-stream,profile=constrained-baseline
97-
```
79+
## Raspberry Pi GPU Acceleration {#raspberry-pi}
9880
9981
```yaml title="docker-compose.yaml"
10082
services:
10183
neko:
102-
# see docs for more variants
10384
image: "ghcr.io/m1k1o/neko/chromium:latest"
10485
restart: "unless-stopped"
10586
# increase on rpi's with more then 1gb ram.
@@ -110,12 +91,121 @@ services:
11091
# note: this is important since we need a GPU for hardware acceleration alternatively
11192
# mount the devices into the docker.
11293
privileged: true
113-
volumes:
114-
- "./config.yaml:/etc/neko/neko.yaml"
11594
environment:
95+
NEKO_CAPTURE_VIDEO_PIPELINE: |
96+
ximagesrc display-name={display} show-pointer=true use-damage=false
97+
! video/x-raw,framerate=25/1
98+
! videoconvert ! queue
99+
! video/x-raw,format=NV12
100+
! v4l2h264enc
101+
name=encoder
102+
extra-controls="controls,h264_profile=1,video_bitrate=1250000;"
103+
! h264parse config-interval=-1
104+
! video/x-h264,stream-format=byte-stream
105+
! appsink name=appsink
106+
NEKO_CAPTURE_VIDEO_CODEC: "h264"
116107
NEKO_DESKTOP_SCREEN: '1280x720@30'
117-
NEKO_MEMBER_MULTIUSER_USER_PASSWORD: 'neko'
118-
NEKO_MEMBER_MULTIUSER_ADMIN_PASSWORD: 'admin'
108+
NEKO_MEMBER_MULTIUSER_USER_PASSWORD: neko
109+
NEKO_MEMBER_MULTIUSER_ADMIN_PASSWORD: admin
110+
NEKO_WEBRTC_EPR: 52000-52100
111+
NEKO_WEBRTC_ICELITE: 1
112+
```
113+
114+
## Nvidia GPU Acceleration {#nvidia}
115+
116+
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).
117+
118+
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.
119+
120+
```yaml title="docker-compose.yaml"
121+
services:
122+
neko:
123+
image: "ghcr.io/m1k1o/neko/nvidia-firefox:latest"
124+
restart: "unless-stopped"
125+
shm_size: "2gb"
126+
ports:
127+
- "8080:8080"
128+
- "52000-52100:52000-52100/udp"
129+
environment:
130+
NEKO_CAPTURE_VIDEO_PIPELINE: |
131+
ximagesrc display-name={display} show-pointer=true use-damage=false
132+
! video/x-raw,framerate=25/1
133+
! videoconvert ! queue
134+
! video/x-raw,format=NV12
135+
! nvh264enc
136+
name=encoder
137+
preset=2
138+
gop-size=25
139+
spatial-aq=true
140+
temporal-aq=true
141+
bitrate=4096
142+
vbv-buffer-size=4096
143+
rc-mode=6
144+
! h264parse config-interval=-1
145+
! video/x-h264,stream-format=byte-stream
146+
! appsink name=appsink
147+
NEKO_CAPTURE_VIDEO_CODEC: "h264"
148+
NEKO_DESKTOP_SCREEN: 1920x1080@30
149+
NEKO_MEMBER_MULTIUSER_USER_PASSWORD: neko
150+
NEKO_MEMBER_MULTIUSER_ADMIN_PASSWORD: admin
151+
NEKO_WEBRTC_EPR: 52000-52100
152+
NEKO_WEBRTC_ICELITE: 1
153+
deploy:
154+
resources:
155+
reservations:
156+
devices:
157+
- driver: nvidia
158+
count: 1
159+
capabilities: [gpu]
160+
```
161+
162+
See available [Nvidia Docker Images](/docs/v3/installation/docker-images#nvidia).
163+
164+
If you only want to accelerate the encoding, **not the browser rendering**, you can use the default image with additional environment variables:
165+
166+
```yaml title="docker-compose.yaml"
167+
services:
168+
neko:
169+
# highlight-next-line
170+
image: "ghcr.io/m1k1o/neko/firefox:latest"
171+
restart: "unless-stopped"
172+
shm_size: "2gb"
173+
ports:
174+
- "8080:8080"
175+
- "52000-52100:52000-52100/udp"
176+
environment:
177+
# highlight-start
178+
NVIDIA_VISIBLE_DEVICES: all
179+
NVIDIA_DRIVER_CAPABILITIES: all
180+
# highlight-end
181+
NEKO_CAPTURE_VIDEO_PIPELINE: |
182+
ximagesrc display-name={display} show-pointer=true use-damage=false
183+
! video/x-raw,framerate=25/1
184+
! videoconvert ! queue
185+
! video/x-raw,format=NV12
186+
! nvh264enc
187+
name=encoder
188+
preset=2
189+
gop-size=25
190+
spatial-aq=true
191+
temporal-aq=true
192+
bitrate=4096
193+
vbv-buffer-size=4096
194+
rc-mode=6
195+
! h264parse config-interval=-1
196+
! video/x-h264,stream-format=byte-stream
197+
! appsink name=appsink
198+
NEKO_CAPTURE_VIDEO_CODEC: "h264"
199+
NEKO_DESKTOP_SCREEN: 1920x1080@30
200+
NEKO_MEMBER_MULTIUSER_USER_PASSWORD: neko
201+
NEKO_MEMBER_MULTIUSER_ADMIN_PASSWORD: admin
119202
NEKO_WEBRTC_EPR: 52000-52100
120203
NEKO_WEBRTC_ICELITE: 1
204+
deploy:
205+
resources:
206+
reservations:
207+
devices:
208+
- driver: nvidia
209+
count: 1
210+
capabilities: [gpu]
121211
```

0 commit comments

Comments
 (0)