Requirements
- Node.js 18 or higher (or Bun 1.0+)
- On linux-x64, linux-arm64, and macOS arm64: nothing else.
npm install node-webcodecsworks with zero system dependencies. - Elsewhere: FFmpeg libraries (libavcodec, libavutil, libswscale, libswresample), plus pkg-config and a C++ compiler when building from source
- 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.
- 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). - 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
- Ubuntu/Debian
- Windows
- Docker
macOS Installation
Install FFmpeg and pkg-config via Homebrew:~/.zshrc or ~/.bashrc):M1/M2/M3 Mac Users
M1/M2/M3 Mac Users
On Apple Silicon Macs, Homebrew installs to
/opt/homebrew by default. Make sure this is in your PATH:Intel Mac Users
Intel Mac Users
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
Error: Cannot find module 'node-webcodecs'
Error: Cannot find module 'node-webcodecs'
The native module failed to compile. Check that:
- FFmpeg libraries are installed (
brew list ffmpegordpkg -l | grep libavcodec) - pkg-config can find FFmpeg (
pkg-config --modversion libavcodec) - You have a C++ compiler installed
Error: Library not loaded: libavcodec
Error: Library not loaded: libavcodec
FFmpeg libraries aren’t in your dynamic library path.macOS:Linux:Add to your shell profile (
.zshrc, .bashrc) to make permanent.Error: pkg-config not found
Error: pkg-config not found
Install pkg-config:macOS:Ubuntu/Debian:Windows:
Build takes forever or fails
Build takes forever or fails
If the native compilation is failing or taking too long:
- Check you have enough RAM (compilation needs ~2GB)
- Try cleaning node_modules:
- Check compiler version (GCC 7+ or Clang 5+ recommended)
Using prebuilt binaries
Using prebuilt binaries
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