audio

@audio/decode-opus1.3.3

Decode Ogg Opus audio with local libopus WASM

Status
calibrated
Updated
Family
decode, 24 packages under it
Category
codecs
Licence
MIT AND BSD-3-Clause AND LGPL-3.0-or-later
Bundles
codec-parser, gpl-3.0, libopus
Dependencies
none
Downloads
768,577 last month
Tests
at least 88 in audiojs/decode's CI, passed at 58c36d8,

Decode Ogg Opus audio to PCM samples with libopus WASM.

import decode, { decoder } from '@audio/decode-opus'

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

let dec = await decoder() // initialize WASM
let a = dec.decode(chunk1)
let b = dec.decode(chunk2)
let tail = dec.flush()
dec.free()

decoder() is asynchronous. Its decode() and flush() methods are synchronous. flush() ends the stream.

Metadata

Read OpusTags metadata and cover art without decoding audio:

import { parseMeta } from '@audio/decode-opus/meta'

let { meta, sampleRate } = parseMeta(opusBytes)
// meta: { title, artist, album, year, genre, ..., pictures }

License

ॐ · MIT. Bundled libopus is BSD 3-Clause. src/decode-opus.js bundles codec-parser, LGPL-3.0-or-later (LICENSE.codec-parser). The bundled codec-parser is version 2.5.0, and the last step of this repository's build.sh builds src/decode-opus.js from src/decode-opus.src.js with esbuild, so it can be rebuilt with a modified codec-parser; the GNU GPL that the LGPL-3.0 supplements is in LICENSE.gpl-3.0.