Take snapshot with camera when ringing doorbell
Moderators: leecollings, remb0
Take snapshot with camera when ringing doorbell
I am new to this forum and have some questions. Although I have searched for a topic on this forum, I get not found anything that can help me. I'm a starter with Domoticz and already playfully acquainted with the program. I have no programming knowledge, but do like to experiment with everything that has to do with automation. What I have achieved; At this time I got it done if someone rings my doorbell, enters the lighting in my hall and I get a push message on my phone. What do I expand now? I would like it if someone pressed my doorbell with my security camera a snapshot is created and sent via push to my phone. I read somewhere that this should be possible by using a script. Where can I find a script that I can modify it if necessary? How / where do I put the software Domoticz this script? Where can I find somewhere a good description of "how it works". Thanks for the effort
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Take snapshot with camera when ringing doorbell
Have you read all 344 matches at http://www.domoticz.com/forum/search.ph ... a+snapshot and the wiki at http://www.domoticz.com/wiki/Camera_Setup ?
Re: Take snapshot with camera when ringing doorbell
Thanks. Do not know why I could not find it myself. Hope I can find my answer here.
Re: Take snapshot with camera when ringing doorbell
I have been working on this for a while now and used the script provided by a fellow Domoticz forum user.
The script has been improved over time, it now consists of transcoding a video directly from the RTSP stream from my cam and sending it to Telegram when someone hits the doorbell. In the event that someone hits the doorbell again within 10 seconds after the previous push the script does nothing.
I've created a blockly event where it rings the bell and kicks off the script below the moment de doorbell is pressed.
Make sure you have ffmpeg installed [sudo apt-get install ffmpeg]
The script has been improved over time, it now consists of transcoding a video directly from the RTSP stream from my cam and sending it to Telegram when someone hits the doorbell. In the event that someone hits the doorbell again within 10 seconds after the previous push the script does nothing.
I've created a blockly event where it rings the bell and kicks off the script below the moment de doorbell is pressed.
Make sure you have ffmpeg installed [sudo apt-get install ffmpeg]
Code: Select all
#!/bin/sh
now=$(date +"%T")
SnapFile="/var/tmp/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=**** # Username which has access to the RTSP stream
Password=****** # Password for above provided user
rtspUrl="rtsp://$User:$Password@[IP address]/" # Use https://sourceforge.net/projects/onvifdm/ to find your correct RTSP stream url
ChatID=******* # Telegram chat ID See https://www.domoticz.com/wiki/Installing_Telegram_Notification_System for setup instructions
TelegramAPIToken=*********:********************** # 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="$now Doorbell ringing.." https://api.telegram.org/bot$TelegramAPIToken/sendVideo
else
echo There was another try within $WaitTime seconds: $sec
fi
-
- Posts: 70
- Joined: Monday 06 February 2017 12:48
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V4.9700
- Location: Azores
- Contact:
Re: Take snapshot with camera when ringing doorbell
Hello Ernieb44, can you do a more detailed explanation on how to make this?
ernieb44 wrote: ↑Wednesday 03 January 2018 0:10 I have been working on this for a while now and used the script provided by a fellow Domoticz forum user.
The script has been improved over time, it now consists of transcoding a video directly from the RTSP stream from my cam and sending it to Telegram when someone hits the doorbell. In the event that someone hits the doorbell again within 10 seconds after the previous push the script does nothing.
I've created a blockly event where it rings the bell and kicks off the script below the moment de doorbell is pressed.
Make sure you have ffmpeg installed [sudo apt-get install ffmpeg]
Code: Select all
#!/bin/sh now=$(date +"%T") SnapFile="/var/tmp/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=**** # Username which has access to the RTSP stream Password=****** # Password for above provided user rtspUrl="rtsp://$User:$Password@[IP address]/" # Use https://sourceforge.net/projects/onvifdm/ to find your correct RTSP stream url ChatID=******* # Telegram chat ID See https://www.domoticz.com/wiki/Installing_Telegram_Notification_System for setup instructions TelegramAPIToken=*********:********************** # 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="$now Doorbell ringing.." https://api.telegram.org/bot$TelegramAPIToken/sendVideo else echo There was another try within $WaitTime seconds: $sec fi
-
- Posts: 70
- Joined: Monday 06 February 2017 12:48
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V4.9700
- Location: Azores
- Contact:
Re: Take snapshot with camera when ringing doorbell
Looks like FFMPEG isint available.
Had to use: apt-get install libav-tools
Guess that now for me to send photos instead of video it should be something like this (will try as soon as I get home):
Had to use: apt-get install libav-tools
Guess that now for me to send photos instead of video it should be something like this (will try as soon as I get home):
Code: Select all
#!/bin/sh
now=$(date +"%T")
SnapFile="/var/tmp/frontdoorcam.jpg" # Temp name of the photo, change it when using this script for multiple cams
#VideoLength=5 # Seconds to record
WaitTime=10 # Seconds the script waits before it sends another photo
User=**** # Username which has access to the RTSP stream
Password=****** # Password for above provided user
rtspUrl="rtsp://$User:$Password@[IP address]/" # Use https://sourceforge.net/projects/onvifdm/ to find your correct RTSP stream url
ChatID=******* # Telegram chat ID See https://www.domoticz.com/wiki/Installing_Telegram_Notification_System for setup instructions
TelegramAPIToken=*********:********************** # 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 photo
avconv -rtsp_transport tcp -i $rtspUrl -f image2 -vframes 1 -pix_fmt yuvj420p $SnapFile # avconv -i $rtspUrl -vf $SnapFile
curl -s -F chat_id=$ChatID -F photo="@$SnapFile" -F caption="$now Doorbell ringing.." https://api.telegram.org/bot$TelegramAPIToken/sendPhoto
else
echo There was another try within $WaitTime seconds: $sec
fi
Re: Take snapshot with camera when ringing doorbell
Sure.. i can do that.. but please let me know what extra information you are looking for?gajotnt wrote: ↑Wednesday 03 January 2018 16:14 Hello Ernieb44, can you do a more detailed explanation on how to make this?
ernieb44 wrote: ↑Wednesday 03 January 2018 0:10 I have been working on this for a while now and used the script provided by a fellow Domoticz forum user.
The script has been improved over time, it now consists of transcoding a video directly from the RTSP stream from my cam and sending it to Telegram when someone hits the doorbell. In the event that someone hits the doorbell again within 10 seconds after the previous push the script does nothing.
I've created a blockly event where it rings the bell and kicks off the script below the moment de doorbell is pressed.
Make sure you have ffmpeg installed [sudo apt-get install ffmpeg]
Code: Select all
#!/bin/sh now=$(date +"%T") SnapFile="/var/tmp/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=**** # Username which has access to the RTSP stream Password=****** # Password for above provided user rtspUrl="rtsp://$User:$Password@[IP address]/" # Use https://sourceforge.net/projects/onvifdm/ to find your correct RTSP stream url ChatID=******* # Telegram chat ID See https://www.domoticz.com/wiki/Installing_Telegram_Notification_System for setup instructions TelegramAPIToken=*********:********************** # 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="$now Doorbell ringing.." https://api.telegram.org/bot$TelegramAPIToken/sendVideo else echo There was another try within $WaitTime seconds: $sec fi
-
- Posts: 5
- Joined: Sunday 08 January 2017 12:02
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Take snapshot with camera when ringing doorbell
I'm trying to get this to work but so far no luck. Anyone here who can help me out? Here's the script which is on my raspberry.ernieb44 wrote: ↑Wednesday 03 January 2018 0:10 I have been working on this for a while now and used the script provided by a fellow Domoticz forum user.
The script has been improved over time, it now consists of transcoding a video directly from the RTSP stream from my cam and sending it to Telegram when someone hits the doorbell. In the event that someone hits the doorbell again within 10 seconds after the previous push the script does nothing.
I've created a blockly event where it rings the bell and kicks off the script below the moment de doorbell is pressed.
Make sure you have ffmpeg installed [sudo apt-get install ffmpeg]
Code: Select all
#!/bin/sh now=$(date +"%T") SnapFile="/var/tmp/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=**** # Username which has access to the RTSP stream Password=****** # Password for above provided user rtspUrl="rtsp://$User:$Password@[IP address]/" # Use https://sourceforge.net/projects/onvifdm/ to find your correct RTSP stream url ChatID=******* # Telegram chat ID See https://www.domoticz.com/wiki/Installing_Telegram_Notification_System for setup instructions TelegramAPIToken=*********:********************** # 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="$now Doorbell ringing.." https://api.telegram.org/bot$TelegramAPIToken/sendVideo else echo There was another try within $WaitTime seconds: $sec fi
Code: Select all
#!/bin/sh
now=$(date +"%T")
SnapFile="/var/tmp/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=<username> # Username which has access to the RTSP stream
Password=<password> # Password for above provided user
rtspUrl="rtsp://$User:[email protected]:554/play1.sdp/" # Use https://sourceforge.net/projects/onvifdm/ to find your correct RTSP stream url
ChatID=<chatid> # Telegram chat ID See https://www.domoticz.com/wiki/Installing_Telegram_Notification_System for setup instructions
TelegramAPIToken=<token> # 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="$now Doorbell ringing.." https://api.telegram.org/bot$TelegramAPIToken/sendVideo
else
echo There was another try within $WaitTime seconds: $sec
fi
Code: Select all
stat: cannot stat '/var/tmp/frontdoorcam.mp4': No such file or directory
File not found /var/tmp/frontdoorcam.mp4
file older than 10 seconds: 999 sending video
ffmpeg version 3.2.10-1~deb9u1+rpt2 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 6.3.0 (Raspbian 6.3.0-18+rpi1+deb9u1) 20170516
configuration: --prefix=/usr --extra-version='1~deb9u1+rpt2' --toolchain=hardened --libdir=/usr/lib/arm-linux-gnueabihf --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libebur128 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx-rpi --enable-mmal --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libiec61883 --arch=armhf --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
libavutil 55. 34.101 / 55. 34.101
libavcodec 57. 64.101 / 57. 64.101
libavformat 57. 56.101 / 57. 56.101
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libavresample 3. 1. 0 / 3. 1. 0
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100
[rtsp @ 0xb97620] method DESCRIBE failed: 404 File Not Found, Or In Incorrect Format
rtsp://admin:[email protected]:554/play1.sdp/: Server returned 404 Not Found
-
- Posts: 153
- Joined: Monday 17 February 2014 9:12
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Take snapshot with camera when ringing doorbell
Did you change the variables to your own, IP adres, password...… etc. And if so, did you get the script working after all?
-
- Posts: 153
- Joined: Monday 17 February 2014 9:12
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Take snapshot with camera when ringing doorbell
I did examen this piece of code. I cannot find the part where the ip camera starts to record and give back the result to the variable $retc in this bash file. Should be here I think but it isn't "retc=$?=$?………………………." I will look further…….
-
- Posts: 153
- Joined: Monday 17 February 2014 9:12
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Take snapshot with camera when ringing doorbell
I did not look very well, this is the video catch line ffmpeg -y -i $rtspUrl -r 30 -vcodec copy -an -t $VideoLength $SnapFile, still trying…….
-
- Posts: 153
- Joined: Monday 17 February 2014 9:12
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Take snapshot with camera when ringing doorbell
Do not worry, I came far, but not yet to the end
-
- Posts: 153
- Joined: Monday 17 February 2014 9:12
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Take snapshot with camera when ringing doorbell
I got it working. The code is allright. Use your ip adres of your camera (not domoticz) and right url, see onvif suggestions in the code. So your ip and url should be in place of this piece of code "@192.168.1.22:554/play1.sdp/" Copy code from the net make sure it is not dos characters, so use dos2unix if you get unespected and of file running bash. Do install FFMJPEG library. And do not forget to chmod your bashfile.That s it.
Last edited by tonbor on Tuesday 19 February 2019 12:30, edited 1 time in total.
-
- Posts: 153
- Joined: Monday 17 February 2014 9:12
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Take snapshot with camera when ringing doorbell
#!/bin/sh
now=$(date +"%T")
SnapFile="/var/tmp/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="user" # Username which has access to the RTSP stream
Password="password" # Password for above provided user
rtspUrl="rtsp://user:[email protected]:554/11" # Use https://sourceforge.net/projects/onvifdm/ to find your correct RTSP stream url
echo $rtspUrl
ChatID=yourIDenumber # Telegram chat ID See https://www.domoticz.com/wiki/Installin ... ion_System for setup instructions
TelegramAPIToken="number:verylongstring" # Telegram API token
echo $TelegramAPIToken
filedate=`stat -L --format %Y $SnapFile`
ffmpeg -y -i $rtspUrl -r 30 -vcodec copy -an -t $VideoLength $SnapFile
curl -s -F chat_id=$ChatID -F video="@$SnapFile" -F caption="$now Deurbel klinkt.." https://api.telegram.org/bot$TelegramAPIToken/sendVideo
now=$(date +"%T")
SnapFile="/var/tmp/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="user" # Username which has access to the RTSP stream
Password="password" # Password for above provided user
rtspUrl="rtsp://user:[email protected]:554/11" # Use https://sourceforge.net/projects/onvifdm/ to find your correct RTSP stream url
echo $rtspUrl
ChatID=yourIDenumber # Telegram chat ID See https://www.domoticz.com/wiki/Installin ... ion_System for setup instructions
TelegramAPIToken="number:verylongstring" # Telegram API token
echo $TelegramAPIToken
filedate=`stat -L --format %Y $SnapFile`
ffmpeg -y -i $rtspUrl -r 30 -vcodec copy -an -t $VideoLength $SnapFile
curl -s -F chat_id=$ChatID -F video="@$SnapFile" -F caption="$now Deurbel klinkt.." https://api.telegram.org/bot$TelegramAPIToken/sendVideo
-
- Posts: 153
- Joined: Monday 17 February 2014 9:12
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Take snapshot with camera when ringing doorbell
It Works
- Attachments
-
- 20190222_101340.jpg (76.32 KiB) Viewed 4140 times
Last edited by tonbor on Friday 22 February 2019 10:14, edited 1 time in total.
-
- Posts: 92
- Joined: Monday 18 June 2018 11:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Germany / Netherlands
- Contact:
Re: Take snapshot with camera when ringing doorbell
Fun ... ook even het scriptje als basis gebruikt maar ik krijg het binnen als een (Animated)Gif .... klopt dat?
Who is online
Users browsing this forum: No registered users and 0 guests