Skip to main content

WebCodecs for Node.js

Native WebCodecs API implementation for Node.js, using FFmpeg for encoding and decoding. Frame-level video and audio processing without subprocess overhead.
v1.0.0 — 84/84 tests passing on the vjeux WebCodecs harness

Why node-webcodecs?

Encode and decode video frame-by-frame with precise control over every aspect. Set keyframes exactly where you want them, not where FFmpeg decides.
Use JavaScript conditionals, loops, and variables instead of cryptic FFmpeg filter syntax. Debug with breakpoints, not stderr parsing.
Same API as browser WebCodecs. Write effects once, run in both browser preview and server export. No more parity bugs.
Access platform encoders (VideoToolbox, NVENC, QuickSync, VA-API) for 8-15x faster encoding with optional worker threads.

Installation

npm install node-webcodecs
Prerequisites: Node.js 18+, FFmpeg libraries (libavcodec, libavformat, libavutil)See Installation Guide for platform-specific setup.

Quick Example

import { VideoEncoder, VideoFrame } from 'node-webcodecs';

const encoder = new VideoEncoder({
  output: (chunk, metadata) => {
    console.log(`Encoded ${chunk.byteLength} bytes`);
  },
  error: (err) => console.error(err)
});

encoder.configure({
  codec: 'avc1.42E01E',
  width: 1920,
  height: 1080,
  bitrate: 5_000_000
});

// Encode frames
const frame = new VideoFrame(buffer, {
  format: 'RGBA',
  codedWidth: 1920,
  codedHeight: 1080,
  timestamp: 0
});

encoder.encode(frame);
frame.close(); // Important: prevent memory leaks

Use Cases

Isomorphic Video Editors

Same effects code in browser and server. Visual parity guaranteed.

WebRTC Recording

Decode, composite, and re-encode in the same Node process.

Live Highlight Clipping

Frame-accurate clips from live streams with no timestamp drift.

Video Ingest Validation

Frame-by-frame quality assurance, not just metadata parsing.

Personalized Video

Actual programming for template-based video assembly.

HDR & Wide Gamut

BT.2020 primaries, PQ/HLG transfer functions natively supported.

Next Steps

1

Install

Follow the installation guide for your platform
2

Quick Start

Complete the 5-minute tutorial
3

Explore

Browse cookbook recipes for your use case

Community & Support