From 2b987a6efb632ec0e372c3aefb564a304ee468c0 Mon Sep 17 00:00:00 2001 From: dumbmoron Date: Tue, 3 Sep 2024 18:40:43 +0000 Subject: [PATCH] web/encode: expect cleanup() to be called before libav is initialized --- web/src/lib/libav/encode.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/web/src/lib/libav/encode.ts b/web/src/lib/libav/encode.ts index 3d6cbeca..679b5421 100644 --- a/web/src/lib/libav/encode.ts +++ b/web/src/lib/libav/encode.ts @@ -47,15 +47,18 @@ export default class EncodeLibAV extends LibAVWrapper { } async cleanup() { - const { libav } = await this.#get(); + let libav; + try { + ({ libav } = await this.#get()); + } catch {} if (this.#has_file) { - await libav.unlinkreadaheadfile('input'); + if (libav) await libav.unlinkreadaheadfile('input'); this.#has_file = false; } 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.#istreams = undefined; }