npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@browser-mc/mediabunny-scene-keyframes

v0.3.0

Published

Streaming scene detection helpers for forcing key frames during Mediabunny transcodes.

Downloads

523

Readme

@browser-mc/mediabunny-scene-keyframes

Streaming scene detection helpers for forcing key frames during Mediabunny transcodes.

Install

pnpm add @browser-mc/mediabunny-scene-keyframes 'mediabunny@^1.62.0'

Mediabunny is a required peer dependency. Use one shared Mediabunny installation (version 1.62.0 or a compatible newer 1.x release) in your application and these helpers. Their APIs exchange Mediabunny objects, and separate copies can fail runtime instanceof checks even when their versions match. Keep Mediabunny external if you bundle these helpers separately, and resolve it to the application's copy. Install it explicitly even if your package manager can install peers automatically; incompatible versions are unsupported.

Streaming Detection

import { Input, Mp4InputFormat, BlobSource } from 'mediabunny';
import { SceneKeyFrameDetector } from '@browser-mc/mediabunny-scene-keyframes';

const input = new Input({
  source: new BlobSource(file),
  formats: [new Mp4InputFormat()],
});

const track = await input.getPrimaryVideoTrack();
if (track) {
  const detector = new SceneKeyFrameDetector({
    sensitivity: 'medium',
    sampleRate: 'all',
    minKeyFrameDistance: 2,
    maxKeyFrameInterval: 6,
  });

  const process = (sample) => {
    const decision = detector.detectSample(sample);
    sample.setEncodeOptions({
      ...sample.encodeOptions,
      keyFrame: decision.keyFrame,
    });
    return sample;
  };

  console.log(detector.state.changes);
  console.log(detector.state.keyFrameTimestamps);
}

注意: keyFrame: decision.keyFrame をすべてのフレームに設定する場合、エンコーダーの keyFrameInterval オプションは 設定しないでください。decision.keyFrame が false のフレームに明示的な false が付くと、エンコーダー側の keyFrameInterval による間隔挿入が無効化されます。maxKeyFrameInterval による間隔保証はこのライブラリの shouldForceKeyFrame が担っているため、エンコーダーへの重複指定は不要です。

Scope

This package detects scene changes and tracks scene-derived key-frame timestamps. It does not wrap Mediabunny Conversion and does not transcode media.

SceneKeyFrameDetector is the streaming API used by @browser-mc/browser-movie-converter; planSceneKeyFrames remains available when a caller wants an offline pre-scan.

Sensitivity Presets

import { resolveSceneDetectionOptions, sceneDetectionPresets } from '@browser-mc/mediabunny-scene-keyframes';

console.log(sceneDetectionPresets);

const options = resolveSceneDetectionOptions({
  sensitivity: 'high',
  minKeyFrameDistance: 2,
});

Presets:

  • low: threshold: 0.25, sampleRate: 1, minSceneDuration: 1.5
  • medium: threshold: 0.18, sampleRate: 2, minSceneDuration: 0.8
  • high: threshold: 0.12, sampleRate: 3, minSceneDuration: 0.5

Explicit options override preset values, so { sensitivity: 'low', threshold: 0.2 } keeps the low preset shape but uses threshold: 0.2.

Pure Detection Tests

import { detectSceneChangesInFingerprints } from '@browser-mc/mediabunny-scene-keyframes';

The pure fingerprint API is useful for deterministic unit tests without WebCodecs.

Commands

pnpm --filter @browser-mc/mediabunny-scene-keyframes build
pnpm --filter @browser-mc/mediabunny-scene-keyframes typecheck
pnpm --filter @browser-mc/mediabunny-scene-keyframes test
pnpm --filter @browser-mc/mediabunny-scene-keyframes test:electron

The Electron smoke test decodes bbb.mov and verifies that a scene plan can be produced in a browser runtime.