Home CCTV using zmodopipe

We have an old Elro CCTV system which mainly looks at the parking lot. The problem with this old DVR (digital video recorder) is that it provides a User-Interface in the local network which can only be seen with IE11 in compatibility mode as it uses ActiveX content (or a third-party android app).

After a while of research I found out that the device has an open telnet port which can be accessed with the password “123456”. Yes really.

But I could not get more from it as I did not know how everything works, the file system is mounted ro and I did not want to mess everything up since there would be no easy way back.

Luckily the Open-Source-Community implemented zmodopipe which allows to access various DVR systems with ActiveX from Zoneminder.

The install process is done by this small script:

wget -O zmodopipe.zip https://forums.zoneminder.com/download/file.php?id=553
unzip zmodopipe.zip
gcc zmodopipe.c -o zmodopipe
cp zmodopipe /usr/bin/zmodopipe

# configure systemd service file
cp zmodopipe.service /etc/systemd/system/zmodopipe.service

sudo systemctl daemon-reload
sudo service zmodopipe enable
sudo service zmodopipe start
#cat /tmp/zmodo0 > capture.mp4
ffmpeg -f h264 -i /tmp/zmodo0 capture.mp4

It is basically just downloading zmodopipe_v41.zip from this article https://forums.zoneminder.com/viewtopic.php?t=18137 , compiling and setting up a systemd-unit.

The usage has been described here too: https://wiki.zoneminder.com/Zmodopipe

What is missing is the zmodopipe.service systemd unit file which has the following content:

[Unit]
Description=Zmodopipe
After=network.agent

[Service]
Type=simple
ExecStart=/usr/bin/zmodopipe -s <IPADDRESS> -p <MEDIAPORT> -m 6 -c 1 -c 2 -c 3 -c 4 -u admin -a PASSPHRASE

[Install]
WantedBy=multi-user.target

the passphrase is set for the user in the web-frontend or at the DVR directly. The same goes for the media port, which defaults to 9000.

Now we have named pipes at /tmp/zmodoX which can be read with ffmpeg. Now what? We want to get a stream from it.

Basically there are two options what to do next. One is to use a rtsp-server which only publishes a stream for the pipes and the other option would be to use zoneminder or motion to capture the video and get notifications if there is action in a given monitored zone.
The latter one seems to be better for future development and integrations of IP-Cams and I could not find a decent rtsp-server working out of the box.

So I first tried motion but could not get it running with the named pipes. So I sticked with zoneminder (well, zmodopipe has been implemented for it) which worked quite well, even using docker and mounting the /tmp/zmodoX into the container.

the relevant part of the docker-compose.yml looks like this:

  zoneminder:
    container_name: zoneminder
    image: zoneminderhq/zoneminder:latest-ubuntu18.04
    restart: always
    shm_size: 256m
    environment:
      - TZ=Europe/Berlin
    volumes:
      - ./data/zm/images:/var/cache/zoneminder/images
      - ./data/zm/events:/var/cache/zoneminder/events
      - ./data/zm/mysql:/var/lib/mysql
      - /tmp:/temp_host
    ports:
      - 3009:80

I first used the docker image by dlandon which was a lot more recent at the time, but it is configured to run apt update on startup which increased the startup time of the docker to a few minutes, which made me switch to zondeminderhq.

From there I can now view the stream in Home-Assistant. Home-Assistant even has a integration for zoneminder which allows me to turn off the video stream when it is unneeded to save resources, as the DVR-System is recording the whole time anyways.