Merge branch 'nocona-fix-event-based-recording' into 'nocona-fix-event-based-recording'

Update Event based recording fix

See merge request Shinobi-Systems/Shinobi!388
video-slicer-reencoder
Moe 2022-09-13 01:17:12 +00:00
commit b34ffd6450
3 changed files with 7 additions and 17 deletions

View File

@ -222,9 +222,6 @@ module.exports = (processCwd,config) => {
return s;
}
function roundNearest5(num) {
return Math.round(num / 5) * 5;
}
return {
parseJSON: parseJSON,
stringJSON: stringJSON,
@ -245,6 +242,5 @@ module.exports = (processCwd,config) => {
asyncSetTimeout: asyncSetTimeout,
copyFile: copyFile,
hmsToSeconds,
roundNearest5,
}
}

View File

@ -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 + 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(
@ -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,

View File

@ -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) => {
@ -688,10 +685,10 @@ 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 = 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)