Enable the media server¶
The media server receives your cameras’ video. It produces the live view and the HLS stream the web app plays, runs motion and object detection, and records events. One process, nnvideo, serves every camera.
You can run it:
on the hub machine (recommended, and what this tutorial does), or
on another machine (partly supported today; see below).
On the hub machine¶
These steps continue on the Orange Pi 6 Plus from Hub on the Orange Pi 6 Plus.
1. The detector model¶
Object detection runs in a small helper, nn-inferd. It loads one model:
a
.cixmodel runs on the Orange Pi 6 Plus NPU;an
.onnxmodel runs on the CPU (works anywhere, slower).
The NPU model is YOLOX-S from the CIX AI Model Hub on ModelScope
(cix/ai_model_hub_25_Q3, under models/ComputeVision/Object_Detection/onnx_yolox_s). Put it in
your home folder as ~/models/yolox_s.cix (or anywhere, and pass --model below).
2. Install the media server¶
Download the newest nn-media-host-<version>.tar.gz from the
hub releases page, unpack it and run its installer. The hub
must be installed first: the media server runs on the hub’s Python environment and uses the hub’s
keys.
$ tar -xzf nn-media-host-<version>.tar.gz
$ cd nn-media-host-<version>
$ sudo ./deploy/install-media.sh --user $USER
It installs the video and AI packages, the four media services (nn-inferd, nn-transcoded, nn-media-ctrl, nn-video-pipelines) and starts them. It points the camera control channel at the hub’s keys, and keeps the memory the services share when you log out. Running it again on a newer release is the update.
Note
The installer ships from release v0.0.2 on.
3. Check it¶
$ curl http://localhost:8880/health
{"ok": true, ...}
In the web app, open Pipelines: it lists the media server with no cameras yet. Cameras appear there by themselves once you set them up in Set up cameras.
Photo needed: The Pipelines page with the media server online
Screenshot of the Pipelines tab showing the media host online and no cameras.
On another machine¶
You can run the video part of the media server on a second machine, for example a PC with a stronger processor beside a small hub. The camera control channel (nn-media-ctrl) stays on the hub: it works with the hub’s private key, which never leaves the hub.
This works from release v0.0.2 on. The examples use hub.lan for the hub and media.lan for
the media machine; use their addresses.
On the media machine, unpack both the hub and the media-host release, put the model in place, and install the video services, telling them where the hub is and how the hub reaches this machine:
$ tar -xzf nn-hub-<version>.tar.gz $ tar -xzf nn-media-host-<version>.tar.gz && cd nn-media-host-<version> $ sudo ./deploy/install-media.sh --user $USER \ --hub-url http://hub.lan:8769 --public-url http://media.lan:8880 \ --hub-package ../nn-hub-<version>
--hub-packageinstalls the hub’s Python code the video services need, without a hub.On the hub, run the media installer for the control channel only, and re-run the hub installer with the media machine’s address, so the first camera already streams there:
$ cd nn-media-host-<version> $ sudo ./deploy/install-media.sh --user $USER --services nn-media-ctrl $ cd ../nn-hub-<version> $ sudo ./deploy/install-hub.sh --user $USER --media-url http://media.lan:8880
Set up cameras as usual (Set up cameras). The wizard now gives each new camera the media machine’s address for its video and the hub’s for its control channel.
Note
The two machines must reach each other on ports 8769 (hub) and 8880 (media server), and the cameras must reach the media machine on its video port (8886).
Todo
Walk the two-machine setup end to end on real hardware (it is built and unit-tested, not yet run on two machines).
Next: Set up cameras.