Releases: Brooooooklyn/webcodecs-node
v1.2.1
What's Changed
- feat: add libjxl (JPEG XL) support for Windows ARM64 by @Brooooooklyn in #10
- feat: support VP9 alpha encoding by @yisibl in #8
- test: port additional WPT tests for orientation, QP encoding, and content hints by @Brooooooklyn in #11
- refactor: unify frame sharing with Rust Arc, remove FFmpeg ref counting by @Brooooooklyn in #12
- perf: reduce data copies in encode/decode/mux pipeline by @Brooooooklyn in #14
- fix: change QP range for VP9 and AV1 from 0-63 to 0-255 by @Brooooooklyn in #15
New Contributors
Full Changelog: v1.2.0...v1.2.1
v1.2.0
v1.1.1
What's Changed
- fix: remove duplicate types in index.d.ts and clean up type generation by @Brooooooklyn in #7
Full Changelog: v1.1.0...v1.1.1
v1.1.0
Support Muxer and Demuxer
Muxer Usage
Muxers combine encoded video/audio chunks into container files (MP4, WebM, MKV).
// Create muxer with options
const muxer = new Mp4Muxer({ fastStart: true })
// Add video track
muxer.addVideoTrack({
codec: 'avc1.42001E',
width: 1920,
height: 1080,
description: metadata.decoderConfig?.description,
})
// Add audio track
muxer.addAudioTrack({
codec: 'mp4a.40.2',
sampleRate: 48000,
numberOfChannels: 2,
description: audioMetadata.decoderConfig?.description,
})
// Add chunks as they're encoded
encoder.configure({
output: (chunk, metadata) => muxer.addVideoChunk(chunk, metadata),
})
// Finalize and get output
await muxer.flush()
const mp4Data = muxer.finalize() // Uint8Array
fs.writeFileSync('output.mp4', mp4Data)
muxer.close()Demuxer Usage
Demuxers extract encoded video/audio chunks from container files (MP4, WebM, MKV).
// Create demuxer with callbacks
const demuxer = new Mp4Demuxer({
videoOutput: (chunk) => videoDecoder.decode(chunk),
audioOutput: (chunk) => audioDecoder.decode(chunk),
error: (err) => console.error(err),
})
// Load from file path or buffer
await demuxer.load('./video.mp4')
// or: await demuxer.loadBuffer(uint8Array)
// Get decoder configs for VideoDecoder/AudioDecoder
const videoConfig = demuxer.videoDecoderConfig
const audioConfig = demuxer.audioDecoderConfig
videoDecoder.configure(videoConfig)
audioDecoder.configure(audioConfig)
// Get track info
console.log(demuxer.tracks) // Array of DemuxerTrackInfo
console.log(demuxer.duration) // Duration in microseconds
// Start demuxing (async, calls callbacks)
demuxer.demux() // Demux all packets
demuxer.demux(100) // Demux up to 100 packets
// Seek to timestamp (microseconds)
demuxer.seek(5_000_000) // Seek to 5 seconds
demuxer.close()Webcodecs in Node.js
@napi-rs/webcodecs
- W3C WebCodecs API compliant - Full implementation of the WebCodecs specification with native
DOMExceptionerrors - Video encoding/decoding - H.264, H.265, VP8, VP9, AV1
- Audio encoding/decoding - AAC, Opus, MP3, FLAC, Vorbis, PCM variants
- Image decoding - JPEG, PNG, WebP, GIF, BMP, AVIF
- Canvas integration - Create VideoFrames from
@napi-rs/canvasfor graphics and text rendering - Hardware acceleration - Zero-copy GPU encoding with VideoToolbox (macOS), NVENC (NVIDIA), VAAPI (Linux), QSV (Intel)
- Cross-platform - macOS, Windows, Linux (glibc/musl, x64/arm64/armv7)
Supported Codecs
Video
| Codec | Codec String | Encoding | Decoding |
|---|---|---|---|
| H.264 | avc1.* |
✅ | ✅ |
| H.265 | hev1.*, hvc1.* |
✅ | ✅ |
| VP8 | vp8 |
✅ | ✅ |
| VP9 | vp09.*, vp9 |
✅ | ✅ |
| AV1 | av01.*, av01, av1 |
✅ | ✅ |
Note: Short form codec strings (vp9, av01, av1) are accepted for compatibility with browser implementations.
Audio
| Codec | Codec String | Encoding | Decoding |
|---|---|---|---|
| AAC | mp4a.40.2 |
✅ | ✅ |
| Opus | opus |
✅ | ✅ |
| MP3 | mp3 |
✅ | ✅ |
| FLAC | flac |
✅ | ✅ |
| Vorbis | vorbis |
❌ | ✅ |
| PCM | pcm-* |
❌ | ✅ |
Image
| Format | MIME Type | Decoding |
|---|---|---|
| JPEG | image/jpeg |
✅ |
| PNG | image/png |
✅ |
| WebP | image/webp |
✅ |
| GIF | image/gif |
✅ |
| BMP | image/bmp |
✅ |
| AVIF | image/avif |
✅ |
Platform Support
Pre-built binaries are available for:
| Platform | Architecture |
|---|---|
| macOS | x64, arm64 |
| Windows | x64, arm64 |
| Linux (glibc) | x64, arm64 |
| Linux (musl) | x64, arm64 |
| Linux (glibc, gnueabihf) | armv7 |
FFmpeg n8.0.1 Static Builds
Pre-built FFmpeg n8.0.1 static libraries.
Included Libraries
- FFmpeg: avcodec, avutil, swscale, swresample
- Video: x264, x265, libvpx, libaom (Linux/arm64), rav1e (Windows x64)
- Audio: opus, mp3lame, vorbis
- Image: libwebp, libjxl
Targets
Linux
- x86_64-unknown-linux-gnu
- aarch64-unknown-linux-gnu
- armv7-unknown-linux-gnueabihf
- x86_64-unknown-linux-musl
- aarch64-unknown-linux-musl
Windows (MSVC)
- x86_64-pc-windows-msvc (uses rav1e for AV1 encoding)
- aarch64-pc-windows-msvc (uses libaom for AV1 encoding)
macOS (Static Libs Only)
- x86_64-apple-darwin (dav1d, libjxl + deps)
- aarch64-apple-darwin (dav1d, libjxl + deps)
Note: macOS builds use Homebrew FFmpeg. These archives contain only
the static libraries (dav1d, libjxl, highway, brotli, lcms2) that
Homebrew doesn't provide as static builds.
Verification
All artifacts are signed with GitHub Artifact Attestations.
Verify with: gh attestation verify <artifact> --repo Brooooooklyn/webcodecs-node