#!/bin/sh
now=$(date +"%T")
SnapFile="/home/jeroen/Deurbel/frontdoorcam.mp4" # Temp name of the video, change it when using this script for multiple cams
VideoLength=5 # Seconds to record
WaitTime=10 # Seconds the script waits before it sends another video
User=admin # Username which has access to the RTSP stream
Password=i5oullQ6xHmy # Password for above provided user
rtspUrl="rtsp://$User:$Password@192.168.1.32:88/videoMain" # Use https://sourceforge.net/projects/onvifdm/ to find your correct RTSP stream url
ChatID=-245000261 # Telegram chat ID See https://www.domoticz.com/wiki/Installing_Telegram_Notification_System for setup instructions
TelegramAPIToken=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx # Telegram API token
filedate=`stat -L --format %Y $SnapFile`
retc=$?
if [ $retc -eq 0 ] ; then
sec=$(( `date +%s`-$filedate))
echo file found and age is $sec seconds
else
sec=999
echo File not found $SnapFile
fi
if [ $sec -gt $WaitTime ] ; then
echo file older than $WaitTime seconds: $sec sending video
ffmpeg -y -i $rtspUrl -r 30 -vcodec copy -an -t $VideoLength $SnapFile
curl -s -F chat_id=$ChatID -F video="@$SnapFile" -F caption="$De deurbel gaat.." https://api.telegram.org/bot$TelegramAPIToken/sendVideo
else
echo There was another try within $WaitTime seconds: $sec
fi
But this one works fine. I tried it with openhab user, and the script worked