ring: fix video clip thumbnails (#651)

This commit is contained in:
Alex Leeds
2023-03-22 16:12:42 -04:00
committed by GitHub
parent 2ecf48bc60
commit 418724f860
3 changed files with 17 additions and 9 deletions

View File

@@ -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",

View File

@@ -44,5 +44,5 @@
"got": "11.8.6",
"socket.io-client": "^2.5.0"
},
"version": "0.0.105"
"version": "0.0.106"
}

View File

@@ -731,17 +731,25 @@ export class RingCameraDevice extends ScryptedDeviceBase implements DeviceProvid
}
async getVideoClip(videoId: string): Promise<MediaObject> {
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<MediaObject> {
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<void> {