Skip to main content

Requirements

  • Node.js 18 or higher (or Bun 1.0+)
  • On linux-x64, linux-arm64, and macOS arm64: nothing else. npm install node-webcodecs works with zero system dependencies.
  • Elsewhere: FFmpeg libraries (libavcodec, libavutil, libswscale, libswresample), plus pkg-config and a C++ compiler when building from source
The loader picks the first native binding that works:
  1. Dynamic prebuild — links your system FFmpeg (all its codecs, including GPL ones like x264/x265). Requires matching FFmpeg runtime libraries: 6.x on Linux (e.g. Ubuntu 24.04), current Homebrew FFmpeg on macOS.
  2. Static prebuild — bundled LGPL-only FFmpeg, shipped as a platform-specific @node-webcodecs/static-* optional dependency (~15 MB). Works in any Docker image, Lambda, or Fly with no FFmpeg installed. H.264 encode via openh264, AV1 encode via SVT-AV1, AV1 decode via dav1d; software HEVC encode is unavailable (hardware HEVC still works).
  3. Source build — compiles against your FFmpeg dev headers via cmake-js.
Set NODE_WEBCODECS_FORCE=dynamic|static|source to pin a variant, and call getNativeVariant() to see which one loaded.

Platform-Specific Setup

macOS Installation

Install FFmpeg and pkg-config via Homebrew:
Ensure Homebrew is in your PATH (add to ~/.zshrc or ~/.bashrc):
On Apple Silicon Macs, Homebrew installs to /opt/homebrew by default. Make sure this is in your PATH:
On Intel Macs, Homebrew installs to /usr/local. Ensure /usr/local/bin is in your PATH:

Install node-webcodecs

First build may take 2-3 minutes as native bindings compile against your FFmpeg installation.

Verification

Verify your installation works:

Troubleshooting

The native module failed to compile. Check that:
  1. FFmpeg libraries are installed (brew list ffmpeg or dpkg -l | grep libavcodec)
  2. pkg-config can find FFmpeg (pkg-config --modversion libavcodec)
  3. You have a C++ compiler installed
Try rebuilding:
FFmpeg libraries aren’t in your dynamic library path.macOS:
Linux:
Add to your shell profile (.zshrc, .bashrc) to make permanent.
Install pkg-config:macOS:
Ubuntu/Debian:
Windows:
If the native compilation is failing or taking too long:
  1. Check you have enough RAM (compilation needs ~2GB)
  2. Try cleaning node_modules:
  3. Check compiler version (GCC 7+ or Clang 5+ recommended)
Dynamic prebuilds (system FFmpeg required at runtime): macOS arm64/x64, Linux x64/arm64.Static prebuilds (no FFmpeg required, v1.3.0+): linux-x64, linux-arm64, darwin-arm64 via @node-webcodecs/static-* optional dependencies.Check which one loaded with getNativeVariant() — returns 'prebuild', 'static', or 'source'.

Runtime Support

Node.js 18+

Full support for Node.js 18.x, 20.x, 22.x

Bun 1.0+

Full compatibility via N-API

Next Steps

Quick Start Tutorial

Get your first video encoding in 5 minutes

Sources