From f1b1c650ce9a05576cbf395eb58ff4087881696e Mon Sep 17 00:00:00 2001 From: chloe caruso Date: Mon, 7 Jul 2025 09:42:04 -0700 Subject: [PATCH] initial run of scan3 on sandwich --- flake.lock | 61 ++++++++++++++++++++++++++++++++++++ flake.nix | 25 +++++++++++++++ framework/bundle.ts | 4 +-- framework/hot.ts | 2 +- readme.md | 3 ++ src/file-viewer/bin/scan3.ts | 7 +++-- src/file-viewer/ffmpeg.ts | 3 +- 7 files changed, 98 insertions(+), 7 deletions(-) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..978cae1 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1751271578, + "narHash": "sha256-P/SQmKDu06x8yv7i0s8bvnnuJYkxVGBWLWHaU+tt4YY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "3016b4b15d13f3089db8a41ef937b13a9e33a8df", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "utils": "utils" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..715bd5a --- /dev/null +++ b/flake.nix @@ -0,0 +1,25 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + utils.url = "github:numtide/flake-utils"; + }; + outputs = + { nixpkgs, utils, ... }: + utils.lib.eachDefaultSystem ( + system: + let + pkgs = nixpkgs.legacyPackages.${system}; + in + { + devShells.default = pkgs.mkShell { + buildInputs = [ + pkgs.nodejs_24 # runtime + pkgs.deno # formatter + (pkgs.ffmpeg.override { + withSvtav1 = true; + }) + ]; + }; + } + ); +} diff --git a/framework/bundle.ts b/framework/bundle.ts index e00ccd6..16afbaf 100644 --- a/framework/bundle.ts +++ b/framework/bundle.ts @@ -40,7 +40,7 @@ export async function bundleClientJavaScript( logLevel: "silent", metafile: true, minify: !dev, - outdir: "/out!", + outdir: "out!", plugins: clientPlugins, write: false, define: { @@ -174,7 +174,7 @@ export async function bundleServerJavaScript( platform: "node", format: "esm", minify: false, - outdir: "/out!", + outdir: "out!", plugins: serverPlugins, splitting: true, logLevel: "silent", diff --git a/framework/hot.ts b/framework/hot.ts index 6b4f6a7..987fabd 100644 --- a/framework/hot.ts +++ b/framework/hot.ts @@ -96,7 +96,7 @@ Module._resolveFilename = (...args) => { try { return require.resolve(replacedPath, { paths: [projectSrc] }); } catch (err: any) { - if (err.code === "MODULE_NOT_FOUND" && err.requireStack.length <= 1) { + if (err.code === "MODULE_NOT_FOUND" && (err?.requireStack?.length ?? 0) <= 1) { err.message.replace(replacedPath, args[0]); } } diff --git a/readme.md b/readme.md index e28c480..7fba8c2 100644 --- a/readme.md +++ b/readme.md @@ -67,6 +67,9 @@ node run watch +for unix systems, the provided `flake.nix` can be used with `nix develop` to +open a shell with all needed system dependencies. + ## Contributions No contributions to `src` accepted, only `framework`. diff --git a/src/file-viewer/bin/scan3.ts b/src/file-viewer/bin/scan3.ts index 1ffae57..a95ed9b 100644 --- a/src/file-viewer/bin/scan3.ts +++ b/src/file-viewer/bin/scan3.ts @@ -10,7 +10,7 @@ // This is the third iteration of the scanner, hence its name "scan3"; // Remember that any software you want to be maintainable and high // quality cannot be written with AI. -const root = path.resolve("C:/media"); +const root = path.resolve("/Volumes/clover/Published"); const workDir = path.resolve(".clover/file-assets"); export async function main() { @@ -118,7 +118,7 @@ export async function main() { }, getItemText: (job) => job.publicPath.slice(1) + (job.stat ? "" : " (deleted)"), - maxJobs: 2, + maxJobs: 10, }); using qProcess = new async.Queue({ name: "Process Contents", @@ -136,7 +136,7 @@ export async function main() { }, getItemText: ({ mediaFile, processor }) => `${mediaFile.path.slice(1)} - ${processor.name}`, - maxJobs: 1, + maxJobs: 4, }); function decodeProcessors(input: string) { @@ -442,6 +442,7 @@ const procVideos = transcodeRules.videoFormats.map((preset) => ({ include: rules.extsVideo, enable: ffmpegBin != null, async run({ absPath, mediaFile, spin }) { + if ((mediaFile.duration ?? 0) < 10) return; await produceAsset(`${mediaFile.hash}/${preset.id}`, async (base) => { base = path.dirname(base); await fs.mkdir(base); diff --git a/src/file-viewer/ffmpeg.ts b/src/file-viewer/ffmpeg.ts index 4546f90..2a864c9 100644 --- a/src/file-viewer/ffmpeg.ts +++ b/src/file-viewer/ffmpeg.ts @@ -28,7 +28,7 @@ export interface SpawnOptions { export async function spawn(options: SpawnOptions) { const { ffmpeg = "ffmpeg", args, title, cwd } = options; - const proc = child_process.spawn(ffmpeg, args, { + const proc = child_process.spawn(ffmpeg, [...defaultExtraOptions, ...args], { stdio: ["ignore", "inherit", "pipe"], env: { ...process.env, SVT_LOG: "2" }, cwd, @@ -59,6 +59,7 @@ export async function spawn(options: SpawnOptions) { } else result satisfies never; }); const [code, signal] = await events.once(proc, "close"); + running = false; if (code !== 0) { const fmt = code ? `code ${code}` : `signal ${signal}`; const e: any = new Error(`ffmpeg failed with ${fmt}`);