ZoneMinder RTSP Motion Detection Fast Start

ZoneMinder RTSP Motion Detection

Fast start to getting RTSP IP camera motion detection up and running


I cannot see the driveway from my home office and would like to know when a car or delivery truck has arrived. The motion detection built into my Foscam IP camera pointed at the driveway was creating too many false positive alarms. Mostly due to sunlight on the driveway from trees moving in the wind. I decided to look for third-party software that could do a better job. Before settling on ZoneMinder, I tried:
  • Homesecurity for Raspberry Pi, NVIDIA Jetson Nano, NVIDIA Jetson Xavier: Does not have built-in support for RTSP devices and my hacks never quite worked out. Even when they did, my version of Xavier CUDA was incompatible. Very nice solution for direct attach cameras and USB cameras though.
  • Motion Project: Supports RTSP out of the box, easy to setup. Very sensitive. Also triggered on sunlight from moving trees. I could not seem to adjust the sensitivity correctly to remove these false positives. Sensitivity uses this algorithm and you can even display the live impact of your sensitivity adjustments. 


  • Run the Zoneminder container. Change this command to reflect the host directories where you would like the configuration stored as well as the saved pictures. Also set your Linux time zone. Installation guide can be found here.
    • sudo docker run -d --name="Zoneminder" \
    • --net="bridge" \
    • --privileged="true" \
    • -p 8443:443/tcp \
    • -p 9000:9000/tcp \
    • -e TZ="America/New_York" \
    • -e SHMEM="50%" \
    • -e PUID="99" \
    • -e PGID="100" \
    • -e INSTALL_HOOK="0" \
    • -e INSTALL_FACE="0" \
    • -e INSTALL_TINY_YOLOV3="0" \
    • -e INSTALL_YOLOV3="0" \
    • -e INSTALL_TINY_YOLOV4="0" \
    • -e INSTALL_YOLOV4="0" \
    • -e MULTI_PORT_START="0" \
    • -e MULTI_PORT_END="0" \
    • -v "/host/mount/for/config":"/config":rw \
    • -v "/host/mount/for/data":"/var/cache/zoneminder":rw \
    • dlandon/zoneminder
  • Turn on web authentication using these instructions. Access the Zoneminder interface at https://host:8443/zm (Firefox works better than Chrome for the self-signed certificate). The default user is "admin" and the default password is "admin".

  • Define an RTSP IP camera and a monitor using these instructions. Here is how I defined the monitor for my Foscam RTSP IP camera:
    • General Tab: Change Source to Remote, Function to Modetect, Reference Image Blend to Outdoor

    • Source Tab: Set Protocol to RTSP, Method to RTP/RTSP, Host Name to the RTSP authentication and IP of your camera (My Foscam is user:password@, Port to the RTSP port (88 for Foscam) Path to the rest of your working RTSP URL (/videoMain for Foscam), Capture Resolution to the actual resolution of your camera (My Foscam is 1920x1080).
    • Click Save and after about a minute you should see your new Monitor turn from red to green. You can click the Log tab at the top of the Zoneminder interface to watch the RTSP connection in progress. Clicking the name of your monitor will bring you to a live view and an event list.

  • Send Alert Emails. ZoneMinder will capture images from your camera as alerts whenever something moves within the camera's field of view. In order to receive these alerts as emails, you need to configure a few components. Detailed instructions are here.

    • OPT_EMAIL: Check the box
    • EMAIL_ADDRESS: The recipient email address for alerts

    • NEW_MAIL_MODUES: Check this box
    • FROM_EMAIL: The sender email address for alerts
    • URL: The URL of your ZoneMinder installation that will be included in the email for easy linking to events.
    • SSMTP_MAIL: Check this box. The ssmtp package is included in this container and is required to communicate securely with Gmail servers. Detailed ssmtp setup instructions for ZoneMinder are here.
    • Edit /etc/ssmtp/ssmtp.conf in your ZoneMinder container.
      • sudo docker exec -it Zoneminder /bin/bash
      • vi /etc/ssmtp/ssmtp.conf
      • Replace the contents of ssmtp.conf with these lines making edits to root (your gmail account), AuthUser (your gmail account), AuthPass (your gmail password)
      • hostname=localhost
      • UseTLS=YES
      • AuthPass=something  # remember if you use 2 factor auth, generate an app specific password
    • Edit /etc/ssmtp/revaliases
      • sudo docker exec -it Zoneminder /bin/bash
      • vi /etc/ssmtp/revaliases
      • Replace the contents of revaliases with these lines making edits to root (your gmail account), www-data (your gmail account)
    • Email Test. See if this works. Just change to your email address.
      • echo "Hello from ZoneMinder" | mail -s "ZoneMinder Subject"

Extra Credit

Mobile Phone Alerting

ZoneMinder also provides an optional mobile app (zmNinja) for receiving alerts. All you have to do is enable the Event Notification Server and install the app on your phone.

  • Turn on the ZoneMinder Event Notification Server. If you want to get alerts when something moves in your camera's field of view, you need to turn on the ZoneMinder Event Notification Server.
    • Check the OPT_USE_EVENTNOTIFICATION box in the Config section of Zoneminder and click Save.

    • Click RUNNING in ZoneMinder and then choose Restart and Apply.

  • Install zmNinja on your phone and run through the Wizard to connect to your ZoneMinder server. Detailed documentation is here. Make sure you select the Event Server setting and click the box for "Use event server". This dance of registering a token for the Event Server is delicate. I had to clear all data (or re-install) zmNinja and start over if there were Event Server errors in the ZoneMinder log. It _does_ work thoughπŸ™‚

    • When everything works, you should start getting event notifications pushed to your phone like these:

    • Selecting a notification will take you to zmNinja where you can watch an image strip of the motion captured (that's me).

Faster Mobile Phone Alerting

My specific use case for this whole mad science experiment was to know when a car or delivery truck had entered the driveway _before_ the vehicle drove away. Email alerts are fine but can take up to a minute or more. The Event Notification Server is faster, but is still not immediate. I decided to look into making the notifications more immediate and found two solutions:

  1.  Reduce the ZoneMinder interval for event checking
    Change DEFAULT_CUSTOMIZE_EVENT_CHECK_INTERVAL in /etc/zm/zmeventnotification.ini from 5 to 1. This speeds up the check for new events from every 5 seconds to every 1 second. You can find this setting on line 128 of the INI file.

    # Interval, in seconds, after which we will check for new events (default: 5).
    #event_check_interval = 5
    event_check_interval = 1

  2. Insert the awesome service into /usr/bin/ on line 1295 to send immediate alert to your phone:
    # this means we haven't previously worked on this alarm
    # so create an event start object for this monitor
    system "curl '[API Code]/Zoneminder/Driveway Alert'";

    Thank You

    Thanks as always for reading this post. Please let me know if you have any questions or improvements.