API Reference
The node-webcodecs API follows the W3C WebCodecs specification, providing native video and audio encoding/decoding in Node.js.All classes and types are exported from the main
node-webcodecs package:Core Classes
Video Processing
VideoEncoder
Encode raw
VideoFrame objects into compressed video chunks (H.264, H.265, VP9, AV1)VideoDecoder
Decode compressed video chunks back into
VideoFrame objectsVideoFrame
Raw video frame data with pixel format, dimensions, and color space
EncodedVideoChunk
A chunk of compressed video data (keyframe or delta frame)
Audio Processing
AudioEncoder
Encode raw
AudioData into compressed audio (AAC, MP3, Opus, FLAC)AudioDecoder
Decode compressed audio chunks back into
AudioData objectsAudioData
Raw audio samples with sample rate, channel count, and format
EncodedAudioChunk
A chunk of compressed audio data
Image & Color
ImageDecoder
Decode image files (JPEG, PNG, WebP, GIF) into
VideoFrame objectsVideoColorSpace
Color space information (primaries, transfer, matrix coefficients)
Utility Functions
FFmpeg Information
getFFmpegVersion()
getFFmpegVersion()
Returns FFmpeg version information, or
null if native module unavailable.listCodecs()
listCodecs()
Lists all available encoders and decoders.
hasCodec(codecName, type)
hasCodec(codecName, type)
Check if a specific codec is available.
isNativeAvailable()
isNativeAvailable()
Check if the native FFmpeg addon loaded successfully.
Supported Codecs
Video Codecs
| Codec | WebCodecs String | Encoding | Decoding | Hardware Accel |
|---|---|---|---|---|
| H.264/AVC | avc1.42001f | ✅ | ✅ | ✅ VideoToolbox, NVENC |
| H.265/HEVC | hvc1.1.6.L93.B0 | ✅ | ✅ | ✅ VideoToolbox, NVENC |
| VP8 | vp8 | ✅ | ✅ | ❌ |
| VP9 | vp09.00.10.08 | ✅ | ✅ | ❌ |
| AV1 | av01.0.04M.08 | ✅ | ✅ | ❌ |
Audio Codecs
| Codec | WebCodecs String | Encoding | Decoding |
|---|---|---|---|
| AAC | mp4a.40.2 | ✅ | ✅ |
| MP3 | mp3 | ✅ | ✅ |
| Opus | opus | ✅ | ✅ |
| FLAC | flac | ✅ | ✅ |
| Vorbis | vorbis | ✅ | ✅ |