This little JavaScript app was written to run on node.js on a maxOS server (but should run fine on an Linux or similar) and, using ffmpeg, take a single frame from an RTSP stream and convert it to a .jpeg file and return to the caller of the HTTP GET.
Why does it exist? Because UniFi Protect has the ability to generate RTSP streams from managed cameras on the UniFi Dream Machine PRO or other NVR box, and these can be grabbed and rendered as still images for use as you see fit.
The use case this was developed for was to act as the backend for a Athom Homey flow whereby a press of a doorbell triggers a flow to grab an image using Image Grabber (via HTTP call to this app on my Mac server) and when received sends it on to my phone via a Pushover alert. So, press my doorbell and I get a picture on my phone of who's there. Simples.
Edit config.json to:
- Set level of logging via Bunyan to the console window
- Change the frame size of the rendered .jpeg (resolution) and JPEG compression level (quality)
- Enter the name and URI of the RTSP streams, which in my use case are being generated by my UDMPRO box
The URI for the example files would be http://192.168.0.1/wineCellar for example.
I use pm2 to run the app automatically on boot.
You can also create virtual IP Cams in Homey and specify the URI for on-demand viewing of snapshots (or testing obvs).