Skip to content

Commit

Permalink
snapshot: black background (koush#1324)
Browse files Browse the repository at this point in the history
* Fix WritableDeviceState

* Fix tsconfig error

* Generate black background instead of using black.jpg

Remove redundant blur
  • Loading branch information
longzheng authored and rustyd0g committed Feb 17, 2024
1 parent 9c1560a commit ebd74d0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
Binary file removed plugins/snapshot/fs/black.jpg
Binary file not shown.
9 changes: 4 additions & 5 deletions plugins/snapshot/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { AutoenableMixinProvider } from "@scrypted/common/src/autoenable-mixin-p
import { AuthFetchCredentialState, authHttpFetch } from '@scrypted/common/src/http-auth-fetch';
import { RefreshPromise, TimeoutError, createMapPromiseDebouncer, singletonPromise, timeoutPromise } from "@scrypted/common/src/promise-utils";
import { SettingsMixinDeviceBase, SettingsMixinDeviceOptions } from "@scrypted/common/src/settings-mixin";
import sdk, { BufferConverter, Camera, DeviceManifest, DeviceProvider, FFmpegInput, HttpRequest, HttpRequestHandler, HttpResponse, MediaObject, MediaObjectOptions, MixinProvider, RequestMediaStreamOptions, RequestPictureOptions, ResponsePictureOptions, ScryptedDevice, ScryptedDeviceType, ScryptedInterface, ScryptedMimeTypes, Setting, SettingValue, Settings, VideoCamera } from "@scrypted/sdk";
import sdk, { BufferConverter, Camera, DeviceManifest, DeviceProvider, FFmpegInput, HttpRequest, HttpRequestHandler, HttpResponse, MediaObject, MediaObjectOptions, MixinProvider, RequestMediaStreamOptions, RequestPictureOptions, ResponsePictureOptions, ScryptedDevice, ScryptedDeviceType, ScryptedInterface, ScryptedMimeTypes, Setting, SettingValue, Settings, VideoCamera, WritableDeviceState } from "@scrypted/sdk";
import { StorageSettings } from "@scrypted/sdk/storage-settings";
import https from 'https';
import os from 'os';
Expand Down Expand Up @@ -519,13 +519,12 @@ class SnapshotMixin extends SettingsMixinDeviceBase<Camera> implements Camera {
const fontFile = path.join(unzippedFs, 'Lato-Bold.ttf');

if (!errorBackground) {
const black = path.join(unzippedFs, 'black.jpg');
return ffmpegFilterImage([
'-i', black,
'-f', 'lavfi',
'-i', 'color=black:size=1920x1080',
], {
console: this.debugConsole,
ffmpegPath: await mediaManager.getFFmpegPath(),
blur: true,
text: {
fontFile,
text,
Expand Down Expand Up @@ -723,7 +722,7 @@ export class SnapshotPlugin extends AutoenableMixinProvider implements MixinProv
return undefined;
}

async getMixin(mixinDevice: any, mixinDeviceInterfaces: ScryptedInterface[], mixinDeviceState: { [key: string]: any; }): Promise<any> {
async getMixin(mixinDevice: any, mixinDeviceInterfaces: ScryptedInterface[], mixinDeviceState: WritableDeviceState): Promise<any> {
const ret = new SnapshotMixin(this, {
mixinDevice,
mixinDeviceInterfaces,
Expand Down
6 changes: 3 additions & 3 deletions plugins/snapshot/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "ES2021",
"module": "NodeNext",
"target": "ESNext",
"resolveJsonModule": true,
"moduleResolution": "Node16",
"moduleResolution": "NodeNext",
"esModuleInterop": true,
"sourceMap": true
},
Expand Down

0 comments on commit ebd74d0

Please sign in to comment.