# @audio/decode-avi

> Decode the audio stream of AVI files (PCM, MP3, AAC, µ-law, A-law) to PCM samples

Latest version **1.1.0** (published 2026-08-27) · MIT license · 0 weekly downloads

## Install

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

## 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.1.0 |
| Published | 2026-08-27 |
| First published | 2026-08-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18 |
| Dependencies | 4 |
| Unpacked size | 15.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 208 |
| Author | audiojs |
| Maintainers | jamen, dfcreative, dy |
| Keywords | avi, riff, opendml, demux, video, audio, decode, decoder, pcm, mp3, aac |

## Links

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

## Dependencies (4)

- [@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

## 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.1.0 (latest) — 2026-08-27
- 1.0.0 — 2026-08-27

## README

# @audio/decode-avi

Decode the audio stream of AVI files to PCM float samples.<br>
A pure-JS RIFF/AVI demuxer (OpenDML `AVIX` extensions included) that skips the video stream and routes the audio to the matching codec package, loaded on demand.

[![npm install @audio/decode-avi](https://nodei.co/npm/@audio/decode-avi.png?mini=true)](https://npmjs.org/package/@audio/decode-avi/)

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

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

let dec = await decoder()
let head = await dec.decode(chunk1)   // Promise on the chunk that completes the stream headers
let more = dec.decode(chunk2)         // synchronous from then on
let tail = await dec.flush()
dec.free()
```

## Codecs

| `wFormatTag` | Codec | Decoded by |
|---|---|---|
| `0x0001`, `0x0003` (and `WAVE_FORMAT_EXTENSIBLE`) | PCM 8–32 bit int, 32/64 bit float | built in |
| `0x0006`, `0x0007` | G.711 A-law, µ-law | built in |
| `0x0055` | MP3 | [@audio/decode-mp3](../decode-mp3) |
| `0x00FF` | AAC | [@audio/decode-aac](../decode-aac) |
| `0x2000` | AC-3 | [@audio/decode-ac3](../decode-ac3) |
| `0x2001` | DTS | [@audio/decode-dts](../decode-dts) |

WMA and ADPCM streams throw an error naming the codec. The first `auds` stream is decoded.

Codec packages are imported dynamically, which is unavailable inside an AudioWorklet — decode in the main thread or a Worker.

## API

### `decode(src: Uint8Array | ArrayBuffer): Promise<AudioData>`

Decode a complete file.

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

Streaming decoder. `decode(chunk)` returns `AudioData`, or a Promise of it on the chunk that completes the stream headers while the codec module loads. `flush()` returns remaining samples and throws if no audio stream was found. `free()` releases codec resources.

### `AudioData`

```ts
{ channelData: Float32Array[], sampleRate: number }
```

## License

[ॐ](https://github.com/krishnized/license/) · [MIT](./LICENSE). Codec packages carry their own licenses.

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