Take snapshot with camera when ringing doorbell

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Prutsium
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

Post by Prutsium »

Prutsium wrote: Wednesday 20 February 2019 17:23 Fun ... ook even het scriptje als basis gebruikt maar ik krijg het binnen als een (Animated)Gif .... klopt dat?
Lol me stupid ... wrong language mode in Brain.

Anyway got script also running but strange enough i get the video as an animated gif is that right?
wastaal
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

Post by wastaal »

wastaal wrote: Wednesday 20 February 2019 17:25
tonbor wrote: Wednesday 20 February 2019 15:56It :D Works
Super! Unfortunately no luck here. Still same errors. I will look into this later again.
Got it working! Thanks a lot for your help. The video is animated gif over here as well. But that works for me.
tonbor
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

Post by tonbor »

Nope
Attachments
Screenshot_20190221-132506_Total Commander.jpg
Screenshot_20190221-132506_Total Commander.jpg (244.86 KiB) Viewed 2101 times
Roland87
Posts: 3
Joined: Monday 18 March 2019 10:58
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Take snapshot with camera when ringing doorbell

Post by Roland87 »

Hi!
I don't get the video on my phone just the message arrives.
nonetheless the video is on the hdd
Attachments
IMG_0436.PNG
IMG_0436.PNG (382.43 KiB) Viewed 2028 times
tonbor
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

Post by tonbor »

Just starting the script with putty do you get any error messages?
Roland87
Posts: 3
Joined: Monday 18 March 2019 10:58
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Take snapshot with camera when ringing doorbell

Post by Roland87 »

The command runs, no error message.
Last edited by Roland87 on Wednesday 20 March 2019 10:14, edited 1 time in total.
Roland87
Posts: 3
Joined: Monday 18 March 2019 10:58
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Take snapshot with camera when ringing doorbell

Post by Roland87 »

The Ubuntu telegram plays the video you are sending, iphone still not, broblem on the phone. Any idea?
tonbor
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

Post by tonbor »

If I was you a would delete the logging on this site. IPhone/Apple is diffecult to load foreign data, that is all I can think off.
AllesVanZelf
Posts: 265
Joined: Monday 05 February 2018 8:42
Target OS: Raspberry Pi / ODroid
Domoticz version: 12467
Location: Netherlands, near Haarlem
Contact:

Re: Take snapshot with camera when ringing doorbell

Post by AllesVanZelf »

Just a snapshot (picture) is send in Blockly - under devices - camera - "send camera snapshot xxxx with subject XXX after xx seconds".
Domoticz 2020.1 (12230) on Raspberry Pi 3B with Raspian Buster. Besides Domoticz, Rpi is running Pi-Hole.
xury
Posts: 48
Joined: Monday 10 December 2018 23:32
Target OS: Linux
Domoticz version:
Location: Poland
Contact:

Re: Take snapshot with camera when ringing doorbell

Post by xury »

If someone want to execute this awesome script from dzvents:

Code: Select all

return {
	on = {
		devices = {
			'Dzwonek'
		}
	},
	execute = function(domoticz, device)
		if (domoticz.devices('Dzwonek').nValue == 3) then
		    os.execute('/home/pi/domoticz/scripts/doorbell.sh')
		    end
	end
}
Of course first you have tu put the doorbell.sh script in the right path i.e /home/pi/domoticz/scripts
Atis
Posts: 37
Joined: Monday 30 March 2020 7:30
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Take snapshot with camera when ringing doorbell

Post by Atis »

tonbor wrote: Wednesday 20 February 2019 15:56It :D Works
Hello, I try your code but I have many errors:

videokuldo.sh: line 3: $'\r': command not found
videokuldo.sh: line 10: $'\r': command not found
rtsp://*****:*********@192.168.10.9:554/ISAPI/Streaming/channels/101
746563875:AAHdcYfA
stat: cannot stat ‘/var/tmp/frontdoorcam.mp4’: No such file or directory
ffmpeg version 2.7.1 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.9.3 (crosstool-NG 1.20.0) 20150311 (prerelease)
configuration: --prefix=/usr --incdir='${prefix}/include/ffmpeg' --arch=i686 --target-os=linux --cross-prefix=/usr/local/x86_64-pc-linux-gnu/bin/x86_64-pc-linux-gnu- --enable-cross-compile --enable-optimizations --enable-pic --enable-gpl --enable-shared --disable-static --enable-version3 --enable-nonfree --enable-libfaac --enable-encoders --enable-pthreads --disable-bzlib --disable-protocol=rtp --disable-muxer=image2 --disable-muxer=image2pipe --disable-swscale-alpha --disable-ffserver --disable-ffplay --disable-devices --disable-bzlib --disable-altivec --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libmp3lame --disable-vaapi --disable-decoder=amrnb --disable-decoder=ac3 --disable-decoder=ac3_fixed --disable-encoder=zmbv --disable-encoder=dca --disable-encoder=ac3 --disable-encoder=ac3_fixed --disable-encoder=eac3 --disable-decoder=dca --disable-decoder=eac3 --disable-decoder=truehd --cc=/usr/local/x86_64-pc-linux-gnu/bin/x86_64-pc-linux-gnu-ccache-gcc --enable-yasm --enable-libx264 --enable-encoder=libx264
libavutil 54. 27.100 / 54. 27.100
libavcodec 56. 41.100 / 56. 41.100
libavformat 56. 36.100 / 56. 36.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 16.101 / 5. 16.101
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.100 / 1. 2.100
libpostproc 53. 3.100 / 53. 3.100
rtsp://**********:**********@192.168.10.9:554/ISAPI/Streaming/channels/101: Protocol not found
curl: no URL specified!
curl: try 'curl --help' for more information
: No such file or directoryps://api.telegram.org/bot746563875:AAHdc/sendVideo
videokuldo.sh: line 19: $'\r': command not found
videokuldo.sh: line 20: $'else\r': command not found
There was another try within 10 seconds:
videokuldo.sh: line 22: $'fi\r': command not found

I hope you can help me. RTSP url good, because VLC can play.

The code:

#!/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="admin" # Username which has access to the RTSP stream
Password="*********" # Password for above provided user
rtspUrl="rtsp://admin:***************@192.168.10.9:554/ISAPI/Streaming/channels/101" # Use https://sourceforge.net/projects/onvifdm/ to find your correct RTSP stream url

echo $rtspUrl
ChatID=-10011 # Telegram chat ID See https://www.domoticz.com/wiki/Installin ... ion_System for setup instructions
TelegramAPIToken="746563875:AAHdcYfA1s" # 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

else
echo There was another try within $WaitTime seconds: $sec
fi
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: Take snapshot with camera when ringing doorbell

Post by EddyG »

It seems that you used a Windows program to edit the "videokuldo.sh" file.
Use an editor which can save the file with only unix line endings, like Notepad2.
Then try again.
Atis
Posts: 37
Joined: Monday 30 March 2020 7:30
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Take snapshot with camera when ringing doorbell

Post by Atis »

EddyG wrote: Friday 20 November 2020 18:59 It seems that you used a Windows program to edit the "videokuldo.sh" file.
Use an editor which can save the file with only unix line endings, like Notepad2.
Then try again.
Not good :(

rtsp://admin:********[email protected]:554/ISAPI/Streaming/channels/101
746563875:AAHdcYfA1
stat: cannot stat ‘/var/tmp/frontdoorcam.mp4’: No such file or directory
ffmpeg version 2.7.1 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.9.3 (crosstool-NG 1.20.0) 20150311 (prerelease)
configuration: --prefix=/usr --incdir='${prefix}/include/ffmpeg' --arch=i686 - -target-os=linux --cross-prefix=/usr/local/x86_64-pc-linux-gnu/bin/x86_64-pc-lin ux-gnu- --enable-cross-compile --enable-optimizations --enable-pic --enable-gpl --enable-shared --disable-static --enable-version3 --enable-nonfree --enable-lib faac --enable-encoders --enable-pthreads --disable-bzlib --disable-protocol=rtp --disable-muxer=image2 --disable-muxer=image2pipe --disable-swscale-alpha --disa ble-ffserver --disable-ffplay --disable-devices --disable-bzlib --disable-altive c --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libmp3lame --di sable-vaapi --disable-decoder=amrnb --disable-decoder=ac3 --disable-decoder=ac3_ fixed --disable-encoder=zmbv --disable-encoder=dca --disable-encoder=ac3 --disab le-encoder=ac3_fixed --disable-encoder=eac3 --disable-decoder=dca --disable-deco der=eac3 --disable-decoder=truehd --cc=/usr/local/x86_64-pc-linux-gnu/bin/x86_64 -pc-linux-gnu-ccache-gcc --enable-yasm --enable-libx264 --enable-encoder=libx264
libavutil 54. 27.100 / 54. 27.100
libavcodec 56. 41.100 / 56. 41.100
libavformat 56. 36.100 / 56. 36.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 16.101 / 5. 16.101
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.100 / 1. 2.100
libpostproc 53. 3.100 / 53. 3.100
rtsp://admin:*******@192.168.10.9:554/ISAPI/Streaming/channels/101: Protocol not found
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: Take snapshot with camera when ringing doorbell

Post by EddyG »

First error;

Code: Select all

stat: cannot stat ‘/var/tmp/frontdoorcam.mp4’: No such file or directory
Can be ignored, because it is just bad programming.

Second error:

Code: Select all

rtsp://admin:*******@192.168.10.9:554/ISAPI/Streaming/channels/101: Protocol not found
states that ffmpeg does not get the 'right' stream or that a parameter is missing.
You should google on 'ffmpeg Protocol not found'
You get a lot of suggestions of parameters. By try and error you have to find the right one(s).
Luckely for me my cam worked at the first try.
Atis
Posts: 37
Joined: Monday 30 March 2020 7:30
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Take snapshot with camera when ringing doorbell

Post by Atis »

EddyG wrote: Saturday 21 November 2020 9:53 First error;

Code: Select all

stat: cannot stat ‘/var/tmp/frontdoorcam.mp4’: No such file or directory
Can be ignored, because it is just bad programming.

Second error:

Code: Select all

rtsp://admin:*******@192.168.10.9:554/ISAPI/Streaming/channels/101: Protocol not found
states that ffmpeg does not get the 'right' stream or that a parameter is missing.
You should google on 'ffmpeg Protocol not found'
You get a lot of suggestions of parameters. By try and error you have to find the right one(s).
Luckely for me my cam worked at the first try.
Thanks one more error left, but I can not find the solutions.
ffmpeg -y -rtsp_transport tcp -i $rtspUrl -r 30 -vcodec copy -an -t $VideoLength $SnapFile

error:
Metadata:
title : Media Presentation
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: h264 (Main), yuvj420p(pc, bt709, progressive), 2560x1440, 10 fps, 10 tbr, 90k tbn, 20 tbc
Stream #0:1: Audio: pcm_mulaw, 8000 Hz, mono, s16, 64 kb/s
[NULL @ 0x1122e80] Unable to find a suitable output format for '/var/tmp/frontdorcam'.mp4
: Invalid argumentcam.mp4
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: Take snapshot with camera when ringing doorbell

Post by EddyG »

Where does the '-rtsp_transport tcp' parameter come from, try without.
Do you have right for '/var/tmp' ??
Try start the script with

Code: Select all

sudo <scriptname>
Is the var $SnapFile correct defined?
Atis
Posts: 37
Joined: Monday 30 March 2020 7:30
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Take snapshot with camera when ringing doorbell

Post by Atis »

EddyG wrote: Sunday 22 November 2020 11:03 Where does the '-rtsp_transport tcp' parameter come from, try without.
Do you have right for '/var/tmp' ??
Try start the script with

Code: Select all

sudo <scriptname>
Is the var $SnapFile correct defined?
I need this parameter.
ffmpeg -y -use_wallclock_as_timestamps 1 -rtsp_transport tcp -i $rtspUrl -r 30 -codec:V copy -an -t $VideoLength -f mp4 $SnapFile

This command runing whitout problem. File creating, BUT I can not read the file. Can not copy, read etc. With dir command view camera1.mp4?. I dont know what is the "?" sign. The file rights ok.

Metadata:
title : Media Presentation
Duration: N/A, start: 1606062318.953167, bitrate: N/A
Stream #0:0: Video: h264 (Main), yuvj420p(pc, bt709, progressive), 2560x1440, 10 fps, 10 tbr, 90k tbn, 20 tbc
Stream #0:1: Audio: pcm_mulaw, 8000 Hz, mono, s16, 64 kb/s
':tput #0, mp4, to 'camera1.mp4
Metadata:
title : Media Presentation
encoder : Lavf58.45.100
Stream #0:0: Video: h264 (Main) (avc1 / 0x31637661), yuvj420p(pc, bt709, progressive), 2560x1440, q=2-31, 10 fps, 10 tbr, 15360 tbn, 30 tbc
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame= 51 fps= 17 q=-1.0 Lsize= 1213kB time=00:00:04.99 bitrate=1991.4kbits/s speed=1.67x
video:1212kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.118550%
curl: (26) couldn't open file "camera1.mp4"
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: Take snapshot with camera when ringing doorbell

Post by EddyG »

Did you try with the simplest version? And did you try to start the script with sudo?

Code: Select all

#!/bin/sh
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="AAA"         # Username which has access to the RTSP stream
Password="BBB"   # Password for above provided user
rtspUrl="rtsp://$User:[email protected]:yyy/videoMain"
ChatID="CCC"    # Telegram chat ID
TelegramAPIToken="DDD"    # Telegram API token

ffmpeg -y -i $rtspUrl -r 30 -vcodec copy -an -t $VideoLength $SnapFile
curl -s -F chat_id=$ChatID -F video="@$SnapFile" -F caption="Doorbell ringing.." https://api.telegram.org/bot$TelegramAPIToken/sendVideo

Atis
Posts: 37
Joined: Monday 30 March 2020 7:30
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Take snapshot with camera when ringing doorbell

Post by Atis »

EddyG wrote: Sunday 22 November 2020 18:56 Did you try with the simplest version? And did you try to start the script with sudo?

Code: Select all

#!/bin/sh
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="AAA"         # Username which has access to the RTSP stream
Password="BBB"   # Password for above provided user
rtspUrl="rtsp://$User:[email protected]:yyy/videoMain"
ChatID="CCC"    # Telegram chat ID
TelegramAPIToken="DDD"    # Telegram API token

ffmpeg -y -i $rtspUrl -r 30 -vcodec copy -an -t $VideoLength $SnapFile
curl -s -F chat_id=$ChatID -F video="@$SnapFile" -F caption="Doorbell ringing.." https://api.telegram.org/bot$TelegramAPIToken/sendVideo

Guessed Channel Layout for Input Stream #0.1 : mono
Input #0, rtsp, from 'rtsp://admin:********@192.168.10.9:554/ISAPI/Streaming/channels/101':
Metadata:
title : Media Presentation
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: h264 (Main), yuvj420p(pc, bt709, progressive), 2560x1440, 10 fps, 10 tbr, 90k tbn, 20 tbc
Stream #0:1: Audio: pcm_mulaw, 8000 Hz, mono, s16, 64 kb/s
'NULL @ 0xd8bdc0] Unable to find a suitable output format for 'camera2.mp4
: Invalid argument

sudo video.sh
Command not found
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: Take snapshot with camera when ringing doorbell

Post by EddyG »

It's clear that your version of ffmpeg needs the output format as a parameter, so just add that one.
Evaluate the next possible error and add possible next parameter.
In Linux the sudo command has to be:

Code: Select all

sudo <full path>/video.sh
or if you are already in that path

Code: Select all

sudo ./video.sh
Then sudo will find your script.
B.t.w. What is your Linux version and what is your ffmpeg version.

Code: Select all

uname -a
ffmpeg -version
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest