Scene detection options including the frame source.
An AsyncGenerator yielding scene boundaries as they are detected.
// Pre-recorded video
const boundaries: SceneBoundary[] = [];
for await (const boundary of detectScenes({ frames: extractFrames('video.mp4') })) {
console.log(`Scene ${boundary.index} at ${boundary.startTimeSec}s (${boundary.cutType})`);
boundaries.push(boundary);
}
// Live webcam with custom thresholds
for await (const boundary of detectScenes({
frames: webcamFrameStream,
hardCutThreshold: 0.4,
minSceneDurationSec: 2.0,
})) {
console.log(`Motion detected at ${boundary.startTimeSec}s`);
}
Detects scene boundaries in a stream of video frames.
Creates a SceneDetector with the supplied configuration and yields SceneBoundary objects as visual discontinuities are detected. The generator completes when the input frame stream is exhausted.
Suitable for both pre-recorded video (extract frames via ffmpeg, then pipe as an async iterable) and live streams (webcam, security camera, screen capture).