CCTV Camera Setup in ArchLinux
Network setup for cameras¶
┌──────────────────────────┐ ┌─────────────┐
│ ArchLinux Desktop │─────│ enp5s0 │──────── (Internet/WAN)
│ (vector@ArchLinuxR72700)│ │ (Built-in │
└──────────────────────────┘ │ Ethernet) │
│ └─────────────┘
│
│ ┌─────────────┐
└─────────────────│ br1 │ 10.0.0.1/24
│ (Bridge │ DHCP Server
│ Switch) │ (No Internet Access)
└─────────────┘
│ │
│ │ enp10s0f3u2
│ │ (USB-to-Ethernet adapter)
│ │ (Just a port, no IP address)
│ │
│ ┌─────────┐
│ │Physical │
│ │Network │
│ │Switch │
│ └─────────┘
│ │
│ │
┌───────┘ ├──────────────┐
│ │ │
│ │ │
┌─────────┐ ┌─────────┐ ┌─────────┐
│Windows │ │6 Network│ │ArchLinux│
│VM │ │Cameras │ │Laptop │
│(Virtual)│ │ │ │ │
└─────────┘ └─────────┘ └─────────┘
DHCP Clients on 10.0.0.0/24 Network
About Windows VM
The only purpose of Windows VM in this network is to setup those cameras which require their specific software (often only available on windows).
Eg: SmarPSS for Imou/Dahua.
Setting up the Linux bridge br1¶
We run the DHCP server on a linux bridge br1 instead of running it directly on
ethernet interface connected to the physical network switch. You can think of the
linux bridge as a virtual device with its own IP address, here enp10s0f3u2
becomes
a port of this device.
This setup can be achieved with these files:
/etc/systemd/network/br1.network | |
---|---|
Setting up DHCPD¶
Change the ExecStart line to:
[Service]
ExecStart=
ExecStart=/usr/bin/dhcpd -4 -q -cf /etc/dhcpd.conf -pf /run/dhcpd4/dhcpd.pid br1
sudo systemctl enable systemd-networkd
sudo systemctl start systemd-networkd
sudo systemctl enable dhcpd4.service
sudo systemctl start dhcpd4.service
Systemd NVR¶
~/.config/systemd/user/nvr-dirs.service | |
---|---|
~/.config/systemd/user/nvr-dirs.timer | |
---|---|
Accessing camera in the LAN with internet (enp5s0 network)¶
Don't run this script without understanding what it does.
I no longer use frigate
It seems like you either need a powerful GPU or a Coral device or running Frigate becomes too CPU intensive. I'm just keep this here for future reference.
Frigate¶
source: https://ipv6.rs/tutorial/Arch_Linux/Frigate/
sudo pacman -S git python ffmpeg sudo pacman -S docker docker-buildx sudo systemctl start docker sudo systemctl enable docker
git clone --depth 1 https://github.com/blakeblackshear/frigate.git
cd frigate
cp config/config.yml.example config/config.yml
DOCKER_BUILDKIT=1 docker build -f docker/main/Dockerfile -t frigate .
Check out: https://github.com/blakeblackshear/frigate/discussions/4161
Find out the rtsp link for your camera. For mine it turned out to be:
ffmpeg -i "rtsp://admin:L288B3D8@10.0.0.12:554/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif" result.mp4
proto=Onvif
Without "proto=Onvif" I got no stream.
Where L288B3D8 was the safety code written on camera. In the link proto=Onvif was necessary. This page really helped: https://www.ispyconnect.com/camera/imou
Finally: