diff --git a/plugins/ring/package-lock.json b/plugins/ring/package-lock.json index 580b9273e6..a6b864d9a5 100644 --- a/plugins/ring/package-lock.json +++ b/plugins/ring/package-lock.json @@ -1,12 +1,12 @@ { "name": "@scrypted/ring", - "version": "0.0.105", + "version": "0.0.106", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@scrypted/ring", - "version": "0.0.105", + "version": "0.0.106", "dependencies": { "@koush/ring-client-api": "file:../../external/ring-client-api", "@scrypted/common": "file:../../common", diff --git a/plugins/ring/package.json b/plugins/ring/package.json index ec9989a9b6..4a97809ff8 100644 --- a/plugins/ring/package.json +++ b/plugins/ring/package.json @@ -44,5 +44,5 @@ "got": "11.8.6", "socket.io-client": "^2.5.0" }, - "version": "0.0.105" + "version": "0.0.106" } diff --git a/plugins/ring/src/camera.ts b/plugins/ring/src/camera.ts index 7c9fc3c726..e3ff9d8b6c 100644 --- a/plugins/ring/src/camera.ts +++ b/plugins/ring/src/camera.ts @@ -731,17 +731,25 @@ export class RingCameraDevice extends ScryptedDeviceBase implements DeviceProvid } async getVideoClip(videoId: string): Promise { - if (this.videoClips.has(videoId)) { - return mediaManager.createMediaObjectFromUrl(this.videoClips.get(videoId).resources.video.href); + if (!this.videoClips.has(videoId)) { + throw new Error('Failed to get video clip.'); } - throw new Error('Failed to get video clip.') + return mediaManager.createMediaObjectFromUrl(this.videoClips.get(videoId).resources.video.href); } async getVideoClipThumbnail(thumbnailId: string): Promise { - if (this.videoClips.has(thumbnailId)) { - return mediaManager.createMediaObjectFromUrl(this.videoClips.get(thumbnailId).resources.thumbnail.href); + if (!this.videoClips.has(thumbnailId)) { + throw new Error('Failed to get video clip thumbnail.'); } - throw new Error('Failed to get video clip thumbnail.') + const ffmpegInput: FFmpegInput = { + inputArguments: [ + '-f', 'h264', + '-i', this.videoClips.get(thumbnailId).resources.thumbnail.href, + ] + }; + const input = await mediaManager.createFFmpegMediaObject(ffmpegInput); + const jpeg = await mediaManager.convertMediaObjectToBuffer(input, 'image/jpeg'); + return await mediaManager.createMediaObject(jpeg, 'image/jpeg'); } async removeVideoClips(...videoClipIds: string[]): Promise {