Page 1 of 1
[SOLVED]Mocord and Section length for video
Posted: Sun Mar 20, 2016 7:40 pm
by fennec
Hi
I use all my monitor in mocord with Section length 600 s
And when i have a Motion detection i wan't to make video to email
But the video length is 600s ... Is it possible to have video for only motion detection time like modect
Or i must use 2 sames monitor, record and other modect ...
Thanks a lot
Re: Mocord and Section length for video
Posted: Mon Mar 21, 2016 1:02 am
by bbunge
To answer your question, yes, that is one way.
As you are using Mocord why not set up to get an email notification of the motion event. Then you can go back to the ZM console and see if the event is something you want to export. ZM could fill up your email inbox quickly on a busy system!
Re: Mocord and Section length for video
Posted: Mon Mar 21, 2016 7:22 am
by fennec
thanks
But the reel interest of mail with video is to have a archive on cloud very fast and free, yahoo mail 1to
i try to setup this option to alarm for stop the event after alarm
EVENT_CLOSE_MODE alarm
but no option for start new event when alarm start and stop event when alarm stop ...
I try with a script in python with a simple event correlator it's ok when i see alarm start in log of zoneminder i save picture and when i see alarm stop i make video and i send by mail But when i don't have the picture just before alarm like zoneminder
Another question when i have this in log
Mar 21 08:17:02 fennec-server zma[1407]: INF [porte: 93008 - Gone into prealarm state]
Mar 21 08:17:02 fennec-server zma[1407]: INF [porte: 93010 - Gone into alarm state]
Mar 21 08:17:08 fennec-server zma[1407]: INF [porte: 93058 - Gone into alert state]
Mar 21 08:17:10 fennec-server zma[1407]: INF [porte: 93083 - Left alarm state (91648) - 3416(48) images]
Mar 21 08:17:10 fennec-server zma[1407]: INF [porte: 93083 - Closing event 91648, alarm end, section truncated]
How can i do for know where is save picture on my disk ? what folder ?
Thanks
Re: [SOLVED]Mocord and Section length for video
Posted: Tue Mar 22, 2016 3:41 am
by fennec
Ok i make a little script
If you wan't to use mocord and you wan't a email with video on alert but just alert frame you can use this
first you must put
EVENT_CLOSE_MODE alarm
For close event after each alarm
install ffmpeg of course and sendemail
you make a file like
nano videozm.py
you must change
ip=""
event="/usr/share/zoneminder/www/events"
username=""
password=""
emailfrom=""
emailto=""
smtp=""
PreEventImageCount=25
PostEventImageCount=25
Code: Select all
#!/usr/bin/python
import subprocess
import urllib
import sys
import time
import os
import urllib2
import glob
import json
ip=""
event="/usr/share/zoneminder/www/events"
username=""
password=""
emailfrom=""
emailto=""
smtp=""
PreEventImageCount=25
PostEventImageCount=25
argu=[]
for arg in sys.argv:
argu.append(arg)
events=argu[1]
eventfolder=argu[1].split("/")
camdico={}
cam=os.listdir(event)
for c in cam:
try:
b=int(c)
except:
link=os.readlink(event+"/"+c)
camdico[link]=c
objet="Alarm_"+camdico[eventfolder[6]]+"_"+eventfolder[9]+"-"+eventfolder[8]+"_"+eventfolder[10]+"H"+eventfolder[11]
jpg=glob.glob(events+'/*.jpg')
os.chdir(events)
monit=eventfolder[6]
date="20"+eventfolder[7]+"-"+eventfolder[8]+"-"+eventfolder[9]
heur=eventfolder[10]+":"+eventfolder[11]+":"+eventfolder[12]
if username!="" and password!="":
url1="http://"+ip+"/zm/index.php?username="+username+"&password="+password+"&action=login&view=console"
req1 = urllib2.Request(url1)
response = urllib2.urlopen(req1)
cookie = response.headers.get('Set-Cookie')
url=urllib2.Request('http://'+ip+'/zm/api/events/index/MonitorId:'+monit+'/StartTime%20=:'+date+'%20'+heur+'.json')
url.add_header('cookie', cookie)
url=urllib2.urlopen(url)
else:
url=urllib2.Request('http://'+ip+'/zm/api/events/index/MonitorId:'+monit+'/StartTime%20=:'+date+'%20'+heur+'.json')
url.add_header('cookie', cookie)
url=urllib2.urlopen(url)
url=json.loads(url.read())
alarmeframe=url['events'][0]['Event']['AlarmFrames']
frame=url['events'][0]['Event']['Frames']
ids=url['events'][0]['Event']['Id']
debutalarme=int(frame)-PostEventImageCount-int(alarmeframe)-PreEventImageCount
tim=str(time.time())
subprocess.call(["/usr/bin/ffmpeg", "-y", "-start_number",str(debutalarme),"-i","%5d-capture.jpg","-vcodec","libx264", "-profile:v", "baseline", "-preset", "medium", "-b:v", "250k", "-maxrate", "250k", "-bufsize", "500k", "-vf", "scale=-1:360", "-threads", "2", tim+".mp4"])
heure=time.strftime('%Y-%m-%d_%H:%M')
subprocess.call(["sendemail", "-u", objet, "-f", emailfrom, "-t", emailto, "-m", heure, "-a", tim+".mp4", "-s", smtp])
after make file
chmod 755 videozm.py
and you can make filter with execute command videozm.py
And now when you have motion detection in mocord you received a video with just motion detection not all event length