web/encode: expect cleanup() to be called before libav is initialized

This commit is contained in:
dumbmoron 2024-09-03 18:40:43 +00:00
parent 050375526f
commit 2b987a6efb
No known key found for this signature in database

View file

@ -47,15 +47,18 @@ export default class EncodeLibAV extends LibAVWrapper {
} }
async cleanup() { async cleanup() {
const { libav } = await this.#get(); let libav;
try {
({ libav } = await this.#get());
} catch {}
if (this.#has_file) { if (this.#has_file) {
await libav.unlinkreadaheadfile('input'); if (libav) await libav.unlinkreadaheadfile('input');
this.#has_file = false; this.#has_file = false;
} }
if (this.#fmt_ctx) { if (this.#fmt_ctx) {
await libav.avformat_close_input_js(this.#fmt_ctx); if (libav) await libav.avformat_close_input_js(this.#fmt_ctx);
this.#fmt_ctx = undefined; this.#fmt_ctx = undefined;
this.#istreams = undefined; this.#istreams = undefined;
} }