mirror of
https://github.com/wukko/cobalt.git
synced 2025-02-13 22:26:28 +01:00
web/workers/remux: init libav only once, terminate after usage
This commit is contained in:
parent
ff62a4c2e6
commit
564fc65297
1 changed files with 17 additions and 17 deletions
|
@ -11,6 +11,9 @@ const error = (code: string) => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const remux = async (files: CobaltFileReference[], args: string[], output: FileInfo) => {
|
||||||
|
if (!(files && output && args)) return;
|
||||||
|
|
||||||
const ff = new LibAVWrapper((progress) => {
|
const ff = new LibAVWrapper((progress) => {
|
||||||
self.postMessage({
|
self.postMessage({
|
||||||
cobaltRemuxWorker: {
|
cobaltRemuxWorker: {
|
||||||
|
@ -27,11 +30,6 @@ const ff = new LibAVWrapper((progress) => {
|
||||||
|
|
||||||
ff.init();
|
ff.init();
|
||||||
|
|
||||||
const remux = async (files: CobaltFileReference[], args: string[], output: FileInfo) => {
|
|
||||||
if (!(files && output && args)) return;
|
|
||||||
|
|
||||||
await ff.init();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// probing just the first file in files array (usually audio) for duration progress
|
// probing just the first file in files array (usually audio) for duration progress
|
||||||
const probeFile = files[0]?.file;
|
const probeFile = files[0]?.file;
|
||||||
|
@ -84,6 +82,8 @@ const remux = async (files: CobaltFileReference[], args: string[], output: FileI
|
||||||
return error("incorrect input or output");
|
return error("incorrect input or output");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await ff.terminate();
|
||||||
|
|
||||||
self.postMessage({
|
self.postMessage({
|
||||||
cobaltRemuxWorker: {
|
cobaltRemuxWorker: {
|
||||||
render
|
render
|
||||||
|
|
Loading…
Reference in a new issue