node-red-contrib-hik-media-buffer 1.1.66 → 1.1.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/hik-media-buffer.js +10 -6
- package/package.json +1 -1
package/hik-media-buffer.js
CHANGED
|
@@ -105,6 +105,7 @@ module.exports = function(RED) {
|
|
|
105
105
|
|
|
106
106
|
const heartbeatInterval = setInterval(checkCameras, 30000);
|
|
107
107
|
|
|
108
|
+
// --- STRATEGIA DI DOWNLOAD MULTIMEDIALE 100% JSON + FFMPEG EXTRACTION ---
|
|
108
109
|
// --- STRATEGIA DI DOWNLOAD MULTIMEDIALE 100% JSON + FFMPEG EXTRACTION ---
|
|
109
110
|
async function downloadMedia(evento, channelID) {
|
|
110
111
|
node.warn(`[warn] [hik-media-buffer:test] [TRIGGER] Ricevuto evento. Evento: ${evento}, Canale originario: ${channelID}`);
|
|
@@ -118,19 +119,22 @@ module.exports = function(RED) {
|
|
|
118
119
|
const referenceTime = new Date();
|
|
119
120
|
const timestamp = Math.floor(referenceTime.getTime() / 1000);
|
|
120
121
|
|
|
121
|
-
//
|
|
122
|
+
// FORMATTAZIONE DATA UTC PULITA PER IL JSON DELL'NVR
|
|
122
123
|
const formatJsonDate = (d) => {
|
|
123
124
|
const pad = (num) => String(num).padStart(2, '0');
|
|
124
|
-
return `${d.
|
|
125
|
+
return `${d.getUTCFullYear()}-${pad(d.getUTCMonth()+1)}-${pad(d.getUTCDate())}T${pad(d.getUTCHours())}:${pad(d.getUTCMinutes())}:${pad(d.getUTCSeconds())}Z`;
|
|
125
126
|
};
|
|
126
|
-
|
|
127
|
-
|
|
127
|
+
|
|
128
|
+
// ALLARGHIAMO LA FINESTRA: Cerca da 2 minuti prima dell'evento a 30 secondi dopo
|
|
129
|
+
const startTimeJson = formatJsonDate(new Date(referenceTime.getTime() - (120 * 1000)));
|
|
130
|
+
const endTimeJson = formatJsonDate(new Date(referenceTime.getTime() + (30 * 1000)));
|
|
128
131
|
|
|
129
132
|
node.status({fill:"yellow", shape:"dot", text:`Download Cam ${channelID}...`});
|
|
130
133
|
const nomeCamera = await getCameraName(channelID);
|
|
131
134
|
|
|
132
|
-
|
|
133
|
-
|
|
135
|
+
// PORTIAMO L'ATTESA A 10 SECONDI PER L'HARD DISK
|
|
136
|
+
node.warn(`[warn] [hik-media-buffer:test] Attesa scrittura completa su Hard Disk (10s)...`);
|
|
137
|
+
await new Promise(resolve => setTimeout(resolve, 10000));
|
|
134
138
|
|
|
135
139
|
const baseUrl = `${node.protocol}://${node.host}:${node.port}/ISAPI/ContentMgmt`;
|
|
136
140
|
const evMinuscolo = evento.toLowerCase();
|