This commit is contained in:
Alec Armbruster 2024-10-03 09:34:07 -07:00
parent 591903cab3
commit 10600a0d28
No known key found for this signature in database
GPG Key ID: 52BC7C84E960FD1B

View File

@ -1,49 +0,0 @@
import mime from "mime";
import LibAVWrapper from "$lib/libav";
let speed;
let processedDuration;
const ff = new LibAVWrapper(progress => {
if (progress.out_time_sec) {
processedDuration = progress.out_time_sec;
}
if (progress.speed) {
speed = progress.speed;
}
});
ff.init();
export const silentRemux = async (file: File) => {
if (file instanceof File && !file.type) {
file = new File([file], file.name, {
type: mime.getType(file.name) ?? undefined,
});
}
const render = await ff
.render({
blob: file,
args: ["-c", "copy", "-map", "0"],
})
.catch((e) => {
console.error("uh-oh! render error");
console.error(e);
});
if (!render) {
return console.log("not a valid file");
}
const filenameParts = file.name.split(".");
const filenameExt = filenameParts.pop();
const filename = `${filenameParts.join(".")} (remux).${filenameExt}`;
return new File([render], filename, {
type: render.type
})
}