mirror of
https://github.com/koush/scrypted.git
synced 2026-09-20 02:30:39 +01:00
ring: fix video clip thumbnails (#651)
This commit is contained in:
4
plugins/ring/package-lock.json
generated
4
plugins/ring/package-lock.json
generated
@@ -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",
|
||||
|
||||
@@ -44,5 +44,5 @@
|
||||
"got": "11.8.6",
|
||||
"socket.io-client": "^2.5.0"
|
||||
},
|
||||
"version": "0.0.105"
|
||||
"version": "0.0.106"
|
||||
}
|
||||
|
||||
@@ -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> {
|
||||
|
||||
Reference in New Issue
Block a user