node-red-contrib-hik-media-buffer 1.2.0 → 1.2.1
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 +4 -10
- package/package.json +1 -1
package/hik-media-buffer.js
CHANGED
|
@@ -126,12 +126,13 @@ module.exports = function(RED) {
|
|
|
126
126
|
if (nowTime - lastTriggerTime[channelID] < 5000) return;
|
|
127
127
|
lastTriggerTime[channelID] = nowTime;
|
|
128
128
|
|
|
129
|
-
node.status({fill:"yellow", shape:"dot", text:`Attesa (10s)...`});
|
|
130
|
-
await new Promise(resolve => setTimeout(resolve, 13000));
|
|
131
|
-
|
|
132
129
|
const nvrAuth = new AxiosDigestAuth({ username: node.user, password: node.pass });
|
|
133
130
|
const referenceTime = new Date();
|
|
134
131
|
const timestamp = Math.floor(referenceTime.getTime() / 1000);
|
|
132
|
+
|
|
133
|
+
node.status({fill:"yellow", shape:"dot", text:`Attesa (15s)...`});
|
|
134
|
+
await new Promise(resolve => setTimeout(resolve, 15000));
|
|
135
|
+
|
|
135
136
|
|
|
136
137
|
const videoTrackID = (parseInt(channelID) * 100) + 1;
|
|
137
138
|
const nomeCamera = await getCameraName(channelID);
|
|
@@ -211,7 +212,6 @@ module.exports = function(RED) {
|
|
|
211
212
|
const endClip = pulisciDataHik(targetEvento.endTime);
|
|
212
213
|
|
|
213
214
|
playbackURIGrezzo = `rtsp://${node.host}:${node.port}/Streaming/tracks/${videoTrackID}/?starttime=${startClip}&endtime=${endClip}`;
|
|
214
|
-
node.warn(`[HIK SCORCIATOIA] URI Generato: ${playbackURIGrezzo}`);
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
217
|
|
|
@@ -224,9 +224,6 @@ module.exports = function(RED) {
|
|
|
224
224
|
<playbackURI>${playbackURIXml}</playbackURI>
|
|
225
225
|
</downloadRequest>`;
|
|
226
226
|
|
|
227
|
-
node.warn(`[HIK DOWNLOAD] Invio Body XML (Stream Mode):\n${payloadDownload}`);
|
|
228
|
-
|
|
229
|
-
// 🌟 CAMBIAMENTO CHIAVE: Chiediamo un 'stream' invece di 'arraybuffer'
|
|
230
227
|
const resDownVideo = await nvrAuth.request({
|
|
231
228
|
method: 'GET',
|
|
232
229
|
url: `${node.protocol}://${node.host}:${node.port}/ISAPI/ContentMgmt/download`,
|
|
@@ -270,9 +267,6 @@ module.exports = function(RED) {
|
|
|
270
267
|
fs.writeFileSync(rawPath, videoBuffer);
|
|
271
268
|
}
|
|
272
269
|
|
|
273
|
-
const stats = fs.statSync(rawPath);
|
|
274
|
-
node.warn(`[HIK DOWNLOAD OK] File scaricato. Dimensione: ${(stats.size / 1024).toFixed(1)} KB`);
|
|
275
|
-
|
|
276
270
|
await new Promise((resolve) => {
|
|
277
271
|
exec(`ffmpeg -y -i "${rawPath}" -c copy -movflags +faststart "${fixedPath}"`, (err) => {
|
|
278
272
|
if (!err && fs.existsSync(fixedPath)) {
|