2
0
mirror of https://github.com/pikvm/pikvm synced 2024-11-01 09:20:17 +00:00
pikvm/docs/webrtc.md

90 lines
4.5 KiB
Markdown
Raw Normal View History

2021-10-12 18:45:00 +00:00
# H.264 / WebRTC
2023-08-12 05:00:11 +00:00
This is a main video streaming mode available on PiKVM V3+ devices and DIY builds based on CSI bridge (USB capture devices are not supported).
With the efficient H.264 encoding, a significant reduction in traffic is achieved compared to old MJPEG mode.
2021-10-12 18:45:00 +00:00
!!! note
2023-08-12 05:03:16 +00:00
The video modes can be switched in the **System** menu in the Web UI.
2023-08-12 05:00:11 +00:00
If you don't see the switch, probably your browser does not support H.264,
or Janus Gateway (the WebRTC server) is not running on PiKVM.
See the [troubleshooting](#troubleshooting) section at the below.
2021-10-12 18:45:00 +00:00
2023-08-12 05:00:11 +00:00
-----
2023-06-01 01:23:46 +00:00
## H.264 parameters
The main parameters available for configuration in the Web UI are **bitrate** and **gop**.
* **Bitrate (H.264 kbps)** - with a large value, the quality will be better, but the network consumption will increase.
* **Group of pictures (H.264 gop)** - the number of frames between which a reference frame must be forcibly added.
The recommended value is 0 for low-loss networks, this will also reduce latency. Use a value of 30 or so for unreliable networks if the image flickers frequently.
2023-08-12 05:00:11 +00:00
-----
## How it's working
2021-06-15 17:15:35 +00:00
2021-07-03 23:31:19 +00:00
The MJPEG video stream uses the same HTTP connection that you use to get the web interface.
This means that for remote access, you just need to forward ports 80 and 443 on your router.
Please review the [Port Foward doc](port_forwarding.md) for proper usage.
2021-06-10 15:40:10 +00:00
In contrast, WebRTC is a completely different way of transmitting video.
2021-07-03 23:32:11 +00:00
It uses a P2P connection and UDP. This reduces network load, but makes it difficult to configure -
the server needs to know your network configuration in order to use it correctly.
2021-06-10 15:40:10 +00:00
2021-09-26 08:47:33 +00:00
To implement this, the PiKVM checks which of the network interfaces is used for the default gateway,
2021-06-10 15:40:10 +00:00
and also tries to find out your external address using the Google [STUN](https://en.wikipedia.org/wiki/STUN) server.
This is necessary when using [Tailscale](tailscale.md) or so that you can connect to your PiKVM from the external Internet.
2021-06-10 15:40:10 +00:00
If you don't like using Google (it was chosen as the default for reliability reasons) for this purpose,
2021-10-12 18:45:00 +00:00
you can choose [any other STUN server](https://www.voip-info.org/stun/) at your discretion, or set up your own.
Edit `/etc/kvmd/override.yaml`:
2021-06-10 15:40:10 +00:00
```yaml
janus:
stun:
host: stun.stunprotocol.org
port: 3478
```
2021-10-12 18:45:00 +00:00
... and restart `kvmd-janus` service using `systemctl restart kvmd-janus`.
2023-08-12 05:00:11 +00:00
-----
2021-10-12 18:45:00 +00:00
## Custom Janus config
2021-06-17 18:48:16 +00:00
[Janus](https://janus.conf.meetecho.com) is a WebRTC gateway that is used to transmit the [uStreamer](https://github.com/pikvm/ustreamer) video.
2021-06-10 15:40:10 +00:00
KVMD-Janus is a wrapper around it, configuring and monitoring changes in the network configuration. This is suitable for most users.
2021-09-26 08:47:33 +00:00
However, if your PiKVM is not connected to the Internet and/or you want to use a custom Janus configuration,
2021-06-10 15:40:10 +00:00
then you should use the `kvmd-janus-static` service instead. You should first change the Janus configuration yourself.
2021-06-17 18:48:16 +00:00
You can find it in `/etc/kvmd/janus/janus.jcfg`.
2021-06-15 17:19:26 +00:00
```
2021-06-10 15:40:10 +00:00
# systemctl disable --now kvmd-janus
...
# systemctl enable --now kvmd-janus-static
2021-06-15 17:19:26 +00:00
```
2021-07-03 23:26:15 +00:00
2021-10-12 18:45:00 +00:00
2023-08-12 05:00:11 +00:00
-----
2021-10-12 18:45:00 +00:00
## Troubleshooting
2023-06-01 01:26:16 +00:00
In rare cases, WebRTC may not work. Here some common tips:
2021-10-12 18:45:00 +00:00
2023-06-01 01:26:16 +00:00
* Clear the browser cache.
2023-06-01 01:26:16 +00:00
* Try other browsers, incognito or private window without any extensions.
2023-06-01 01:26:16 +00:00
* Tricky IPv6 configuration on the network can be a problem. IPv6 support for WebRTC in PiKVM is still in its infancy, so if your network has IPv4, it will be easiest to disable IPv6 on PiKVM. To do this, switch the file system to write mode using `rw` command, add option `ipv6.disable_ipv6=1` to `/boot/cmdline.txt` and perform `reboot`. Also see [here](https://wiki.archlinux.org/title/IPv6#Disable_IPv6).
2021-10-12 18:45:00 +00:00
2021-09-26 08:47:33 +00:00
* A paranoid firewall when you try to connect to the PiKVM by forwarding port 443 to the Internet from the internal network. WebRTC is not enough of this, it uses UDP on ports 10000-20000 for a P2P connection. Make sure that the Firewall does not block them.
2021-10-12 18:45:00 +00:00
2021-07-03 23:26:15 +00:00
* If nothing helps, open the browser's JS console and look at the log, and contact our community via [Discord](https://discord.gg/bpmXfz5). Developers and/or experienced users will definitely help you.
2021-10-12 18:45:00 +00:00
* Another option to try is if you have both wifi and eth connected, disable wifi `rfkill list wifi` then `rfkill block X` where is a number that shows in the output. Reason: Arch Linux will choose to route all outgoing packets out wifi by default.
* There are some linux distro's that require more work to be able to use H.264 (WEBRTC MODE), this may include any RedHat variant.
2021-10-12 18:45:00 +00:00
* For instance: On Fedora you can install the rpmfusion repos, then use the `chromium-freeworld` package instead of `chromium`