Merge branch 'dev' into 'master'
Uulong See merge request Shinobi-Systems/Shinobi!148revert-b25c0d81
commit
d4f9afbfc9
|
@ -1,14 +1,8 @@
|
|||
|
||||
const fs = require('fs')
|
||||
const exec = require('child_process').exec
|
||||
const spawn = require('child_process').spawn
|
||||
process.send = process.send || function () {};
|
||||
// [CTRL] + [C] = exit
|
||||
process.on('SIGINT', function() {
|
||||
if(cameraProcess && cameraProcess.kill)cameraProcess.kill(0)
|
||||
});
|
||||
process.on('exit', (code) => {
|
||||
if(cameraProcess && cameraProcess.kill)cameraProcess.kill(0)
|
||||
});
|
||||
|
||||
if(!process.argv[2] || !process.argv[3]){
|
||||
return writeToStderr('Missing FFMPEG Command String or no command operator')
|
||||
|
@ -29,10 +23,18 @@ var writeToStderr = function(text){
|
|||
// fs.appendFileSync('/home/Shinobi/test.log',text + '\n','utf8')
|
||||
}
|
||||
}
|
||||
|
||||
// [CTRL] + [C] = exit
|
||||
process.on('uncaughtException', function (err) {
|
||||
writeToStderr('Uncaught Exception occured!');
|
||||
writeToStderr(err.stack);
|
||||
});
|
||||
const exitAction = function(){
|
||||
process.kill(-cameraProcess.pid)
|
||||
}
|
||||
process.on('SIGTERM', exitAction);
|
||||
process.on('SIGINT', exitAction);
|
||||
process.on('exit', exitAction);
|
||||
|
||||
for(var i=0; i < stdioPipes; i++){
|
||||
switch(i){
|
||||
|
|
|
@ -139,7 +139,7 @@ module.exports = function(s,config,lang){
|
|||
var temporaryImageFile = streamDir + s.gid(5) + '.jpg'
|
||||
var iconImageFile = streamDir + 'icon.jpg'
|
||||
var ffmpegCmd = s.splitForFFPMEG(`-loglevel warning -re -probesize 1000000 -analyzeduration 1000000 ${inputOptions.join(' ')} -i "${url}" ${outputOptions.join(' ')} -vframes 1 "${temporaryImageFile}"`)
|
||||
fs.writeFileSync(s.group[monitor.ke].rawMonitorConfigurations[monitor.id].sdir + 'snapCmd.txt',JSON.stringify({
|
||||
fs.writeFileSync(s.group[monitor.ke].activeMonitors[monitor.id].sdir + 'snapCmd.txt',JSON.stringify({
|
||||
cmd: ffmpegCmd,
|
||||
temporaryImageFile: temporaryImageFile,
|
||||
iconImageFile: iconImageFile,
|
||||
|
@ -149,7 +149,7 @@ module.exports = function(s,config,lang){
|
|||
var cameraCommandParams = [
|
||||
s.mainDirectory + '/libs/cameraThread/snapshot.js',
|
||||
config.ffmpegDir,
|
||||
s.group[monitor.ke].rawMonitorConfigurations[monitor.id].sdir + 'snapCmd.txt'
|
||||
s.group[monitor.ke].activeMonitors[monitor.id].sdir + 'snapCmd.txt'
|
||||
]
|
||||
var snapProcess = spawn('node',cameraCommandParams,{detached: true})
|
||||
snapProcess.stderr.on('data',function(data){
|
||||
|
@ -766,11 +766,15 @@ module.exports = function(s,config,lang){
|
|||
// }
|
||||
var createCameraFolders = function(e,callback){
|
||||
//set the recording directory
|
||||
var activeMonitor = s.group[e.ke].activeMonitors[e.id]
|
||||
createStreamDirectory(e,function(err,directory){
|
||||
activeMonitor.sdir = directory
|
||||
e.sdir = directory
|
||||
createRecordingDirectory(e,function(err,directory){
|
||||
activeMonitor.dir = directory
|
||||
e.dir = directory
|
||||
createTimelapseDirectory(e,function(err,directory){
|
||||
activeMonitor.dirTimelapse = directory
|
||||
e.dirTimelapse = directory
|
||||
createFileBinDirectory(e,function(err){
|
||||
if(callback)callback()
|
||||
|
@ -1372,7 +1376,7 @@ module.exports = function(s,config,lang){
|
|||
if(activeMonitor.fswatchStream && activeMonitor.fswatchStream.close){
|
||||
activeMonitor.fswatchStream.close()
|
||||
}
|
||||
activeMonitor.fswatchStream = fs.watch(e.sdir, {encoding : 'utf8'}, () => {
|
||||
activeMonitor.fswatchStream = fs.watch(activeMonitor.sdir, {encoding : 'utf8'}, () => {
|
||||
resetStreamCheck(e)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue