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

@hurraey/video-thumbnail

v0.1.0

Published

Framework-independent browser video thumbnail generation with exact viewport frames and coarse Worker backfill.

Readme

@hurraey/video-thumbnail

Goal

Generate a poster, exact visible thumbnails, and coarse background thumbnails without depending on React, Zustand, or editor-specific project state.

Prerequisites

  • Node.js 22 or later and pnpm 10 or later for package development
  • A browser environment with HTMLVideoElement and createImageBitmap
  • Web Worker, WebCodecs VideoDecoder, and an MP4-compatible source for coarse background decoding
  • A bundler that supports module workers created through new URL(..., import.meta.url)

Step-by-Step Guide

Install the package

Install a locally packed release:

pnpm add ./hurraey-video-thumbnail-0.1.0.tgz

After a registry release is available, install it by package name:

pnpm add @hurraey/video-thumbnail

Import the public API

Application code should import from the library entry point instead of an internal browser adapter.

import {
    abortViewportThumbnails,
    disposePoster,
    ensurePoster,
    registerIdleBackfill,
    scheduleViewportThumbnails,
    thumbnailCache,
    unregisterIdleBackfill,
} from '@hurraey/video-thumbnail';

Generate the poster and register background work

const sourceId = URL.createObjectURL(videoFile);

await ensurePoster(sourceId);
registerIdleBackfill(sourceId, videoDurationSec);

The poster uses an isolated HTMLVideoElement and seeks to 0.1 seconds. Idle backfill uses the Worker path and stores frames with coarse quality.

Request exact visible frames

scheduleViewportThumbnails({
    sourceId,
    objectUrl: sourceId,
    timestamps: [0.8, 2.4, 4],
    requestKey: 'viewport-42',
});

Use a new requestKey when the viewport, zoom level, tile geometry, or visible source times change. A completed frame is committed only when it still belongs to the current request.

Read the best available frame

const frame = thumbnailCache.getBestNear({
    sourceId,
    timeSec: 2.4,
    toleranceSec: 0.15,
});

Here, exact means that the browser completed an HTMLVideoElement.currentTime seek for the requested timestamp. It does not mean byte-identical decoding across browsers. coarse means that the Worker decoded the nearest sync sample (keyframe).

The cache prefers an exact frame over a coarse frame within the requested tolerance. A later exact frame replaces a coarse frame stored at the same quantized timestamp.

Release runtime resources

abortViewportThumbnails(sourceId);
unregisterIdleBackfill(sourceId);
disposePoster(sourceId);
thumbnailCache.remove(sourceId);
URL.revokeObjectURL(sourceId);

Call the cleanup functions when a source is removed, replaced, or no longer reachable.

Verify Final Result

Install dependencies, verify the library, and create an installable tarball.

pnpm install
pnpm verify
pnpm pack

The Core directory contains deterministic policies and calculations. The Browser directory contains resource-owning adapters for HTML video seeking, Worker decoding, ImageBitmap, and IndexedDB.