JSPM

@catlabtech/webcvt-codec-webcodecs

0.2.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 47
  • Score
    100M100P100Q60020F
  • License MIT

Thin adapter over the W3C WebCodecs API — encode/decode video and audio frames for webcvt container packages

Package Exports

  • @catlabtech/webcvt-codec-webcodecs

Readme

@catlabtech/webcvt-codec-webcodecs

Thin adapter over the W3C WebCodecs API. Provides a uniform encode / decode surface that higher-level container packages (@catlabtech/webcvt-container-mp4, @catlabtech/webcvt-container-webm, etc.) depend on to produce and consume raw video frames and audio data.

This package does not implement any codec logic — it delegates entirely to the browser's hardware-accelerated codec stack. Its job is to wrap the raw WebCodecs API with ergonomic TypeScript types, consistent error classes, and a probeCodec() helper for capability detection.

Target LOC: ~1,500 lines across all source files.

API surface

import {
  probeVideoCodec,
  probeAudioCodec,
  WebCodecsVideoEncoder,
  WebCodecsVideoDecoder,
  WebCodecsAudioEncoder,
  WebCodecsAudioDecoder,
  WebCodecsNotSupportedError,
  UnsupportedCodecError,
} from '@catlabtech/webcvt-codec-webcodecs';

// Probe capability
const result = await probeVideoCodec({ codec: 'h264', width: 1920, height: 1080 });
if (!result.supported) throw new UnsupportedCodecError('h264');

// Encode
const enc = new WebCodecsVideoEncoder(
  { config: { codec: 'avc1.42001E', width: 1280, height: 720, bitrate: 2_000_000, framerate: 30 } },
  (chunk, meta) => { /* forward chunk to muxer */ },
);
enc.encode(videoFrame);
await enc.flush();
enc.close();

Implementation references

This package wraps the official W3C WebCodecs specification (W3C WebCodecs). Architectural inspiration drawn from studying Mediabunny (MPL-2.0) but no code was copied — all implementation is original and licensed under MIT.

Test fixtures derived from FFmpeg samples (LGPL-2.1) are stored in tests/fixtures/ and are excluded from the published npm package via .npmignore.