From 181606156fa5ee457f322610b952d8058b11a247 Mon Sep 17 00:00:00 2001 From: lashman Date: Tue, 12 May 2026 01:41:25 +0300 Subject: [PATCH] live readout below target-size slider --- src/lib/Main.svelte | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/lib/Main.svelte b/src/lib/Main.svelte index 0a383f5..3b4a95c 100644 --- a/src/lib/Main.svelte +++ b/src/lib/Main.svelte @@ -204,6 +204,23 @@ let trimmedDuration = $derived(Math.max(0.1, trimEnd - trimStart)) + let previewDims = $derived.by(() => { + if (!clip) return "..." + if (format === "gif") { + const bytesPerPixelPerFrame = 0.5 + const frames = Math.max(1, fps * trimmedDuration) + const budget = (targetMB * 1_048_576) / (frames * bytesPerPixelPerFrame) + const aspect = clip.height === 0 ? 16 / 9 : clip.width / clip.height + const wRaw = Math.sqrt(budget * aspect) + const w = Math.min(clip.width, Math.max(120, Math.round(wRaw))) + const h = Math.round(w / aspect) + const w2 = (w >> 1) << 1 + const h2 = (h >> 1) << 1 + return `${w2}x${h2}` + } + return `${clip.width}x${clip.height}` + }) + async function doExport() { if (!clip) return errMsg = null @@ -400,6 +417,9 @@
{targetMB.toFixed(1)} MB
+

+ {targetMB.toFixed(1)} MB → {previewDims} at {fps}fps, {trimmedDuration.toFixed(1)}s +