Is there a way to display rtsp in openhab

I’m relatively new to OpenHab. I have the server up and running with a few basic binding working (local weather / nest).

I have a CCTV security cam system that is using rtsp only and no other way to view the streams and DVR. Is there a way to get the live stream in my portal? I’m currently running the server on centos and using ffmpeg to grab a frame from the rtsp feed every minuet and post it as a jpg. Though I’d really like to have a live feed. The DVR playback would be nice but not 100% necessary.

Any info is appreciated.

I don’t know the direct answer to the question, but if it is ‘no’ then you could transcode the stream to a different format using (for example) vlc.
https://wiki.videolan.org/Documentation:Streaming_HowTo/Command_Line_Examples/

See this page for some ideas. Not sure it answers your questions though.

Thanks I’ll check it out.

1 Like

Thanks. I’ve played with VLC but it’s a lot of background processes to keep track of. I’ll take another look though.

Hi there, did you find any solution for this?
Cheers!

Yes for the most part. It can be transcoded in real time with VLC, but that was difficult to manage and taxing my CPU as I add more and more cameras. In the end I wrote a bash script that ran ffmpeg to grab and save a frame from each rtsp stream. Since I keep writing over the same file I just added the static image to my sitemap and it refreshes when I load the page. The process would get stuck sometime so I added a line to kill the ones hanging and log the last time it ran successfully. It runs every minute via a cron job. Here is what I used:

#!/bin/bash
#Super awesome ffmpeg script

#Kill all hung processes
kill -9 $(ps aux | grep [f]fmpeg | awk ‘{print $2}’)

#Grab still image from camera 1
yes | /usr/local/bin/ffmpeg -i rtsp://my.ip.address/user=MyUser_password=MyPassword_channel=1_stream=0.sdp -vframes 1 -s 480x300 -f image2 /var/www/html/ch01.jpg &

#Grab still image from camera 2
yes | /usr/local/bin/ffmpeg -i rtsp://my.ip.address/user=MyUser_password=MyPassword_channel=1_stream=0.sdp -vframes 1 -s 480x300 -f image2 /var/www/html/ch01.jpg &

#Print log
echo “This script last run on” $(date) > /var/www/html/get-pics.log

1 Like

@cjsaba Thanks a lot for sharing!! I will try this.

@cjsaba I’ve got the script running, except one issue.
I cannot make it run every 5 seconds for example. So I’ve updated a script.

#!/bin/bash
#ffmpeg script

i=0

while [ $i -lt 12 ]; do
#Kill all hung processes
kill -9 $(ps aux | grep [f]fmpeg | awk '{print $2}')
#Grab still image from camera 2
yes | ffmpeg -i rtsp://XXXXXXXXXX/ch0.h264 -vframes 1 -s 800x450 -f image2 /var/www/html/cam2.jpg

sleep 5
i=$(( i + 1 ))

done
1 Like

I used a call to ffmpeg in a python script running on my windows machine. To get it to work, I had to add a ‘-an’ parameter to get it to save the file correctly. The -an tells ffmpeg to expect no sound. Here is the call I used, in case it will help someone else:

subprocess.call(["ffmpeg.exe", "-i", "rtsp://admin:@192.168.1.205/live0.264",
"-vframes", "1", "-s", "800x450", "-an", "-f", "image2", "C:/myimage.jpg",
"-loglevel", "quiet"])