mirror of
https://github.com/wukko/cobalt.git
synced 2025-02-15 23:36:37 +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,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) => {
|
const remux = async (files: CobaltFileReference[], args: string[], output: FileInfo) => {
|
||||||
if (!(files && output && args)) return;
|
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 {
|
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
|
||||||
|
@ -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