@glissade/cli 0.4.2 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +7 -2
- package/dist/index.d.ts +2 -0
- package/dist/music.js +39 -0
- package/dist/render.js +13 -1
- package/package.json +8 -8
package/dist/cli.js
CHANGED
|
@@ -53,6 +53,7 @@ render options:
|
|
|
53
53
|
--state <name> render one machine state's timeline linearly
|
|
54
54
|
--force downgrade a trace hash mismatch to a warning
|
|
55
55
|
--captions <m> burn (default) | sidecar | off; burn/sidecar also write .srt/.vtt
|
|
56
|
+
--music <m> auto (default): mix a sibling *.music.timing.json bed, ducked under narration | off
|
|
56
57
|
|
|
57
58
|
dev options:
|
|
58
59
|
--record add a Record button; writes .trace.json sidecars next to the module
|
|
@@ -135,12 +136,16 @@ async function main() {
|
|
|
135
136
|
...flags.has("state") ? { state: flags.get("state") } : {},
|
|
136
137
|
...flags.has("force") ? { force: true } : {},
|
|
137
138
|
captions: parseCaptionsModeOrFail(flags.get("captions")),
|
|
139
|
+
music: flags.get("music") === "off" ? "off" : "auto",
|
|
138
140
|
onProgress: (n, total) => {
|
|
139
|
-
if (
|
|
141
|
+
if (process.stderr.isTTY) {
|
|
142
|
+
if (n % 30 === 0 || n === total) process.stderr.write(`\rrendering ${n}/${total} frames`);
|
|
143
|
+
} else if (n % 300 === 0 || n === total) process.stderr.write(`rendering ${n}/${total} frames\n`);
|
|
140
144
|
}
|
|
141
145
|
});
|
|
142
146
|
const secs = ((performance.now() - started) / 1e3).toFixed(2);
|
|
143
|
-
process.stderr.
|
|
147
|
+
const cr = process.stderr.isTTY ? "\r" : "";
|
|
148
|
+
process.stderr.write(`${cr}rendered ${result.frames} frames in ${secs}s → ${result.out}\n`);
|
|
144
149
|
} catch (err) {
|
|
145
150
|
fail(err instanceof Error ? err.message : String(err));
|
|
146
151
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,8 @@ interface RenderOptions {
|
|
|
18
18
|
force?: boolean;
|
|
19
19
|
/** burn (default): captions render in-frame; sidecar/off hide the caption node. */
|
|
20
20
|
captions?: 'burn' | 'sidecar' | 'off';
|
|
21
|
+
/** auto (default): mix a sibling *.music.timing.json bed, ducked under narration. */
|
|
22
|
+
music?: 'auto' | 'off';
|
|
21
23
|
onProgress?: (frame: number, total: number) => void;
|
|
22
24
|
}
|
|
23
25
|
declare class SceneModuleError extends Error {
|
package/dist/music.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { music, validateMusicTiming } from "@glissade/narrate";
|
|
3
|
+
//#region src/music.ts
|
|
4
|
+
/**
|
|
5
|
+
* Render-time music auto-mix (the narration parity): a committed
|
|
6
|
+
* `<module>.music.timing.json` with a `stem` field next to the scene mixes
|
|
7
|
+
* its bed automatically — and when a narration timing manifest ALSO sits
|
|
8
|
+
* there, the bed auto-ducks under the voice. Zero-config
|
|
9
|
+
* narrated-explainer-with-bed; everything derives from the two manifests.
|
|
10
|
+
*/
|
|
11
|
+
/** `<module>.music.timing.json`, when the scene has a music bed. */
|
|
12
|
+
function musicPathFor(modulePath) {
|
|
13
|
+
const candidate = modulePath.replace(/\.[jt]sx?$/, "") + ".music.timing.json";
|
|
14
|
+
return existsSync(candidate) ? candidate : null;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Build the bed clip from the manifests. The stem path stays relative — the
|
|
18
|
+
* manifest sits next to the module, and the mixer resolves clip urls against
|
|
19
|
+
* the module dir, so the bases coincide.
|
|
20
|
+
*/
|
|
21
|
+
function buildMusicClip(musicManifestPath, narrationTimingPath) {
|
|
22
|
+
const timing = JSON.parse(readFileSync(musicManifestPath, "utf8"));
|
|
23
|
+
validateMusicTiming(timing);
|
|
24
|
+
if (!timing.stem) return null;
|
|
25
|
+
const anchors = music(timing);
|
|
26
|
+
if (narrationTimingPath) {
|
|
27
|
+
const narration = JSON.parse(readFileSync(narrationTimingPath, "utf8"));
|
|
28
|
+
return {
|
|
29
|
+
clip: anchors.clip(void 0, { duckUnder: narration }),
|
|
30
|
+
note: `music bed '${timing.stem}'${timing.gainDb ? ` at ${timing.gainDb}dB` : ""}, ducked under narration`
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
clip: anchors.clip(),
|
|
35
|
+
note: `music bed '${timing.stem}'${timing.gainDb ? ` at ${timing.gainDb}dB` : ""}`
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
export { buildMusicClip, musicPathFor };
|
package/dist/render.js
CHANGED
|
@@ -130,8 +130,20 @@ async function render(opts) {
|
|
|
130
130
|
"+faststart"
|
|
131
131
|
]
|
|
132
132
|
];
|
|
133
|
+
const audioClips = [...compiled.audio];
|
|
134
|
+
if ((opts.music ?? "auto") === "auto") {
|
|
135
|
+
const { buildMusicClip, musicPathFor } = await import("./music.js");
|
|
136
|
+
const musicPath = musicPathFor(opts.modulePath);
|
|
137
|
+
if (musicPath) {
|
|
138
|
+
const bed = buildMusicClip(musicPath, timingPathFor(opts.modulePath));
|
|
139
|
+
if (bed) {
|
|
140
|
+
audioClips.push(bed.clip);
|
|
141
|
+
process.stderr.write(`note: auto-mixing ${bed.note}\n`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
133
145
|
const { planAudioMix } = await import("./audioMix.js").then((n) => n.r);
|
|
134
|
-
const mix = planAudioMix(
|
|
146
|
+
const mix = planAudioMix(audioClips, opts.modulePath, duration);
|
|
135
147
|
if (mix?.hasEasedGain) process.stderr.write("note: eased gain keys are approximated linearly in the FFmpeg mix\n");
|
|
136
148
|
const audioInputs = mix ? mix.inputs.flatMap((p) => ["-i", p]) : [];
|
|
137
149
|
const audioEnc = mix ? pickEncoder("audio", container) : null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glissade/cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"description": "glissade CLI: headless rendering via backend-skia (+ FFmpeg mux).",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -20,13 +20,13 @@
|
|
|
20
20
|
"@napi-rs/canvas": "^0.1.65",
|
|
21
21
|
"esbuild": "^0.28.0",
|
|
22
22
|
"jiti": "^2.4.2",
|
|
23
|
-
"@glissade/backend-skia": "0.4.
|
|
24
|
-
"@glissade/core": "0.4.
|
|
25
|
-
"@glissade/interact": "0.4.
|
|
26
|
-
"@glissade/lottie": "0.4.
|
|
27
|
-
"@glissade/narrate": "0.4.
|
|
28
|
-
"@glissade/player": "0.4.
|
|
29
|
-
"@glissade/scene": "0.4.
|
|
23
|
+
"@glissade/backend-skia": "0.4.4",
|
|
24
|
+
"@glissade/core": "0.4.4",
|
|
25
|
+
"@glissade/interact": "0.4.4",
|
|
26
|
+
"@glissade/lottie": "0.4.4",
|
|
27
|
+
"@glissade/narrate": "0.4.4",
|
|
28
|
+
"@glissade/player": "0.4.4",
|
|
29
|
+
"@glissade/scene": "0.4.4"
|
|
30
30
|
},
|
|
31
31
|
"repository": {
|
|
32
32
|
"type": "git",
|