Skip to content

software

Brett Graham edited this page Apr 6, 2020 · 1 revision

The system generates two major data streams:

  • periodic snapshots
  • triggered videos

Snapshots

Snapshots are captured automatically by the cameras (after configuration: see dahuacam.py:set_snap_config) and saved over ftp to the external HD (configured as the local_root for the vsftp FTP service running on the pi).

Capture

For capturing triggered videos a grabber process (see grabber.py) run in a templated systemd service (see [email protected]) started for each camera. This process uses gstreamer to save the h265 encoded video (without decoding) in an mp4 container from the main rtsp stream provided by the camera whenever the NN detects a relevant classification from the sub rtsp stream (smaller resolution, faster frame rate for lower latency).

Discovery

A discovery service (see pcam-discover.service) periodically runs a network scan (using nmap, see discover.py to find IPs on the local ethernet. When an IP is found, a connection attempt is made (using dahuacam.py) and if it returns a valid camera name (camera mac address with colons stripped) a pcam grabber service is started for that IP. If the connection fails (or returned name is invalid) the IP is blacklisted from future scans. Scan black and white lists can be found in 2 locations (these files will be cascaded together with the hard-coded list overwriting the temporary values):

  1. /dev/shm/pcam/ips.json: temporary [for this boot] list where IPs will be automatically white/blacklisted
  2. ~/.pcam/ips.json: hard-coded list [survives reboot] where IPs can be white/blacklisted

These files contain a single dictionary with IP addresses as keys and values equal to false for invalid (non-camera) IPs and the camera name for camera IPs.

To permanently ignore an IP, add it to ~/.pcam/ips.json as a key value pair where key is the IP address and value is false. To reset white/blacklist to the state at boot, remove /dev/shm/pcam/ips.json.

During discovery after the network scan for each valid cameras the system service for that camera will be checked and started if not running.

Clone this wiki locally