From 513e484c07478a5a540f954881e55188072d818b Mon Sep 17 00:00:00 2001 From: Moe Date: Sat, 27 Oct 2018 10:36:06 -0700 Subject: [PATCH 1/4] Traditional Recording with dynamic recording timeout - "Timeout Reset on Next Event" is now an available in the Global Detector Settings section for Traditional recording method --- libs/events.js | 14 ++++++++++---- web/pages/blocks/monitoredit.ejs | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/libs/events.js b/libs/events.js index 8e134d6e..b2dd4948 100644 --- a/libs/events.js +++ b/libs/events.js @@ -328,9 +328,15 @@ module.exports = function(s,config,lang){ }else{ detector_timeout = parseFloat(currentConfig.detector_timeout) } - s.group[d.ke].mon[d.id].eventBasedRecording.timeout = setTimeout(function(){ - s.group[d.ke].mon[d.id].eventBasedRecording.allowEnd=true; - },detector_timeout * 950 * 60) + if(currentConfig.watchdog_reset !== '1' || !s.group[d.ke].mon[d.id].eventBasedRecording.timeout){ + clearTimeout(s.group[d.ke].mon[d.id].eventBasedRecording.timeout) + s.group[d.ke].mon[d.id].eventBasedRecording.timeout = setTimeout(function(){ + s.group[d.ke].mon[d.id].eventBasedRecording.allowEnd = true + s.group[d.ke].mon[d.id].eventBasedRecording.process.stdin.setEncoding('utf8') + s.group[d.ke].mon[d.id].eventBasedRecording.process.stdin.write('q') + delete(s.group[d.ke].mon[d.id].eventBasedRecording.timeout) + },detector_timeout * 1000 * 60) + } if(!s.group[d.ke].mon[d.id].eventBasedRecording.process){ if(!d.auth){ d.auth = s.gid(60) @@ -348,7 +354,7 @@ module.exports = function(s,config,lang){ var filename = s.formattedTime()+'.mp4' s.userLog(d,{type:"Traditional Recording",msg:"Started"}) //-t 00:'+s.timeObject(new Date(detector_timeout * 1000 * 60)).format('mm:ss')+' - s.group[d.ke].mon[d.id].eventBasedRecording.process = spawn(config.ffmpegDir,s.splitForFFPMEG(('-loglevel warning -analyzeduration 1000000 -probesize 1000000 -re -i http://'+config.ip+':'+config.port+'/'+d.auth+'/hls/'+d.ke+'/'+d.id+'/detectorStream.m3u8 -t 00:'+s.timeObject(new Date(detector_timeout * 1000 * 60)).format('mm:ss')+' -c:v copy -strftime 1 "'+s.getVideoDirectory(d.mon) + filename + '"'))) + s.group[d.ke].mon[d.id].eventBasedRecording.process = spawn(config.ffmpegDir,s.splitForFFPMEG(('-loglevel warning -analyzeduration 1000000 -probesize 1000000 -re -i http://'+config.ip+':'+config.port+'/'+d.auth+'/hls/'+d.ke+'/'+d.id+'/detectorStream.m3u8 -c:v copy -strftime 1 "'+s.getVideoDirectory(d.mon) + filename + '"'))) var ffmpegError=''; var error s.group[d.ke].mon[d.id].eventBasedRecording.process.stderr.on('data',function(data){ diff --git a/web/pages/blocks/monitoredit.ejs b/web/pages/blocks/monitoredit.ejs index caadae79..d5f6b0a4 100644 --- a/web/pages/blocks/monitoredit.ejs +++ b/web/pages/blocks/monitoredit.ejs @@ -938,7 +938,7 @@ -
+