Opus decoder: `TypeError: this._input is undefined` for sync and `TypeError: decoder is undefined` for web worker
Closed this issue · 2 comments
Trying to integrate these libraries for consistent decoding, but having issues with Opus.
Important snippets of my code (installed the lib via NPM, building using webpack):
import { OggOpusDecoder } from "ogg-opus-decoder";
const decoderOpus = new OggOpusDecoder({ forceStereo: true });
await decoderOpus.ready;
const decoded = await this.decoderOpus.decodeFile(view);This produces the following traceback:
Uncaught (in promise) TypeError: this._input is undefined
_decode OpusDecoder.js:87
decodeFrames OpusDecoder.js:157
_decode OggOpusDecoder.js:92
decodeFile OggOpusDecoder.js:154
...my code
When changing to the web worker impl I just get TypeError: decoder is undefined, with the debugger pointing at the start of the wasm blob:
const decoderOpus = new OggOpusDecoder({ forceStereo: true }); await decoderOpus.ready; const decoded = await this.decoderOpus.decodeFile(view);
I assume you mean not to use this when referencing the decoderOpus variable. It should be:
const decoded = await decoderOpus.decodeFile(view);Where are you running your code, a browser or Node (or other runtime)? If it's a browser, you can check to see if decodeFile works by trying out the demo page.
Do you have any minification set up in your Webpack build configuration? Sometimes this can rename object references incorrectly causing the property names to no longer match. If you have minification enabled, try disabling it or running it with a debug setting.
Otherwise, I don't see anything wrong with the examples you provided, it should just work.
I assume you mean not to use this when referencing the decoderOpus variable. It should be:
Yes, that was a bad copy-paste from my actual code, where the decoder lives inside a class.
With a fresh mind I looked at the issue again and worked out the problem - I was using the same decoder to decode 2 songs at once. The first one completed, called decoder.reset, which unsets this._input and kills the other decode stage.
By simply using 2 decoders, the problem is solved. Thanks for your help!
