If you’ve been following this series, you’ll know we talked about the dbsink gstreamer plugin for archiving video into a database. Then we discussed the exciting world of h264 PTS timestamps, careful tweaking of which can make random-access video playback possible. In this post, I will discuss how motion events are captured from the IP cameras and stored in the database.
This turned out to be super-simple. Remember this diagram of the IP camera?
The Axis cameras I’m using can be configured to access a get URL on a server when motion is detected. I wrote a C/C++ module for the nginx web server to write a row in a database table when motion is detected.
The URL configured in the camera has an argument that indicates which camera detected motion. Postgresql NOTIFY is used to notify other listening database clients that a new motion event has been added to the database.