rebroadcast: various memory fixes and process observations.

This commit is contained in:
Koushik Dutta
2021-10-08 20:25:33 -07:00
parent 58570d065a
commit 915d776a41
6 changed files with 25 additions and 9 deletions

View File

@@ -1,12 +1,12 @@
{
"name": "@scrypted/prebuffer-mixin",
"version": "0.1.51",
"version": "0.1.52",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@scrypted/prebuffer-mixin",
"version": "0.1.51",
"version": "0.1.52",
"license": "Apache-2.0",
"dependencies": {
"@scrypted/common": "file:../../common",

View File

@@ -1,6 +1,6 @@
{
"name": "@scrypted/prebuffer-mixin",
"version": "0.1.51",
"version": "0.1.52",
"description": "Rebroadcast and Prebuffer for VideoCameras.",
"author": "Scrypted",
"license": "Apache-2.0",

View File

@@ -209,6 +209,16 @@ class PrebufferMixin extends SettingsMixinDeviceBase<VideoCamera> implements Vid
});
}
let watchdog: NodeJS.Timeout;
session.events.on('mp4-data', () => {
clearTimeout(watchdog);
setTimeout(() => {
this.console.error('watchdog for mp4 parser timed out... killing ffmpeg session');
session.kill();
}, 30000);
})
session.events.once('killed', () => clearTimeout(watchdog));
return session;
}

View File

@@ -1,12 +1,12 @@
{
"name": "@scrypted/unifi-protect",
"version": "0.0.38",
"version": "0.0.39",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@scrypted/unifi-protect",
"version": "0.0.38",
"version": "0.0.39",
"license": "Apache",
"dependencies": {
"@types/ws": "^7.4.7",

View File

@@ -1,6 +1,6 @@
{
"name": "@scrypted/unifi-protect",
"version": "0.0.38",
"version": "0.0.39",
"description": "Unifi Protect Plugin for Scrypted",
"author": "Scrypted",
"license": "Apache",

View File

@@ -31,6 +31,10 @@ class UnifiCamera extends ScryptedDeviceBase implements Camera, VideoCamera, Mot
}
}
async getObjectTypes(): Promise<string[]> {
return this.findCamera().featureFlags.smartDetectTypes;
}
async getDetectionInput(detectionId: any): Promise<MediaObject> {
const data = this.detections.get(detectionId);
if (!data)
@@ -95,7 +99,6 @@ class UnifiCamera extends ScryptedDeviceBase implements Camera, VideoCamera, Mot
const rtspChannels = camera.channels.filter(channel => channel.isRtspEnabled && this.isChannelEnabled(channel));
const rtspChannel = camera.channels.find(channel => channel.id === options?.id) || rtspChannels[0];
this.console.log('serving rtsp channel', rtspChannel);
const { rtspAlias } = rtspChannel;
const u = `rtsp://${this.protect.getSetting('ip')}:7447/${rtspAlias}`
@@ -288,6 +291,8 @@ class UnifiProtect extends ScryptedDeviceBase implements Settings, DeviceProvide
}
const detectionId = Math.random().toString();
const camera = rtsp.findCamera();
const snapshotChannel = camera.channels[0];
const detection: ObjectDetection = {
detectionId,
@@ -295,13 +300,14 @@ class UnifiProtect extends ScryptedDeviceBase implements Settings, DeviceProvide
detections: payload.smartDetectTypes.map(type => ({
className: type,
score: payload.score,
}))
})),
inputDimensions: [snapshotChannel.width, snapshotChannel.height],
};
rtsp.onDeviceEvent(ScryptedInterface.ObjectDetector, detection);
const snapshot = rtsp.getSnapshot();
rtsp.detections.set(detectionId, snapshot);
setTimeout(() => rtsp.detections.delete(detectionId), 30000);
rtsp.onDeviceEvent(ScryptedInterface.ObjectDetector, detection);
rtsp.lastSeen = payload.start;
break;