# @audio/decode-webm

> Decode WebM / Matroska audio (Opus, Vorbis, AAC, MP3, FLAC, ALAC, PCM) to PCM samples

Latest version **1.6.1** (published 2026-08-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install @audio/decode-webm
pnpm add @audio/decode-webm
yarn add @audio/decode-webm
bun add @audio/decode-webm
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.6.1 |
| Published | 2026-08-29 |
| First published | 2026-04-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18 |
| Dependencies | 8 |
| Unpacked size | 262.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 208 |
| Author | audiojs |
| Maintainers | jamen, dfcreative, dy |
| Keywords | webm, matroska, ebml, opus, vorbis, audio, decode, decoder, pcm, mkv, aac, mp3, flac, alac, video, demux |

## Links

- npm: https://www.npmjs.com/package/@audio/decode-webm
- Repository: https://github.com/audiojs/decode
- Homepage: https://github.com/audiojs/decode/tree/master/packages/decode-webm#readme
- Issues: https://github.com/audiojs/decode/issues
- Funding: https://github.com/sponsors/audiojs
- npm.io page: https://npm.io/package/@audio/decode-webm

## Dependencies (8)

- [@audio/decode-aac](https://npm.io/package/@audio/decode-aac.md) ^1.5.0
- [@audio/decode-ac3](https://npm.io/package/@audio/decode-ac3.md) ^1.0.0
- [@audio/decode-dts](https://npm.io/package/@audio/decode-dts.md) ^1.0.0
- [@audio/decode-mp3](https://npm.io/package/@audio/decode-mp3.md) ^1.3.0
- [@audio/decode-eac3](https://npm.io/package/@audio/decode-eac3.md) ^1.0.0
- [@audio/decode-flac](https://npm.io/package/@audio/decode-flac.md) ^1.3.0
- [@audio/decode-opus](https://npm.io/package/@audio/decode-opus.md) ^1.3.0
- [@audio/decode-vorbis](https://npm.io/package/@audio/decode-vorbis.md) ^1.3.0

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 1.6.1 (latest) — 2026-08-29
- 1.6.0 — 2026-08-27
- 1.5.0 — 2026-08-27
- 1.4.1 — 2026-08-12
- 1.4.0 — 2026-08-11
- 1.3.3 — 2026-07-14
- 1.3.2 — 2026-07-11
- 1.3.1 — 2026-07-10
- 1.3.0 — 2026-07-10
- 1.2.2 — 2026-07-09
- 1.2.1 — 2026-04-11
- 1.2.0 — 2026-04-10
- 1.1.0 — 2026-04-05
- 1.0.0 — 2026-04-04

## README

# @audio/decode-webm

Decode WebM and Matroska (MKV) audio to PCM float samples — the audio track of video files included (Opus, Vorbis, AAC, ALAC, MP3, FLAC, AC-3, DTS, PCM).

## Install

```
npm i @audio/decode-webm
```

## Usage

```js
import decode, { decoder } from '@audio/decode-webm'

let { channelData, sampleRate } = await decode(webmBytes)

let dec = await decoder() // initialize Opus and Vorbis WASM
let result = dec.decode(chunk)
let tail = dec.flush()
dec.free()
```

Video tracks are skipped; the first audio track is decoded. Laced blocks (Xiph, EBML, fixed) are split into frames.

## API

### `decode(src): Promise<AudioData>`

Decode a complete `Uint8Array` or `ArrayBuffer`.

### `decoder(): Promise<WebmDecoder>`

Initialize the codec runtimes and return a streaming decoder. For the WebM codecs (Opus, Vorbis) `decode()` and `flush()` are synchronous. For Matroska-only codecs the call that completes the track header returns a Promise while the codec package loads; later calls are synchronous. `flush()` ends the stream.

The factory prepares the Opus and Vorbis runtimes, then releases what the track does not need once the header is read.

## Codecs

| CodecID | Decoded by |
|---|---|
| `A_OPUS` | bundled libopus WASM core from [@audio/decode-opus](../decode-opus) |
| `A_VORBIS` | bundled [@audio/decode-vorbis](../decode-vorbis) |
| `A_AAC` (all profiles) | [@audio/decode-aac](../decode-aac), loaded on demand |
| `A_ALAC` | [@audio/decode-aac](../decode-aac), loaded on demand |
| `A_MPEG/L3` | [@audio/decode-mp3](../decode-mp3), loaded on demand |
| `A_FLAC` | [@audio/decode-flac](../decode-flac), loaded on demand |
| `A_PCM/INT/LIT`, `A_PCM/INT/BIG`, `A_PCM/FLOAT/IEEE` | built in |
| `A_AC3` | [@audio/decode-ac3](../decode-ac3), loaded on demand |
| `A_DTS` (core of DTS-HD too) | [@audio/decode-dts](../decode-dts), loaded on demand |
| `A_EAC3` | [@audio/decode-eac3](../decode-eac3), loaded on demand |

TrueHD, MPEG Layer I/II, WavPack, TTA and `A_MS/ACM` tracks throw an error naming the codec. `DiscardPadding` on Opus blocks is honoured, so files from @audio/encode-webm decode sample-exact.

On-demand codec packages are imported dynamically, which is unavailable inside an AudioWorklet — Opus and Vorbis work there, the others need the main thread or a Worker.

## License

[ॐ](https://github.com/krishnized/license/) · [MIT](./LICENSE). Bundled [libopus](https://opus-codec.org/) is [BSD 3-Clause](./LICENSE.libopus).

---
_Source: https://npm.io/package/@audio/decode-webm · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
