Skip to content

The VS Code of video editing, built for agents.

TypeScript

Enhance node capture functionality with resolution support

konstantin-paulus66a37207c253
diff --git a/apps/cli/src/index.ts b/apps/cli/src/index.ts
index fb4ecbd6..10b5c0fd 100644
--- a/apps/cli/src/index.ts
+++ b/apps/cli/src/index.ts
@@ -1341,7 +1341,7 @@ node
node
.command("capture")
.description(
- `Render a node in isolation to PNGs, one per position, each stamped in the top-left with its HH:MM:SS:FF timestamp. The node is drawn offscreen, tightly framed to its own bounds on a transparent background — siblings and overlapping scene content are not included, so capture a scene id to check composition ("what plays at time T": layout, overlaps, text, timing). For a video asset's own full-resolution pixels use \`media grab\`.`,
+ `Render a node in isolation to PNGs, one per position, each stamped in the top-left with its HH:MM:SS:FF timestamp. The node is drawn offscreen at 720p height, tightly framed to its own bounds on a transparent background — siblings and overlapping scene content are not included, so capture a scene id to check composition ("what plays at time T": layout, overlaps, text, timing). For a video asset's own full-resolution pixels use \`media grab\`.`,
)
.argument("<id>", "node id to capture")
.option("-t, --time <time...>", `one or more positions to capture, relative to the node's start (0 = its first visible frame) — seconds ("1.5"), frames ("45f"), or "MM:SS" (default: the node's frame under the current playhead)`)
diff --git a/apps/web/src/components/engine/encode/image-encoder.ts b/apps/web/src/components/engine/encode/image-encoder.ts
index 5f723773..53808377 100644
--- a/apps/web/src/components/engine/encode/image-encoder.ts
+++ b/apps/web/src/components/engine/encode/image-encoder.ts
@@ -28,6 +28,8 @@ type ImageEncoderConfig = {
frames: number[];
/** Stamp each capture with its HH:MM:SS:FF label (frame-relative). */
timestamp?: boolean;
+ /** Target output height in px (default: the entity's native size). */
+ resolution?: number;
};
export type ImageExportResult =
@@ -154,9 +156,15 @@ export async function createImageEncoder(sourceWorld: EngineWorld, config: Image
}
assert(Number.isFinite(bounds.minX), 'Entity is not visible at any of the requested frames');
- offscreenCanvas.width = Math.max(1, Math.ceil(bounds.maxX - bounds.minX));
- offscreenCanvas.height = Math.max(1, Math.ceil(bounds.maxY - bounds.minY));
- // Shift the measured box onto the canvas so the node is centered in view.
+ const boundsWidth = Math.max(1, bounds.maxX - bounds.minX);
+ const boundsHeight = Math.max(1, bounds.maxY - bounds.minY);
+ const scale = config.resolution ? config.resolution / boundsHeight : 1;
+
+ offscreenCanvas.width = Math.max(1, Math.round(boundsWidth * scale));
+ offscreenCanvas.height = Math.max(1, Math.round(boundsHeight * scale));
+ // Shift the measured box onto the canvas so the node is centered in view;
+ // the camera translation is scaled by world.resolution at render time.
+ world.resolution = scale;
world.camera.e = -bounds.minX;
world.camera.f = -bounds.minY;
diff --git a/apps/web/src/context/editor-api/node.ts b/apps/web/src/context/editor-api/node.ts
index a8d14aa0..6b33936b 100644
--- a/apps/web/src/context/editor-api/node.ts
+++ b/apps/web/src/context/editor-api/node.ts
@@ -306,6 +306,7 @@ export function handleNodeCapture(engine: Accessor<Engine>) {
eid,
frames: shots,
timestamp: timestamp !== false,
+ resolution: 720,
});
const result = await encoder.render();