web: make everything ssr-compatible

This commit is contained in:
dumbmoron
2024-08-31 17:46:10 +00:00
parent 4b4fce326f
commit 51c140fbfa
9 changed files with 91 additions and 53 deletions

View File

@@ -2,6 +2,7 @@ import mime from "mime";
import LibAV, { type LibAV as LibAVInstance } from "@imput/libav.js-remux-cli";
import type { FFmpegProgressCallback, FFmpegProgressEvent, FFmpegProgressStatus, FileInfo, RenderParams } from "./types/libav";
import type { FfprobeData } from "fluent-ffmpeg";
import { browser } from "$app/environment";
export default class LibAVWrapper {
libav: Promise<LibAVInstance> | null;
@@ -10,12 +11,12 @@ export default class LibAVWrapper {
constructor(onProgress?: FFmpegProgressCallback) {
this.libav = null;
this.concurrency = Math.min(4, navigator.hardwareConcurrency);
this.concurrency = Math.min(4, browser ? navigator.hardwareConcurrency : 0);
this.onProgress = onProgress;
}
async init() {
if (!this.libav) {
if (this.concurrency && !this.libav) {
this.libav = LibAV.LibAV({
yesthreads: true,
base: '/_libav'