Skip to content

Commit

Permalink
sdk: remove filter from VideoFrameGenerator
Browse files Browse the repository at this point in the history
  • Loading branch information
koush committed Nov 9, 2023
1 parent 7eca7f6 commit 6d5fedc
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 15 deletions.
6 changes: 3 additions & 3 deletions plugins/objectdetector/src/ffmpeg-videoframes-no-sharp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class RawImage implements Image, RawFrame {
}

export class FFmpegVideoFrameGenerator extends ScryptedDeviceBase implements VideoFrameGenerator {
async *generateVideoFramesInternal(mediaObject: MediaObject, options?: VideoFrameGeneratorOptions, filter?: (videoFrame: VideoFrame) => Promise<boolean>): AsyncGenerator<VideoFrame, any, unknown> {
async *generateVideoFramesInternal(mediaObject: MediaObject, options?: VideoFrameGeneratorOptions): AsyncGenerator<VideoFrame, any, unknown> {
const ffmpegInput = await sdk.mediaManager.convertMediaObjectToJSON<FFmpegInput>(mediaObject, ScryptedMimeTypes.FFmpegInput);
const gray = options?.format === 'gray';
const format = options?.format || 'rgb';
Expand Down Expand Up @@ -171,7 +171,7 @@ export class FFmpegVideoFrameGenerator extends ScryptedDeviceBase implements Vid
}


async generateVideoFrames(mediaObject: MediaObject, options?: VideoFrameGeneratorOptions, filter?: (videoFrame: VideoFrame & MediaObject) => Promise<boolean>): Promise<AsyncGenerator<VideoFrame, any, unknown>> {
return this.generateVideoFramesInternal(mediaObject, options, filter);
async generateVideoFrames(mediaObject: MediaObject, options?: VideoFrameGeneratorOptions): Promise<AsyncGenerator<VideoFrame, any, unknown>> {
return this.generateVideoFramesInternal(mediaObject, options);
}
}
7 changes: 3 additions & 4 deletions plugins/objectdetector/src/ffmpeg-videoframes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class VipsImage implements Image {
}

export class FFmpegVideoFrameGenerator extends ScryptedDeviceBase implements VideoFrameGenerator {
async *generateVideoFramesInternal(mediaObject: MediaObject, options?: VideoFrameGeneratorOptions, filter?: (videoFrame: VideoFrame) => Promise<boolean>): AsyncGenerator<VideoFrame, any, unknown> {
async *generateVideoFramesInternal(mediaObject: MediaObject, options?: VideoFrameGeneratorOptions): AsyncGenerator<VideoFrame, any, unknown> {
const ffmpegInput = await sdk.mediaManager.convertMediaObjectToJSON<FFmpegInput>(mediaObject, ScryptedMimeTypes.FFmpegInput);
const gray = options?.format === 'gray';
const channels = gray ? 1 : 3;
Expand Down Expand Up @@ -249,8 +249,7 @@ export class FFmpegVideoFrameGenerator extends ScryptedDeviceBase implements Vid
}
}


async generateVideoFrames(mediaObject: MediaObject, options?: VideoFrameGeneratorOptions, filter?: (videoFrame: VideoFrame) => Promise<boolean>): Promise<AsyncGenerator<VideoFrame, any, unknown>> {
return this.generateVideoFramesInternal(mediaObject, options, filter);
async generateVideoFrames(mediaObject: MediaObject, options?: VideoFrameGeneratorOptions): Promise<AsyncGenerator<VideoFrame, any, unknown>> {
return this.generateVideoFramesInternal(mediaObject, options);
}
}
1 change: 0 additions & 1 deletion plugins/python-codecs/src/gstreamer.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,6 @@ async def createGstMediaObject(image: GstImage):
async def generateVideoFramesGstreamer(
mediaObject: scrypted_sdk.MediaObject,
options: scrypted_sdk.VideoFrameGeneratorOptions = None,
filter: Any = None,
h264Decoder: str = None,
h265Decoder: str = None,
postProcessPipeline: str = None,
Expand Down
1 change: 0 additions & 1 deletion plugins/python-codecs/src/libav.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
async def generateVideoFramesLibav(
mediaObject: scrypted_sdk.MediaObject,
options: scrypted_sdk.VideoFrameGeneratorOptions = None,
filter: Any = None,
) -> scrypted_sdk.VideoFrame:
ffmpegInput: scrypted_sdk.FFmpegInput = (
await scrypted_sdk.mediaManager.convertMediaObjectToJSON(
Expand Down
9 changes: 3 additions & 6 deletions plugins/python-codecs/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async def generateVideoFrames(
filter: Any = None,
) -> scrypted_sdk.VideoFrame:
forked: CodecFork = await self.zygote().result
return await forked.generateVideoFramesLibav(mediaObject, options, filter)
return await forked.generateVideoFramesLibav(mediaObject, options)


class GstreamerGenerator(
Expand All @@ -60,7 +60,6 @@ async def generateVideoFrames(
return await forked.generateVideoFramesGstreamer(
mediaObject,
options,
filter,
self.storage.getItem("h264Decoder"),
self.storage.getItem("h265Decoder"),
self.storage.getItem("postProcessPipeline"),
Expand Down Expand Up @@ -242,14 +241,13 @@ async def generateVideoFramesGstreamer(
self,
mediaObject: scrypted_sdk.MediaObject,
options: scrypted_sdk.VideoFrameGeneratorOptions,
filter: Any,
h264Decoder: str,
h265Decoder: str,
postProcessPipeline: str,
) -> scrypted_sdk.VideoFrame:
async for data in self.generateVideoFrames(
gstreamer.generateVideoFramesGstreamer(
mediaObject, options, filter, h264Decoder, h265Decoder, postProcessPipeline
mediaObject, options, h264Decoder, h265Decoder, postProcessPipeline
),
"gstreamer",
options and options.get("firstFrameOnly"),
Expand All @@ -260,10 +258,9 @@ async def generateVideoFramesLibav(
self,
mediaObject: scrypted_sdk.MediaObject,
options: scrypted_sdk.VideoFrameGeneratorOptions = None,
filter: Any = None,
) -> scrypted_sdk.VideoFrame:
async for data in self.generateVideoFrames(
libav.generateVideoFramesLibav(mediaObject, options, filter),
libav.generateVideoFramesLibav(mediaObject, options),
"libav",
options and options.get("firstFrameOnly"),
):
Expand Down

0 comments on commit 6d5fedc

Please sign in to comment.