Pack a .gif from camera snapshot

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

hoeby
Posts: 531
Joined: Saturday 02 June 2018 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.1
Location: Echt, Netherlands
Contact:

Re: Pack a .gif from camera snapshot

Post by hoeby »

felix63 wrote: Monday 04 March 2019 16:08 Wouldn't this be simpler?
yes for sure, that's simpler.
i made a mistake that it wouldn't work. i wrote "Device" instead of "device".
with the http i could test with my browser and search the problem by testing each part. after i found the problem, i didn't changed it. you are right, need to change it and make of simpler.

Do you know other ways, by changing the script and not use aftersec, so 0,5sec would be possible?
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Pack a .gif from camera snapshot

Post by emme »

the frameldelay is a millisencond value... you can adjust it as you want
The most dangerous phrase in any language is:
"We always done this way"
hoeby
Posts: 531
Joined: Saturday 02 June 2018 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.1
Location: Echt, Netherlands
Contact:

Re: Pack a .gif from camera snapshot

Post by hoeby »

emme wrote: Monday 04 March 2019 17:48 the frameldelay is a millisencond value... you can adjust it as you want
But frameDelay doesn't do something on interval-time.
frameDelay is only the time between showing the images in de .gif file.

But i would like to make pictures every 0,5 sec.
The .gif movie will be smoother. Now a person jumps from left to right in de .gif picture.
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
hoeby
Posts: 531
Joined: Saturday 02 June 2018 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.1
Location: Echt, Netherlands
Contact:

Re: Pack a .gif from camera snapshot

Post by hoeby »

Made a very quick and very dirty solution. To take image in less than 1 second interval
Like said, it is dirty. I don't have the knowledge to make a nice .sh without writting every line separate. But it works


I removed 3 line in the DZvents script, the next lines are removed.

Code: Select all

            filler = string.rep('0',frameDigit - string.len(varTrig.value))
            os.execute('wget -O "'..filePath..camName..filler..varTrig.value..'.jpg" "'..domoReq..'"')
            varTrig.set(varTrig.value - 1).afterSec(varInterval)
This is replaced by one line

Code: Select all

os.execute('/home/pi/domoticz/scripts/CameravoordeurGIFmake.sh')
And an extra line is remove when variable is 0, this one is removed

Code: Select all

os.execute('rm '..filePath..camName..'*.*')
replaced by

Code: Select all

os.execute('/home/pi/domoticz/scripts/CameravoordeurGIFremove.sh')

Then i made 2 .sh files.
One which makes 10 pictures with 0.5sec interval

Code: Select all

#!/bin/sh
SnapFile001="/home/pi/dzGif/frame0001.jpg"
SnapFile002="/home/pi/dzGif/frame0002.jpg"
SnapFile003="/home/pi/dzGif/frame0003.jpg"
SnapFile004="/home/pi/dzGif/frame0004.jpg"
SnapFile005="/home/pi/dzGif/frame0005.jpg"
SnapFile006="/home/pi/dzGif/frame0006.jpg"
SnapFile007="/home/pi/dzGif/frame0007.jpg"
SnapFile008="/home/pi/dzGif/frame0008.jpg"
SnapFile009="/home/pi/dzGif/frame0009.jpg"
SnapFile010="/home/pi/dzGif/frame0010.jpg"
# Get snapshot via Domoticz server
wget -O $SnapFile001 "http://xxx.xxx.xxx.xxx/jpg/1/image.jpg"
sleep 0.500
wget -O $SnapFile002 "http://xxx.xxx.xxx.xxx/jpg/1/image.jpg"
sleep 0.500
wget -O $SnapFile003 "http://xxx.xxx.xxx.xxx/jpg/1/image.jpg"
sleep 0.500
wget -O $SnapFile004 "http://xxx.xxx.xxx.xxx/jpg/1/image.jpg"
sleep 0.500
wget -O $SnapFile005 "http://xxx.xxx.xxx.xxx/jpg/1/image.jpg"
sleep 0.500
wget -O $SnapFile006 "http://xxx.xxx.xxx.xxx/jpg/1/image.jpg"
sleep 0.500
wget -O $SnapFile007 "http://xxx.xxx.xxx.xxx/jpg/1/image.jpg"
sleep 0.500
wget -O $SnapFile008 "http://xxx.xxx.xxx.xxx/jpg/1/image.jpg"
sleep 0.500
wget -O $SnapFile009 "http://xxx.xxx.xxx.xxx/jpg/1/image.jpg"
sleep 0.500
wget -O $SnapFile010 "http://xxx.xxx.xxx.xxx/jpg/1/image.jpg"
sleep 0.500
# Set variable to 0
curl -g 'http://xxx.xxx.xxx.xxx:xxxx/json.htm?type=command&param=updateuservariable&vname=TELEGRAM_Frames&vtype=0&vvalue=0'
And a second one, which removes the images when the .gif is made and send

Code: Select all

#!/bin/sh
SnapFile001="/home/pi/dzGif/frame0001.jpg"
SnapFile002="/home/pi/dzGif/frame0002.jpg"
SnapFile003="/home/pi/dzGif/frame0003.jpg"
SnapFile004="/home/pi/dzGif/frame0004.jpg"
SnapFile005="/home/pi/dzGif/frame0005.jpg"
SnapFile006="/home/pi/dzGif/frame0006.jpg"
SnapFile007="/home/pi/dzGif/frame0007.jpg"
SnapFile008="/home/pi/dzGif/frame0008.jpg"
SnapFile009="/home/pi/dzGif/frame0009.jpg"
SnapFile010="/home/pi/dzGif/frame0010.jpg"
SnapFile011="/home/pi/dzGif/frame.gif"
# Remove Image
 /bin/rm $SnapFile001
 /bin/rm $SnapFile002
 /bin/rm $SnapFile003
 /bin/rm $SnapFile004
 /bin/rm $SnapFile005
 /bin/rm $SnapFile006
 /bin/rm $SnapFile007
 /bin/rm $SnapFile008
 /bin/rm $SnapFile009
 /bin/rm $SnapFile010
 /bin/rm $SnapFile011
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Pack a .gif from camera snapshot

Post by emme »

my fault...
time interval is a global variable called 'TELEGRAM_Inverval'
that can be 0.5 either
The most dangerous phrase in any language is:
"We always done this way"
hoeby
Posts: 531
Joined: Saturday 02 June 2018 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.1
Location: Echt, Netherlands
Contact:

Re: Pack a .gif from camera snapshot

Post by hoeby »

i tried to set interval to 0.5, but that's not allowed in a integer variabele.

or is that not what you are saying, if so, then i don't understand it
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Pack a .gif from camera snapshot

Post by emme »

no, you're right... it accept only integer... mmmh willing to ask for an update on this....
unless I'll try to change somehow the way how the snapshot is handled (like moving to a bash script, but I don't like it very much....)
The most dangerous phrase in any language is:
"We always done this way"
hoeby
Posts: 531
Joined: Saturday 02 June 2018 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.1
Location: Echt, Netherlands
Contact:

Re: Pack a .gif from camera snapshot

Post by hoeby »

i also don't like it, that i used a bash script.
But that was the quick and dirty option i thoughed about, to use something less than 1 second.
I don't mean that bash script is dirty, but the way i used it is dirty.

I also will think about it. Maybe we can find a solution
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
hoeby
Posts: 531
Joined: Saturday 02 June 2018 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.1
Location: Echt, Netherlands
Contact:

Re: Pack a .gif from camera snapshot

Post by hoeby »

Maybe i found a little option.

the normal "wget" command looks like

Code: Select all

os.execute('wget -O "'..filePath..camName..filler..varTrig.value..'.jpg" "'..domoReq..'"')
but when addind a row, undernead the first "wget" command row, with the command-details:

Code: Select all

os.execute('wget -w 0.5 -O "'..filePath..camName..filler..varTrig.value..'.jpg" "'..domoReq..'"')
This should delay the wget by 0.5 seconds.
This only sets an other problem. Both files get the same name, because the varTrig. value isn't updatet.
i was testing with a hack Xiaomi camera. But looks like this camera is to slow (network wise), because it takes 3 seconds for 1 picture. Need to test with my other network camera, which response faster. But not tonight
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Pack a .gif from camera snapshot

Post by emme »

mmmh... that looks wired! :P

you can handle all the frames on the same script... but you would get a warning in the log the script is taking more than 10secs to execute.

That would be not a big deal since it is handled, but my concerns are about the way how domoticz would interact with other scripts... if they would runs or they will wait for this to end.
The most dangerous phrase in any language is:
"We always done this way"
hoeby
Posts: 531
Joined: Saturday 02 June 2018 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.1
Location: Echt, Netherlands
Contact:

Re: Pack a .gif from camera snapshot

Post by hoeby »

Had a thouged about it.
I think, if the wget delay works, that it could be working if there is made an extra variable.
Instead of using varTrig.value to give a number to the .jpg. The new variable will give a number to the .jpg
Every time when an image is made, the new variable will be +1. Only in the convert line, the -reverse need to be removed.
Maybe I will try it this evening.

But still the problem will be the .aftersec command.
I prefer to have a local function, to fill in the wait time. But don't know how do deal with the .aftersec to get the variable updatet.
Still something to think about
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
hoeby
Posts: 531
Joined: Saturday 02 June 2018 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.1
Location: Echt, Netherlands
Contact:

Re: Pack a .gif from camera snapshot

Post by hoeby »

I modified the script, but testing isn't possible.

On 5 march there was a Telegram update, with autoplay of videos.
Since then the GIF autoplay is in a hurry. The delay time in the GIF file is gone, it puts all image together in 1 or 2 seconds (depends on how many images you have taken).
GIF files which worked nicely last week, are now also in a hurry. So it is something which has to do with telegram and not the DZvents script

Do you guys also have this problem?
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Pack a .gif from camera snapshot

Post by emme »

my still works as wanted....
send them as documents, not as images or videos
The most dangerous phrase in any language is:
"We always done this way"
hoeby
Posts: 531
Joined: Saturday 02 June 2018 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.1
Location: Echt, Netherlands
Contact:

Re: Pack a .gif from camera snapshot

Post by hoeby »

this is my sending code
setup as document. will test with an other phone. when looking on telegram.web on my pc, the gif works fine. maybe a phone setting.

Code: Select all

os.execute('curl -s -X POST "https://api.telegram.org/bot'..teleTok..'/sendDocument?chat_id='..destId..'" -F document="@'..filePath..camName..'.gif"')
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest