A snapshot of a RTSP-stream every second

Posted on January 30, 2022 • 2 min read • 254 words
Thought it wasn’t possible to display an RTSP stream on a Grafana dashboard? Think again. I’ve recently started making a snapshot of an RTSP stream every…
A snapshot of a RTSP-stream every second

Thought it wasn’t possible to display an RTSP stream on a Grafana dashboard? Think again. I’ve recently started making a snapshot of an RTSP stream every second and displaying it on my dashboard.

In my office, I have a monitor displaying a Grafana dashboard. On it, I show all sorts of things that our [home automation system]/wat-is-domotica/ Home Assistant measures and controls.

One of the things I wanted to display was an overview of our cameras, especially the doorbell camera. Unfortunately, Grafana (at least at that time) did not support RTSP streams.

To still display the cameras, I created a script that takes a snapshot of the camera every second. I then use these snapshots in Grafana in an HTML frame.

You can use the following script for your snapshot of an RTSP stream

#!/bin/bash
url0='rtsp://10.0.x.x:7447/<stream>'
url='rtsp://10.0.x.x:7447/<stream>'
url1='rtsp://10.0.x.x:7447/<stream>'
url2='rtsp://10.0.x.x:7447/<stream>'
while true; do
  # Do something
  ffmpeg -y -i $url -r 1 -vsync 1 -qscale 1 -frames:v 1  -loglevel quiet -f image2 /containers/url/public_html/camera/frontdoor-small.jpg
  sleep 1;
done

It’s a bit of a workaround, as there’s a certain delay in creating a snapshot from a stream, but it’s better than nothing.

Update  

I no longer use the above dashboard and script. Nowadays, I use a dashboard that is entirely made in Home Assistant. I stream this dashboard to a Google Chromecast connected to the HDMI port of my monitor. This way, I don’t need to maintain a separate Grafana dashboard and also save a little bit of electricity by using a Chromecast instead of a Raspberry Pi.

See also

    Follow me