Skip to content

best way to save what you love

web/workers/remux: init libav only once, terminate after usage

wukko564fc652971d
diff --git a/web/src/lib/workers/remux.ts b/web/src/lib/workers/remux.ts
index 9f2dc60e..281b2594 100644
--- a/web/src/lib/workers/remux.ts
+++ b/web/src/lib/workers/remux.ts
@@ -11,26 +11,24 @@ const error = (code: string) => {
})
}
-const ff = new LibAVWrapper((progress) => {
- self.postMessage({
- cobaltRemuxWorker: {
- progress: {
- durationProcessed: progress.out_time_sec,
- speed: progress.speed,
- size: progress.total_size,
- currentFrame: progress.frame,
- fps: progress.fps,
- }
- }
- })
-});
-
-ff.init();
-
const remux = async (files: CobaltFileReference[], args: string[], output: FileInfo) => {
if (!(files && output && args)) return;
- await ff.init();
+ const ff = new LibAVWrapper((progress) => {
+ self.postMessage({
+ cobaltRemuxWorker: {
+ progress: {
+ durationProcessed: progress.out_time_sec,
+ speed: progress.speed,
+ size: progress.total_size,
+ currentFrame: progress.frame,
+ fps: progress.fps,
+ }
+ }
+ })
+ });
+
+ ff.init();
try {
// probing just the first file in files array (usually audio) for duration progress
@@ -84,6 +82,8 @@ const remux = async (files: CobaltFileReference[], args: string[], output: FileI
return error("incorrect input or output");
}
+ await ff.terminate();
+
self.postMessage({
cobaltRemuxWorker: {
render