commit 8829c872c949bf316f8d00a15ea6e514c7f3ec11
parent de9def531aa0cddaa229b7db482187db3f1ed641
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Thu, 5 Nov 2026 17:37:54 -0500
umtool: a preview renders what the take's render renders -- a quick take's veryfast segments, a crossfade only when the take's own patch sets a transition (as makeTake decides)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/umtool/lib/report/takePreview.mjs b/umtool/lib/report/takePreview.mjs
@@ -37,7 +37,7 @@ import { mkdir, readFile, rename, rm, stat, writeFile } from "node:fs/promises";
import path from "node:path";
import { promisify } from "node:util";
import { applyMontageRulings, readMontageRulings } from "umtool-report-to-video/montage-rulings";
-import { composeTake, checkSpec, estimatedSeconds, linkSharedOut, MANIFEST, sourcedEntries, windowManifest } from "./takeMaker.mjs";
+import { composeTake, checkSpec, estimatedSeconds, getPath, linkSharedOut, MANIFEST, mergePatch, QUICK_RENDER, sourcedEntries, windowManifest } from "./takeMaker.mjs";
import { takesDirOf, TAKE_FILE } from "./takes.mjs";
const execFileP = promisify(execFile);
@@ -450,10 +450,14 @@ async function storedSpec(projectDir, id) {
style: take.style ?? null,
patch: take.patch ?? null,
window: take.window ?? "full",
+ quick: take.quick === true,
}),
};
}
+/** As makeTake decides: a take crossfades only when its own patches set a transition (else its hard cuts). */
+const takeXfade = (c) => Number(c.manifest.render?.transition ?? 0) > 0 && c.patches.some((p) => getPath(p, "render.transition") !== undefined);
+
/** The manifest a base take rendered (its video.manifest.json), else its composition now (a draft). */
async function baseManifest(projectDir, from) {
const dir = path.join(takesDirOf(projectDir), from);
@@ -492,7 +496,7 @@ async function linkSources(projectDir, id, from, dst, { tierDir }) {
* One build of a render manifest into `outDir` (the take's preview or changes dir): through renderTake,
* the heavy slot and all, recorded in outDir/render.json and render.log. Resolves to the build's mp4.
*/
-async function buildInto(projectDir, { id, label, kind, renderDoc, outDir, from, opts }) {
+async function buildInto(projectDir, { id, label, kind, renderDoc, outDir, from, xfade, opts }) {
const recordMod = await import("./renderRecord.mjs");
await mkdir(outDir, { recursive: true });
const rec = await recordMod
@@ -515,7 +519,7 @@ async function buildInto(projectDir, { id, label, kind, renderDoc, outDir, from,
await writeFile(renderPath, JSON.stringify(renderDoc, null, 2) + "\n", "utf8");
const render = opts.render ?? (await import("./takeRender.mjs")).renderTake;
const t0 = Date.now();
- const { file } = await render({ manifestPath: renderPath, outDir, slug: String(renderDoc.slug ?? ""), full: false, xfade: Number(renderDoc.render?.transition ?? 0) > 0 && opts.xfade === true, keepFrames: false, emit, log, ...(opts.signal ? { signal: opts.signal } : {}) });
+ const { file } = await render({ manifestPath: renderPath, outDir, slug: String(renderDoc.slug ?? ""), full: false, xfade: xfade === true, keepFrames: false, emit, log, ...(opts.signal ? { signal: opts.signal } : {}) });
const made = await stat(file).catch(() => null);
if (!made?.isFile() || made.size === 0) throw new Error(`${id}: the ${kind} render wrote no mp4 (${file})`);
return { file, rec, log, renderSeconds: Math.round((Date.now() - t0) / 100) / 10 };
@@ -554,13 +558,14 @@ export async function previewTake(projectDir, id, opts = {}) {
if (from) await checkFrom(projectDir, id, from);
const log = opts.log ?? (() => {});
const c = await composeTake(projectDir, { ...spec, window: opts.window ?? spec.window ?? "full" }, { log });
- const renderDoc = atPreviewTier(c.renderDoc);
+ // A quick take's render is encoded veryfast (makeTake's QUICK_RENDER): its preview builds what it built.
+ const renderDoc = atPreviewTier(spec.quick ? /** @type {Record<string, any>} */ (mergePatch(c.renderDoc, QUICK_RENDER)) : c.renderDoc);
const takeDir = path.join(takesDirOf(projectDir), id);
const slug = String(c.manifest.slug ?? "");
const p = previewPaths(takeDir, slug);
const t = renderDoc.render.tier;
log(`${id}: a preview — ${t.width}x${t.height}, ${t.preset}, crf ${t.crf}${previewKnobs(c.renderDoc.render).segments === "preview" ? ", its segments at the tier too" : ""}; the full render's files untouched${from ? `; reusing ${from}'s` : ""}${take.draft ? " (a draft: its stored patch)" : ""}`);
- const b = await buildInto(projectDir, { id, label: spec.label, kind: PREVIEW_DIR, renderDoc, outDir: p.previewOut, from, opts });
+ const b = await buildInto(projectDir, { id, label: spec.label, kind: PREVIEW_DIR, renderDoc, outDir: p.previewOut, from, xfade: takeXfade(c), opts });
try {
await rename(b.file, p.previewMp4);
} catch (e) {
@@ -703,7 +708,7 @@ export async function changesTake(projectDir, id, opts = {}) {
if (preview) renderDoc = atPreviewTier(renderDoc, { segments: "preview" });
log(`${id}: rendering ${want.size} entr${want.size === 1 ? "y" : "ies"} in ${runs.length} run(s): ${runs.map((r) => r.ids.join(" ")).join(" | ")}`);
const since = Date.now();
- const b = await buildInto(projectDir, { id, label: spec.label, kind: CHANGES_DIR, renderDoc, outDir: p.changesOut, from, opts });
+ const b = await buildInto(projectDir, { id, label: spec.label, kind: CHANGES_DIR, renderDoc, outDir: p.changesOut, from, xfade: takeXfade(c), opts });
try {
const built = await buildPlaces(path.join(p.changesOut, "sourced"), [...want].sort((x, y) => ids.indexOf(x) - ids.indexOf(y)), since);
const measured = new Map([...changedIds].filter((x) => built.places.has(x)).map((x) => [x, built.places.get(x).duration]));