Rillke/opusenc.js
Rillke/opusenc.js has 101 GitHub stars and 9 forks. GitHot measured 0 stars in 24 hours. Last checked 2026-11-16 19:56 UTC. Last push 2026-10-16.
Measured star growth
- in 24h
- 0
- in 7 days
- Collecting history
- in 15 days
- Collecting history
- in 1 month
- Collecting history
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
About
JavaScript opus encoder
Creative & MediaREADME.md
Originalopusenc.js 
JavaScript Opus (audio format) Encoder
Project Website • Minimal demo
Opusenc.js encodes whole files to ogg-opus; this is Opus encapsulated into an Ogg container. It is supposed to do the same as the opusenc tool from the opus-tools collection and as such supports features like Vorbis comment, preserving some metadata, reading AIF, WAV, and FLAC (in its native container).
This version of opusenc.js was built with Emscripten 6.0.12; flac 1.5.0; libogg 1.3.6; opus 1.6.1; libopusenc 0.3; opus-tools 0.2
If the browser supports WebAssembly, that is used. Otherwise, a pure JavaScript build (created with wasm2js) is used as a fallback.
Building
If you just want to use opusenc.js, you don't have to build it. In this case, see using instead.
Prerequisites
- A recent linux build system including autoconf, automake, libtool, gettext/autopoint and pkg-config
- Emscripten installed and activated
Build script
git clone --recursive https://github.com/Rillke/opusenc.js.git opusenc.js
cd opusenc.js
./make.sh
After building, make.sh serves the demo using emrun; pass --no-run to skip this.
Using
A pre-compiled script together with some auxiliary scripts making use from JavaScript easier is in the /worker directory.
iframe.html is a minimal usage example. Test it live. It starts the encoding process posting command: 'encode' to the worker:
var worker = new Worker( 'worker/EmsWorkerProxy.js' );
// Files to be read and posted back
// after encoding completed
var outData = {
// File name
'encoded.opus': {
// MIME type
'MIME': 'audio/ogg'
}
};
worker.onmessage = function( e ) {
// Handle incoming data
};
// Prepare files etc.
// Post all data and the encode command
// to the web worker
worker.postMessage( {
command: 'encode',
args: args,
outData: outData,
fileData: storedFiles
} );
command:'encode'|'prefetch'DOMString that either starts encoding or prefetching the 850 KiB worker script. Posting a prefetch command in advance is optional, depends on the user experience you'd like to create and does not require further arguments. If the script is not prefetched, it will be downloaded when'encode'is invoked.args: Array holding the command line arguments (DOMString)outData: Object literal of information about the files that should be read out of the worker's file system after encoding completedfileData: Object literal of input file data mapping file names toUint8Arrays
A more extensive example is available on the project's website.
Testing
npm install
npm test # Lint
npx playwright install chromium # Once, or use firefox / webkit too
npm run test:browser # Encode files in real browsers
The browser tests in test/browser run opusenc.js in Chromium, Firefox and WebKit using Playwright. They encode WAV, AIFF and FLAC files with the worker, validate the resulting Ogg Opus files, decode them with the browser's own decoder, and exercise the demo page. They run on GitHub Actions against both the committed build and a fresh build.
Contributing
Submit patches to this GitHub repository or file issues.
License
See LICENSE.md
Open source Opus JS ports
| Implementation | Primary focus | Implementation details |
|---|---|---|
| opusenc.js | JS-Port of the opusenc command line tool (encoding from and to files); encoding larger but not huge chunks of audio to Ogg-Opus files, showcase/Opus evangelism | Written in JS; Emscripten hybrid WASM with asm.js fallback; building on Xiph.org's opusenc (which is part of opus tools) |
| opus.js-sample | De-, encoder and resampler for raw Opus (without container) | Written in Typescript; Web-Worker; codec and resampler ported with Emscripten to asm.js; building on Xiph.org's reference implementation of opus en-/decoder |
| opus-recorder | Recorder (audio source like microphone); Ogg-Opus de-and encoder and resampler | Custom Ogg implementation purely in JS; npm and bower packaging; building on Xiph.org's reference implementation of opus and speexdsp; new versions WASM-only; Old versions asm.js-only |
| audiocogs/opus.js | Modular system decoding and playing Ogg-Opus as well as a lot of other audio formats (any if an appropriate plugin is available) | aurora.js (CoffeeScript) plugin; building on Xiph.org's reference implementation of opus; npm packaging; asm.js which is not labeled as such |
| howler.js | Audio playback shim with special effects (probably good for games) | Pure JavaScript; no Opus support compiled into; uses browser APIs for decoding and playback |
| opus-stream.js | Opus streaming solution with de-/encoding and resampling support offering raw and packaged streaming with adjustable buffer sizes; server-side example component | Emscripten hybrid WASM with asm.js fallback, npm and bower packaging |
Losless audio codec required?
Try flac.js.