web/libav: add getter for libav instance

This commit is contained in:
dumbmoron 2024-08-16 20:56:24 +00:00
parent a78f272848
commit 226162f91f
No known key found for this signature in database

View file

@ -31,9 +31,13 @@ export default class LibAVWrapper {
} }
} }
async probe(blob: Blob) { async #get() {
if (!this.libav) throw new Error("LibAV wasn't initialized"); if (!this.libav) throw new Error("LibAV wasn't initialized");
const libav = await this.libav; return await this.libav;
}
async probe(blob: Blob) {
const libav = await this.#get();
await libav.mkreadaheadfile('input', blob); await libav.mkreadaheadfile('input', blob);
@ -72,8 +76,8 @@ export default class LibAVWrapper {
} }
async remux({ blob, output, args }: RenderParams) { async remux({ blob, output, args }: RenderParams) {
if (!this.libav) throw new Error("LibAV wasn't initialized"); const libav = await this.#get();
const libav = await this.libav;
const inputKind = blob.type.split("/")[0]; const inputKind = blob.type.split("/")[0];
const inputExtension = LibAVWrapper.getExtensionFromType(blob); const inputExtension = LibAVWrapper.getExtensionFromType(blob);
@ -230,4 +234,4 @@ export default class LibAVWrapper {
this.onProgress(progress); this.onProgress(progress);
} }
} }