Skip to content

Commit

Permalink
Added small improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanBluefox committed Dec 19, 2023
1 parent 71b608d commit 63f6f9c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ To add a new camera, you must create a Pull Request on GitHub with the following
-->

## Changelog
### 2.0.4 (2023-12-19)
### **WORK IN PROGRESS**
* (bluefox) Minimal supported NodeJS version is 18
* (bluefox) Corrected widgets

Expand Down
10 changes: 10 additions & 0 deletions cameras/rtsp.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ function init(adapter, cam) {

cam.decodedPassword = cam.password ? adapter.decrypt(cam.password) : '';
cam.timeout = parseInt(cam.timeout || adapter.config.defaultTimeout, 10) || 10000;
cam.lastFrame = null;

return Promise.resolve();
}
Expand All @@ -134,6 +135,13 @@ function process(adapter, cam) {

adapter.log.debug(`Requesting snapshot from ${cam.ip}...`);

if (streamings[cam.name] && streamings[cam.name].lastBase64Frame) {
return Promise.resolve({
body: Buffer.from(streamings[cam.name].lastBase64Frame, 'base64'),
contentType: 'image/jpeg',
});
}

const outputFileName = path.normalize(`${adapter.config.tempPath}/${cam.ip.replace(/[.:]/g, '_')}.jpg`);
cam.runningRequest = getRtspSnapshot(adapter.config.ffmpegPath, cam, outputFileName, adapter)
.then(async body => {
Expand Down Expand Up @@ -264,6 +272,8 @@ async function webStreaming(adapter, camera, options, fromState) {
if (!lastFrame || Date.now() - lastFrame > 300) {
lastFrame = Date.now();
console.log(`frame ${frame.length}`);
streamings[camera].lastBase64Frame = frame;

const clientsToDelete = [];
adapter._streamSubscribes.forEach(sub => {
if (sub.camera === camera) {
Expand Down
13 changes: 0 additions & 13 deletions io-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,6 @@
"name": "cameras",
"version": "2.0.4",
"news": {
"2.0.4": {
"en": "Minimal supported NodeJS version is 18\nCorrected widgets",
"de": "Minimal unterstützt NodeJS-Version ist 18\nKorrigierte Widgets",
"ru": "Минимальная поддержка Версия NodeJS 18\nИсправленные виджеты",
"pt": "Minimal suportado NodeJS versão é 18\nWidgets corrigidos",
"nl": "Minimale ondersteuning NodeJS versie 18\nVertaling:",
"fr": "Support minimal NodeJS version is 18\nWidgets corrigés",
"it": "Minimal supportato NodeJS versione è 18\nWidget corretti",
"es": "Soporte mínimo NodeJS versión es 18\nWidgets corregidos",
"pl": "Minimalny Wersja NodeJS wynosi 18\nPoprawiony widget",
"uk": "Мінімалістична підтримка Версія NodeJS - 18\nВиправлені віджети",
"zh-cn": "明米支助 未提交法院的版本 18\n伤势"
},
"1.4.0": {
"en": "Changed widget set name\nAdded the caching of images with time, size and rotation\nAdded timeout for RTSP cameras",
"de": "Geänderter Widget-Setname\nHinzufügen des Caches von Bildern mit Zeit, Größe und Rotation\nTimeout für RTSP-Kameras hinzugefügt",
Expand Down

0 comments on commit 63f6f9c

Please sign in to comment.