From 469f693d58e8b25d014cf1962c09df86c11d0afc Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Wed, 13 Dec 2023 09:07:02 -0800 Subject: [PATCH] snapshot: use internal prebuffer converter rather than media manager --- plugins/snapshot/.vscode/settings.json | 2 +- plugins/snapshot/package-lock.json | 4 ++-- plugins/snapshot/package.json | 2 +- plugins/snapshot/src/ffmpeg-image-filter.ts | 3 +-- plugins/snapshot/src/main.ts | 7 ++++++- plugins/snapshot/src/promise-debouncer.ts | 0 6 files changed, 11 insertions(+), 7 deletions(-) delete mode 100644 plugins/snapshot/src/promise-debouncer.ts diff --git a/plugins/snapshot/.vscode/settings.json b/plugins/snapshot/.vscode/settings.json index 105b96164..77ccdbd6d 100644 --- a/plugins/snapshot/.vscode/settings.json +++ b/plugins/snapshot/.vscode/settings.json @@ -1,4 +1,4 @@ { - "scrypted.debugHost": "koushik-windows", + "scrypted.debugHost": "127.0.0.1", } \ No newline at end of file diff --git a/plugins/snapshot/package-lock.json b/plugins/snapshot/package-lock.json index 5050a46ae..4bce51e98 100644 --- a/plugins/snapshot/package-lock.json +++ b/plugins/snapshot/package-lock.json @@ -1,12 +1,12 @@ { "name": "@scrypted/snapshot", - "version": "0.2.14", + "version": "0.2.15", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@scrypted/snapshot", - "version": "0.2.14", + "version": "0.2.15", "dependencies": { "@koush/axios-digest-auth": "^0.8.5", "@types/node": "^18.16.18", diff --git a/plugins/snapshot/package.json b/plugins/snapshot/package.json index 97ac5062f..bafecdba5 100644 --- a/plugins/snapshot/package.json +++ b/plugins/snapshot/package.json @@ -1,6 +1,6 @@ { "name": "@scrypted/snapshot", - "version": "0.2.14", + "version": "0.2.15", "description": "Snapshot Plugin for Scrypted", "scripts": { "scrypted-setup-project": "scrypted-setup-project", diff --git a/plugins/snapshot/src/ffmpeg-image-filter.ts b/plugins/snapshot/src/ffmpeg-image-filter.ts index 34f2c35ba..d066bd8ca 100644 --- a/plugins/snapshot/src/ffmpeg-image-filter.ts +++ b/plugins/snapshot/src/ffmpeg-image-filter.ts @@ -1,12 +1,11 @@ -import fs from 'fs'; import { addVideoFilterArguments } from '@scrypted/common/src/ffmpeg-helpers'; import { ffmpegLogInitialOutput, safeKillFFmpeg, safePrintFFmpegArguments } from '@scrypted/common/src/media-helpers'; +import { timeoutFunction } from '@scrypted/common/src/promise-utils'; import { sleep } from '@scrypted/common/src/sleep'; import child_process, { ChildProcess } from 'child_process'; import { once } from 'events'; import { Writable } from 'stream'; import { Pipe2Jpeg } from './pipe2jpeg'; -import { timeoutFunction } from '@scrypted/common/src/promise-utils'; export interface FFmpegImageFilterOptions { console?: Console, diff --git a/plugins/snapshot/src/main.ts b/plugins/snapshot/src/main.ts index 0c10e721a..ffe7162d6 100644 --- a/plugins/snapshot/src/main.ts +++ b/plugins/snapshot/src/main.ts @@ -176,7 +176,12 @@ class SnapshotMixin extends SettingsMixinDeviceBase implements Camera { request.refresh = false; takePrebufferPicture = async () => { // this.console.log('snapshotting active prebuffer'); - return mediaManager.convertMediaObjectToBuffer(await realDevice.getVideoStream(request), 'image/jpeg'); + const ffmpegInput = await sdk.mediaManager.convertMediaObjectToJSON(await realDevice.getVideoStream(request), ScryptedMimeTypes.FFmpegInput); + return ffmpegFilterImage(ffmpegInput.inputArguments, { + console: this.debugConsole, + ffmpegPath: await mediaManager.getFFmpegPath(), + timeout: 10000, + }); }; return takePrebufferPicture; } diff --git a/plugins/snapshot/src/promise-debouncer.ts b/plugins/snapshot/src/promise-debouncer.ts deleted file mode 100644 index e69de29bb..000000000