node-red-contrib-hik-media-buffer 1.1.104 → 1.1.105

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.
@@ -103,6 +103,7 @@ module.exports = function(RED) {
103
103
  const pad = (num) => String(num).padStart(2, '0');
104
104
  const timeGoBack = new Date(referenceTime.getTime() - (10 * 1000)); // iniziamo 10 secondi prima dello scatto
105
105
 
106
+ // Generiamo il timestamp con T e Z MAIUSCOLE e SENZA due punti, esattamente come piace a Hikvision
106
107
  const year = timeGoBack.getUTCFullYear();
107
108
  const month = pad(timeGoBack.getUTCMonth() + 1);
108
109
  const day = pad(timeGoBack.getUTCDate());
@@ -110,11 +111,10 @@ module.exports = function(RED) {
110
111
  const minutes = pad(timeGoBack.getUTCMinutes());
111
112
  const seconds = pad(timeGoBack.getUTCSeconds());
112
113
 
114
+ // Output pulito: 20260624T085731Z
113
115
  const rtspTimestamp = `${year}${month}${day}T${hours}${minutes}${seconds}Z`;
114
116
 
115
117
  node.status({fill:"yellow", shape:"dot", text:`Estrazione media Cam ${channelID}...`});
116
-
117
- // Aspettiamo 5 secondi per dare all'NVR il tempo di scrivere i frame correnti sull'hard disk
118
118
  await new Promise(resolve => setTimeout(resolve, 5000));
119
119
 
120
120
  let output = {
@@ -126,16 +126,15 @@ module.exports = function(RED) {
126
126
  let fileDaCancellare = [];
127
127
 
128
128
  try {
129
- const trackId = parseInt(channelID) * 100 + 1; // Es: Canale 2 -> traccia 201
129
+ const trackId = parseInt(channelID) * 100 + 1;
130
130
  const fixedPath = path.join(baseStorage, `hik_v_${channelID}_${timestamp}.mp4`);
131
131
  const fullImgPath = path.join(baseStorage, `img_${timestamp}.jpg`);
132
132
 
133
- // Costruiamo l'URL RTSP di Playback diretto inserendo le credenziali e il timestamp di inizio
134
133
  const archiveRtspUrl = `rtsp://${node.user}:${node.pass}@${node.host}:554/Streaming/tracks/${trackId}/?starttime=${rtspTimestamp}`;
135
- node.warn(`[DEBUG RTSP] Mi collego all'archivio su traccia ${trackId} dall'orario: ${rtspTimestamp}`);
134
+ node.warn(`[DEBUG RTSP] Chiamata finale: ${archiveRtspUrl}`);
136
135
 
137
- // --- 1. CATTURA VIDEO DIRECT (Registriamo 15 secondi di archivio) ---
138
- const ffmpegRtspCmd = `ffmpeg -y -rtsp_transport tcp -i "${archiveRtspUrl}" -t 15 -c:v copy -c:a aac -movflags +faststart "${fixedPath}"`;
136
+ // Via il flag -rtsp_transport tcp per sbloccare il timeout UDP
137
+ const ffmpegRtspCmd = `ffmpeg -y -i "${archiveRtspUrl}" -t 15 -c:v copy -c:a aac -movflags +faststart "${fixedPath}"`;
139
138
 
140
139
  await new Promise((resolve) => {
141
140
  exec(ffmpegRtspCmd, { timeout: 25000 }, (err) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-hik-media-buffer",
3
- "version": "1.1.104",
3
+ "version": "1.1.105",
4
4
  "description": "Ottiene buffer video e immagine da camere Hikvision via ISAPI",
5
5
  "keywords": [
6
6
  "node-red",