From def2224544698d982df0a7ec4ef71bb80b35c737 Mon Sep 17 00:00:00 2001 From: Katie Roberts Date: Mon, 12 Sep 2022 23:23:56 +0000 Subject: [PATCH 1/6] Update libs/basic/utils.js --- libs/basic/utils.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/libs/basic/utils.js b/libs/basic/utils.js index 5b0a1ff0..064f67de 100644 --- a/libs/basic/utils.js +++ b/libs/basic/utils.js @@ -222,9 +222,6 @@ module.exports = (processCwd,config) => { return s; } - function roundNearest5(num) { - return Math.round(num / 5) * 5; - } return { parseJSON: parseJSON, stringJSON: stringJSON, From b2981e2500f429e9deaecfb0235bd917c754a23f Mon Sep 17 00:00:00 2001 From: Katie Roberts Date: Mon, 12 Sep 2022 23:28:08 +0000 Subject: [PATCH 2/6] Update libs/events/utils.js --- libs/events/utils.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/libs/events/utils.js b/libs/events/utils.js index 8b7c7ec3..ec83a237 100644 --- a/libs/events/utils.js +++ b/libs/events/utils.js @@ -28,9 +28,6 @@ module.exports = (s,config,lang,app,io) => { isEven, fetchTimeout, } = require('../basic/utils.js')(process.cwd(),config) - const { - roundNearest5, - } = require('../basic/utils.js')(process.cwd(),config) async function saveImageFromEvent(options,frameBuffer){ const monitorId = options.mid || options.id const groupKey = options.ke @@ -429,7 +426,7 @@ module.exports = (s,config,lang,app,io) => { monitorConfig.mode === 'start' && (monitorDetails.detector_record_method === 'sip' || monitorDetails.detector_record_method === 'hot') ){ - const secondBefore = (roundNearest5(parseInt(monitorDetails.detector_buffer_seconds_before)) || 5) + 1 + const secondBefore = (parseInt(monitorDetails.detector_buffer_seconds_before) || 5) + 1 createEventBasedRecording(d,moment(eventTime).subtract(secondBefore,'seconds').format('YYYY-MM-DDTHH-mm-ss')) } d.currentTime = eventTime @@ -552,8 +549,8 @@ module.exports = (s,config,lang,app,io) => { ){ outputMap += `-map 0:1 ` } - const secondsBefore = roundNearest5(parseInt(monitorDetails.detector_buffer_seconds_before)) || 5 - let LiveStartIndex = parseInt(secondsBefore / 5) + const secondsBefore = parseInt(monitorDetails.detector_buffer_seconds_before) || 5 + let LiveStartIndex = parseInt(secondsBefore / 2) const ffmpegCommand = `-loglevel warning -live_start_index -${LiveStartIndex} -analyzeduration ${analyzeDuration} -probesize ${probeSize} -re -i "${s.dir.streams+d.ke+'/'+d.id}/detectorStream.m3u8" ${outputMap}-movflags faststart+frag_keyframe+empty_moov -fflags +igndts -c:v copy -c:a aac -strict -2 -strftime 1 -y "${s.getVideoDirectory(monitorConfig) + filename}"` s.debugLog(ffmpegCommand) activeMonitor.eventBasedRecording.process = spawn( @@ -575,7 +572,7 @@ module.exports = (s,config,lang,app,io) => { runRecord() return } - const secondBefore = (roundNearest5(parseInt(monitorDetails.detector_buffer_seconds_before)) || 5) + 1 + const secondBefore = (parseInt(monitorDetails.detector_buffer_seconds_before) || 5) + 1 s.insertCompletedVideo(monitorConfig,{ file : filename, endTime: moment(new Date()).subtract(secondBefore,'seconds')._d, From b13297bdfb1e4be12baddd47791e1605b328550a Mon Sep 17 00:00:00 2001 From: Katie Roberts Date: Mon, 12 Sep 2022 23:29:56 +0000 Subject: [PATCH 3/6] Update libs/ffmpeg/builders.js --- libs/ffmpeg/builders.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/libs/ffmpeg/builders.js b/libs/ffmpeg/builders.js index f321b0c8..1cffa87f 100644 --- a/libs/ffmpeg/builders.js +++ b/libs/ffmpeg/builders.js @@ -9,9 +9,6 @@ module.exports = (s,config,lang) => { const { validateDimensions, } = require('./utils.js')(s,config,lang) - const { - roundNearest5, - } = require('../basic/utils.js')(process.cwd(),config) if(!config.outputsWithAudio)config.outputsWithAudio = ['hls','flv','mp4','rtmp']; if(!config.outputsNotCapableOfPresets)config.outputsNotCapableOfPresets = []; const hasCudaEnabled = (monitor) => { @@ -690,8 +687,8 @@ module.exports = (s,config,lang) => { const { videoWidth, videoHeight } = validateDimensions(e.details.event_record_scale_x,e.details.event_record_scale_y) const hlsTime = !isNaN(parseInt(e.details.detector_buffer_hls_time)) ? `${parseInt(e.details.detector_buffer_hls_time)}` : '5' // const hlsListSize = !isNaN(parseInt(e.details.detector_buffer_hls_list_size)) ? `${parseInt(e.details.detector_buffer_hls_list_size)}` : '4' - const secondsBefore = roundNearest5(parseInt(e.details.detector_buffer_seconds_before)) || 5 - let hlsListSize = parseInt(secondsBefore / 5 + 3) + const secondsBefore = parseInt(e.details.detector_buffer_seconds_before) || 5 + let hlsListSize = parseInt(secondsBefore / 2 + 3) // hlsListSize = hlsListSize < 5 ? 5 : hlsListSize; if(inputMap)outputFlags.push(inputMap) if(e.details.cust_sip_record)outputFlags.push(e.details.cust_sip_record) From 2ff97d301dd40ff4dc3e4652bcb84b597aa484da Mon Sep 17 00:00:00 2001 From: Katie Roberts Date: Mon, 12 Sep 2022 23:33:15 +0000 Subject: [PATCH 4/6] Update libs/basic/utils.js --- libs/basic/utils.js | 1 - 1 file changed, 1 deletion(-) diff --git a/libs/basic/utils.js b/libs/basic/utils.js index 064f67de..73bff949 100644 --- a/libs/basic/utils.js +++ b/libs/basic/utils.js @@ -242,6 +242,5 @@ module.exports = (processCwd,config) => { asyncSetTimeout: asyncSetTimeout, copyFile: copyFile, hmsToSeconds, - roundNearest5, } } From 5d727f0ac0180bad35b204d1e52be6678fb37321 Mon Sep 17 00:00:00 2001 From: Katie Roberts Date: Mon, 12 Sep 2022 23:36:24 +0000 Subject: [PATCH 5/6] Update libs/ffmpeg/builders.js --- libs/ffmpeg/builders.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/ffmpeg/builders.js b/libs/ffmpeg/builders.js index 1cffa87f..0e5ff2f7 100644 --- a/libs/ffmpeg/builders.js +++ b/libs/ffmpeg/builders.js @@ -685,7 +685,7 @@ module.exports = (s,config,lang) => { const videoFps = !isNaN(parseFloat(e.details.stream_fps)) && e.details.stream_fps !== '0' ? parseFloat(e.details.stream_fps) : null const inputMap = buildInputMap(e,e.details.input_map_choices.detector_sip_buffer) const { videoWidth, videoHeight } = validateDimensions(e.details.event_record_scale_x,e.details.event_record_scale_y) - const hlsTime = !isNaN(parseInt(e.details.detector_buffer_hls_time)) ? `${parseInt(e.details.detector_buffer_hls_time)}` : '5' + const hlsTime = !isNaN(parseInt(e.details.detector_buffer_hls_time)) ? `${parseInt(e.details.detector_buffer_hls_time)}` : '2' // const hlsListSize = !isNaN(parseInt(e.details.detector_buffer_hls_list_size)) ? `${parseInt(e.details.detector_buffer_hls_list_size)}` : '4' const secondsBefore = parseInt(e.details.detector_buffer_seconds_before) || 5 let hlsListSize = parseInt(secondsBefore / 2 + 3) From 9fb1a602ebe1622e626c14cc7c1ae179dadcbfea Mon Sep 17 00:00:00 2001 From: Katie Roberts Date: Mon, 12 Sep 2022 23:42:05 +0000 Subject: [PATCH 6/6] Update libs/events/utils.js --- libs/events/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/events/utils.js b/libs/events/utils.js index ec83a237..33789eb4 100644 --- a/libs/events/utils.js +++ b/libs/events/utils.js @@ -550,7 +550,7 @@ module.exports = (s,config,lang,app,io) => { outputMap += `-map 0:1 ` } const secondsBefore = parseInt(monitorDetails.detector_buffer_seconds_before) || 5 - let LiveStartIndex = parseInt(secondsBefore / 2) + let LiveStartIndex = parseInt(secondsBefore / 2 + 1) const ffmpegCommand = `-loglevel warning -live_start_index -${LiveStartIndex} -analyzeduration ${analyzeDuration} -probesize ${probeSize} -re -i "${s.dir.streams+d.ke+'/'+d.id}/detectorStream.m3u8" ${outputMap}-movflags faststart+frag_keyframe+empty_moov -fflags +igndts -c:v copy -c:a aac -strict -2 -strftime 1 -y "${s.getVideoDirectory(monitorConfig) + filename}"` s.debugLog(ffmpegCommand) activeMonitor.eventBasedRecording.process = spawn(