Skip to content

The VS Code of video editing, built for agents.

TypeScript

Refactor timecode formatting in media frame and node capture outputs

konstantin-paulusb9c47a197520
diff --git a/apps/cli/src/index.ts b/apps/cli/src/index.ts
index de1ad13e..bfcebd4c 100644
--- a/apps/cli/src/index.ts
+++ b/apps/cli/src/index.ts
@@ -445,7 +445,7 @@ async function nodeCapture(id: string, opts: CaptureOptions): Promise<void> {
try {
const shots = await editor.node.capture.query({ id: eid, frames }, GENERATE);
for (const [i, { base64, timecode }] of shots.entries()) {
- const path = join(dir, `${timecode.replaceAll(":", "-")}.png`);
+ const path = join(dir, timecodeFilename(timecode));
writeFileSync(path, Buffer.from(base64, "base64"));
console.log(JSON.stringify({ time: times[i], path }));
}
@@ -526,7 +526,7 @@ async function mediaFrame(ref: string, opts: MediaFrameOptions): Promise<void> {
try {
const frames = await editor.media.frame.query({ ...target, times, count, start, end, quality, auto: opts.auto });
for (const { time, timecode, base64 } of frames) {
- const path = join(dir, `${timecode.replaceAll(":", "-")}.png`);
+ const path = join(dir, timecodeFilename(timecode));
writeFileSync(path, Buffer.from(base64, "base64"));
console.log(JSON.stringify({ time, path }));
}
@@ -614,6 +614,11 @@ function parseTimeArg(value: string, flag: string, allowNegative = false): numbe
return seconds;
}
+function timecodeFilename(timecode: string): string {
+ const [hh, mm, ss, ff] = timecode.split(":");
+ return `${hh}h${mm}m${ss}s${ff}f.png`;
+}
+
// Parse the window/scale flags shared by `filmstrip` and `waveform`.
function parsePreviewWindow(opts: MediaPreviewOptions): { start?: number; end?: number; scale?: number } {
const start = opts.start !== undefined ? parseTimeArg(opts.start, "--start") : undefined;
@@ -1304,7 +1309,7 @@ media
.command("grab")
.alias("sample")
.description(
- `Decode frames of a video file and write them as PNGs (local render, no credits), each named after its HH-MM-SS-FF timecode. Grabs the asset's own pixels at full resolution, unlike \`node capture\` which renders the composited node. The recommended tool for understanding a video at the frame level.`,
+ `Decode frames of a video file and write them as PNGs (local render, no credits), each named after its timecode (e.g. 00h00m01s15f.png). Grabs the asset's own pixels at full resolution, unlike \`node capture\` which renders the composited node. The recommended tool for understanding a video at the frame level.`,
)
.argument("<id|path>", "video asset id, or a local video file to grab frames from")
.option("-t, --time <time...>", `one or more timestamps to grab — seconds ("1.5"), frames ("45f"), or "MM:SS"; negatives count back from the end, so -1 is one second before the end and -1f one frame before it (default: 0)`)
@@ -1466,7 +1471,7 @@ node
node
.command("capture")
.description(
- `Render a node in isolation to PNGs, one per position, each named after the HH-MM-SS-FF timecode of the frame rendered. 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\`.`,
+ `Render a node in isolation to PNGs, one per position, each named after the timecode of the frame rendered (e.g. 00h00m01s15f.png). 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: 0, the node's first visible frame)`)
diff --git a/reference/media/grab.md b/reference/media/grab.md
index e30fbbdb..d2244b93 100644
--- a/reference/media/grab.md
+++ b/reference/media/grab.md
@@ -1,6 +1,6 @@
# `dapi media grab <id|path>`
-Decodes one or more frames of a video asset at the given times and writes each to a PNG file named after its `HH-MM-SS-FF` timecode (e.g. `00-00-01-12.png`); like [`node capture`](../node/capture.md), but grabs the asset's own pixels at full resolution (unlike `node capture`, which captures the composited canvas). Renders locally; no credits.
+Decodes one or more frames of a video asset at the given times and writes each to a PNG file named after its timecode, hours through frames (e.g. `00h00m01s12f.png`); like [`node capture`](../node/capture.md), but grabs the asset's own pixels at full resolution (unlike `node capture`, which captures the composited canvas). Renders locally; no credits.
## Input
@@ -18,7 +18,7 @@ Decodes one or more frames of a video asset at the given times and writes each t
JSON Lines, one object per requested timestamp, in the requested order:
```ts
-{ time: number; path: string } // time = the requested timestamp in seconds; path = the written PNG, named HH-MM-SS-FF.png
+{ time: number; path: string } // time = the requested timestamp in seconds; path = the written PNG, e.g. …/00h00m01s12f.png
```
## Errors
diff --git a/reference/node/capture.md b/reference/node/capture.md
index c751e3bd..81438790 100644
--- a/reference/node/capture.md
+++ b/reference/node/capture.md
@@ -1,6 +1,6 @@
# `dapi node capture <id> [-t, --time <time...>]`
-Renders a node in isolation and writes one PNG per timeline position, each named after the `HH-MM-SS-FF` timecode of the frame actually rendered (e.g. `00-00-01-12.png`). 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. To grab a video asset's own pixels at full resolution instead of the composited node, use [`media grab`](../media/grab.md).
+Renders a node in isolation and writes one PNG per timeline position, each named after the timecode of the frame actually rendered, hours through frames (e.g. `00h00m01s12f.png`). 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. To grab a video asset's own pixels at full resolution instead of the composited node, use [`media grab`](../media/grab.md).
## Input
@@ -14,5 +14,5 @@ Renders a node in isolation and writes one PNG per timeline position, each named
One JSON object per line (JSON Lines), in the order the times were given: the requested time in seconds and the absolute path to the written PNG.
```ts
-{ time: number, path: string } // e.g. { "time": 1.5, "path": "/tmp/dapi-capture-3f2c1a8e/00-00-01-15.png" }
+{ time: number, path: string } // e.g. { "time": 1.5, "path": "/tmp/dapi-capture-3f2c1a8e/00h00m01s15f.png" }
```