@phil65/demoreel 0.7.1 → 0.8.0
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/README.md +22 -3
- package/dist/args.js +8 -0
- package/dist/cli.js +43 -1
- package/dist/compose.d.ts +3 -0
- package/dist/compose.js +16 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/layout.d.ts +10 -1
- package/dist/layout.js +41 -0
- package/dist/marks.d.ts +7 -12
- package/dist/marks.js +73 -43
- package/dist/mcp.js +35 -0
- package/dist/music.d.ts +81 -0
- package/dist/music.js +344 -0
- package/dist/project.d.ts +16 -2
- package/dist/project.js +25 -14
- package/dist/record.d.ts +3 -0
- package/dist/record.js +1 -0
- package/dist/render.d.ts +4 -0
- package/dist/render.js +52 -15
- package/dist/scene.d.ts +6 -0
- package/dist/scene.js +27 -3
- package/dist/types.d.ts +2 -0
- package/dist/voice.d.ts +10 -1
- package/dist/voice.js +31 -0
- package/package.json +1 -1
- package/skills/demoreel/SKILL.md +4 -3
package/README.md
CHANGED
|
@@ -110,8 +110,8 @@ Each run writes into `out/<name>/`:
|
|
|
110
110
|
| `say(text, [opts], [fn])` | voiceover narration via `@phil65/anyvoice` (free Edge TTS by default, OpenAI, ElevenLabs, Gemini, Cartesia, Deepgram); supports `say(text, async (cue) => { await cue.at("word"); ... })` + `.vtt` subtitles |
|
|
111
111
|
| `zoom(target, { depth, duration, context, wait })` | explicit zoom (integer tier `1..6`: 1.25x..5x) overriding auto zooms |
|
|
112
112
|
| `highlight(target, { duration, color, dim, badge, zoom })` | outline with optional spotlight dim backdrop and callout badge |
|
|
113
|
-
| `blur(target, { type, shape, intensity, duration })` | blur or pixelate (`type: "mosaic"`) sensitive UI elements (alias `redact()`;
|
|
114
|
-
| `arrow(target, { direction, color, duration })` | draw a crisp OpenScreen vector arrow pointing at an element |
|
|
113
|
+
| `blur(target, { type, shape, intensity, mode, duration })` | blur or pixelate (`type: "mosaic"`) sensitive UI elements (alias `redact()`; DOM Gaussian blurs track scroll & zoom automatically; defaults to `"end"`) |
|
|
114
|
+
| `arrow(target, { direction, color, duration })` | draw a crisp camera-tracked OpenScreen vector arrow pointing at an element |
|
|
115
115
|
| `image(src, { x, y, width, height, duration })` | overlay a local PNG/JPG/SVG/WebP image or `data:image/...` URL on the rendered canvas |
|
|
116
116
|
|
|
117
117
|
`target` is a structured accessibility-first spec (`{ role, name?, exact?, nth? }`,
|
|
@@ -128,7 +128,8 @@ JSON, relative to the scenario file), `colorScheme`, `seed`, `pacing`
|
|
|
128
128
|
(`wallpaper`, `padding`, `borderRadius`, `shadowIntensity`, `showBlur`, `crop`, `aspectRatio`,
|
|
129
129
|
`captionPosition`, `captionFontSize`, `captionAnimation`, `showKeys`, `watermark`), `cursor` (`size`, `clickBounce`, `smoothing`, `motionBlur`,
|
|
130
130
|
`show`), `clickRipple`, `trimIdle` (`true` or `{ minMs, keepMs, mode, speed, ignoreFrames }`),
|
|
131
|
-
`voice` (`{ provider: "edge" | "openai" | "elevenlabs" | "gemini" | "cartesia" | "deepgram", voice, model, language, speed, pitch, volume, instructions, gapMs, padMs, captions: "vtt" | "burned" | "off", cacheDir }`)
|
|
131
|
+
`voice` (`{ provider: "edge" | "openai" | "elevenlabs" | "gemini" | "cartesia" | "deepgram", voice, model, language, speed, pitch, volume, instructions, gapMs, padMs, captions: "vtt" | "burned" | "off", cacheDir }`),
|
|
132
|
+
`music` (`"./bed.mp3"`, `"https://..."`, or `{ src?, provider?: "elevenlabs" | "gemini", prompt?, model?, instrumental?, volume?, duck?, fadeInMs?, fadeOutMs?, loop?, startOffsetMs?, cacheDir? }`).
|
|
132
133
|
|
|
133
134
|
### Voiceover narration (`scene.say`)
|
|
134
135
|
|
|
@@ -158,6 +159,24 @@ export default defineScenario({
|
|
|
158
159
|
- `demoreel render` / `demoreel rezoom --render` stream-copy the OpenScreen H.264 video (`-c:v copy`), mux all cues into AAC audio at post-trim timestamps, and write `<name>.vtt`.
|
|
159
160
|
- Override provider or voice at run time without editing the scenario: `--voice-provider openai --voice nova` or `--no-voice`.
|
|
160
161
|
|
|
162
|
+
### Background music (`music`)
|
|
163
|
+
|
|
164
|
+
Layer a local track, cached HTTP(S) URL, or AI-generated instrumental bed (ElevenLabs Music via `ELEVENLABS_API_KEY` or Google Lyria via `GEMINI_API_KEY`). Tracks automatically loop/trim to the rendered duration, fade in/out cleanly, and **auto-duck smoothly under `scene.say()` voiceover cues** in the same `-c:v copy` ffmpeg pass:
|
|
165
|
+
|
|
166
|
+
```ts
|
|
167
|
+
export default defineScenario({
|
|
168
|
+
name: "launch",
|
|
169
|
+
// Static file or URL (cached on disk):
|
|
170
|
+
music: { src: "./bed.mp3", volume: 0.18, duck: 0.3, fadeInMs: 800, fadeOutMs: 1500 },
|
|
171
|
+
// Or AI-generated (SHA-256 cached by prompt + 5s duration bucket):
|
|
172
|
+
// music: { provider: "elevenlabs", prompt: "minimal upbeat lo-fi synth, instrumental" },
|
|
173
|
+
// music: { provider: "gemini", prompt: "warm clean acoustic tech background" },
|
|
174
|
+
async run(scene) { /* ... */ },
|
|
175
|
+
});
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Override on the CLI or MCP without editing the scenario: `--music ./bed.mp3`, `--music-provider elevenlabs --music-prompt "..."`, or `--no-music` (works on both `run` and `render`).
|
|
179
|
+
|
|
161
180
|
Library: `recordScenario`, `dryRunScenario`, `resolveStorageState`, `deriveZoomRegions`,
|
|
162
181
|
`deriveIdleRegions`, `buildProject`, `buildCursorData`, `buildMarks`, `renderProject`,
|
|
163
182
|
`validateProject`, `rezoom`, `reviewSheet`, `extractFrame`, `exportGif`, `createMcpServer`,
|
package/dist/args.js
CHANGED
|
@@ -27,6 +27,10 @@ export const COMMANDS = {
|
|
|
27
27
|
"voice-provider": { type: "string", value: "NAME", description: "override voiceover TTS provider: edge (free) | openai | elevenlabs | gemini | cartesia | deepgram" },
|
|
28
28
|
voice: { type: "string", value: "ID", description: "override voiceover voice ID" },
|
|
29
29
|
"no-voice": { type: "boolean", description: "skip voiceover TTS synthesis for this run" },
|
|
30
|
+
music: { type: "string", value: "PATH|URL", description: "background music bed (local audio file or HTTP(S) URL)" },
|
|
31
|
+
"music-provider": { type: "string", value: "NAME", description: "AI background music provider: elevenlabs | gemini (Lyria)" },
|
|
32
|
+
"music-prompt": { type: "string", value: "TEXT", description: "prompt for AI background music generation" },
|
|
33
|
+
"no-music": { type: "boolean", description: "disable background music for this run" },
|
|
30
34
|
headed: { type: "boolean", description: "show the browser while recording" },
|
|
31
35
|
frames,
|
|
32
36
|
framesheet,
|
|
@@ -39,6 +43,10 @@ export const COMMANDS = {
|
|
|
39
43
|
positionals: { min: 1, max: 1 },
|
|
40
44
|
flags: {
|
|
41
45
|
out: { type: "string", alias: "o", value: "FILE", description: "output MP4 (default: next to the project)" },
|
|
46
|
+
music: { type: "string", value: "PATH|URL", description: "override background music bed (local audio file or HTTP(S) URL)" },
|
|
47
|
+
"music-provider": { type: "string", value: "NAME", description: "AI background music provider: elevenlabs | gemini (Lyria)" },
|
|
48
|
+
"music-prompt": { type: "string", value: "TEXT", description: "prompt for AI background music generation" },
|
|
49
|
+
"no-music": { type: "boolean", description: "disable background music for this render" },
|
|
42
50
|
gpu,
|
|
43
51
|
fps,
|
|
44
52
|
quality,
|
package/dist/cli.js
CHANGED
|
@@ -9,6 +9,7 @@ import { checkFfmpeg, DemoreelError, detectGpu, launchChromium } from "./env.js"
|
|
|
9
9
|
import { exportGif } from "./gif.js";
|
|
10
10
|
import { initProject } from "./init.js";
|
|
11
11
|
import { loadScenario } from "./load.js";
|
|
12
|
+
import { MUSIC_PROVIDERS, normalizeMusicConfig } from "./music.js";
|
|
12
13
|
import { PACKAGE_ROOT } from "./openscreen.js";
|
|
13
14
|
import { dryRunScenario, recordScenario, resolveStorageState } from "./record.js";
|
|
14
15
|
import { renderProject, validateProject } from "./render.js";
|
|
@@ -32,12 +33,42 @@ function progressPrinter(enabled) {
|
|
|
32
33
|
};
|
|
33
34
|
}
|
|
34
35
|
function printRender(r) {
|
|
35
|
-
|
|
36
|
+
const audioNote = r.audioMuxed ? (r.musicMuxed ? " + audio/music" : " + audio") : "";
|
|
37
|
+
log(` rendered ${r.width}x${r.height} ${(r.bytes / 1e6).toFixed(1)} MB in ${fmt(r.renderMs)} (${r.gpu ? "GPU" : "software"}, setup ${fmt(r.setupMs)})${audioNote} -> ${r.outputPath}`);
|
|
36
38
|
if (r.vttPath)
|
|
37
39
|
log(` subtitles: ${r.vttPath}`);
|
|
38
40
|
if (r.warnings.length)
|
|
39
41
|
log(` warnings: ${r.warnings.join("; ")}`);
|
|
40
42
|
}
|
|
43
|
+
function musicFlagOverride(flags, base) {
|
|
44
|
+
if (flags.music === undefined && flags["music-provider"] === undefined && flags["music-prompt"] === undefined && !flags["no-music"]) {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
const m = { ...base };
|
|
48
|
+
if (flags["no-music"])
|
|
49
|
+
m.enabled = false;
|
|
50
|
+
if (typeof flags.music === "string") {
|
|
51
|
+
m.src = /^https?:\/\//i.test(flags.music) ? flags.music : path.resolve(flags.music);
|
|
52
|
+
delete m.provider;
|
|
53
|
+
delete m.prompt;
|
|
54
|
+
m.enabled = true;
|
|
55
|
+
}
|
|
56
|
+
if (flags["music-provider"] !== undefined) {
|
|
57
|
+
const p = String(flags["music-provider"]);
|
|
58
|
+
if (!MUSIC_PROVIDERS.includes(p)) {
|
|
59
|
+
throw new UsageError(`--music-provider must be ${MUSIC_PROVIDERS.join(", ")}`);
|
|
60
|
+
}
|
|
61
|
+
m.provider = p;
|
|
62
|
+
delete m.src;
|
|
63
|
+
m.enabled = true;
|
|
64
|
+
}
|
|
65
|
+
if (typeof flags["music-prompt"] === "string") {
|
|
66
|
+
m.prompt = flags["music-prompt"];
|
|
67
|
+
delete m.src;
|
|
68
|
+
m.enabled = true;
|
|
69
|
+
}
|
|
70
|
+
return m;
|
|
71
|
+
}
|
|
41
72
|
function renderFlags(flags) {
|
|
42
73
|
const q = flags.quality;
|
|
43
74
|
if (q && !["medium", "good", "source"].includes(q))
|
|
@@ -80,6 +111,9 @@ async function cmdRun({ positionals, flags }) {
|
|
|
80
111
|
voice.voice = flags.voice;
|
|
81
112
|
overrides.voice = voice;
|
|
82
113
|
}
|
|
114
|
+
const musicOverride = musicFlagOverride(flags, normalizeMusicConfig(scenario.music));
|
|
115
|
+
if (musicOverride)
|
|
116
|
+
overrides.music = musicOverride;
|
|
83
117
|
const storageState = flags.state ? String(flags.state) : undefined;
|
|
84
118
|
if (flags["dry-run"]) {
|
|
85
119
|
const res = await dryRunScenario(scenario, {
|
|
@@ -122,11 +156,17 @@ async function cmdRun({ positionals, flags }) {
|
|
|
122
156
|
log(` marks: ${rec.marksPath}`);
|
|
123
157
|
if (flags.render === false)
|
|
124
158
|
return;
|
|
159
|
+
const baseMusic = normalizeMusicConfig(scenario.music);
|
|
160
|
+
const resolvedScenarioMusic = baseMusic?.src && !/^https?:\/\//i.test(baseMusic.src) && !path.isAbsolute(baseMusic.src)
|
|
161
|
+
? { ...baseMusic, src: path.resolve(path.dirname(file), baseMusic.src) }
|
|
162
|
+
: baseMusic;
|
|
163
|
+
const effectiveMusic = musicOverride ?? resolvedScenarioMusic;
|
|
125
164
|
const mp4 = path.join(out, `${scenario.name}.mp4`);
|
|
126
165
|
const r = await renderProject({
|
|
127
166
|
projectPath: rec.projectPath,
|
|
128
167
|
outputPath: mp4,
|
|
129
168
|
cursor: scenario.cursor,
|
|
169
|
+
...(effectiveMusic ? { music: effectiveMusic } : {}),
|
|
130
170
|
...renderFlags(flags),
|
|
131
171
|
log,
|
|
132
172
|
onProgress: progressPrinter(true),
|
|
@@ -154,9 +194,11 @@ async function cmdRun({ positionals, flags }) {
|
|
|
154
194
|
}
|
|
155
195
|
async function cmdRender({ positionals, flags }) {
|
|
156
196
|
const projectPath = path.resolve(positionals[0]);
|
|
197
|
+
const music = musicFlagOverride(flags);
|
|
157
198
|
const r = await renderProject({
|
|
158
199
|
projectPath,
|
|
159
200
|
outputPath: flags.out ? path.resolve(String(flags.out)) : undefined,
|
|
201
|
+
...(music ? { music } : {}),
|
|
160
202
|
...renderFlags(flags),
|
|
161
203
|
log,
|
|
162
204
|
onProgress: progressPrinter(true),
|
package/dist/compose.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type IdleOptions } from "./idle.ts";
|
|
2
2
|
import { type Marks } from "./marks.ts";
|
|
3
|
+
import { type MusicConfig, type MusicInput } from "./music.ts";
|
|
3
4
|
import { buildProject, type LookOptions } from "./project.ts";
|
|
4
5
|
import type { CursorStyle } from "./render.ts";
|
|
5
6
|
import type { ActionRecord, ArrowAnnotation, BlurAnnotation, Caption, CursorSample, ImageAnnotation, SpeedRegion, TrimRegion, Viewport, VoiceCue, ZoomRegion } from "./types.ts";
|
|
@@ -23,6 +24,7 @@ export interface Timeline {
|
|
|
23
24
|
trimIdle: Partial<IdleOptions> | false;
|
|
24
25
|
cursor?: CursorStyle;
|
|
25
26
|
voice?: Omit<VoiceConfig, "apiKey">;
|
|
27
|
+
music?: Omit<MusicConfig, "apiKey">;
|
|
26
28
|
};
|
|
27
29
|
actions: ActionRecord[];
|
|
28
30
|
zoomRegions: ZoomRegion[];
|
|
@@ -69,6 +71,7 @@ export interface ComposeInput {
|
|
|
69
71
|
trimIdle?: Partial<IdleOptions> | boolean;
|
|
70
72
|
cursor?: CursorStyle;
|
|
71
73
|
voice?: VoiceConfig;
|
|
74
|
+
music?: MusicInput;
|
|
72
75
|
}
|
|
73
76
|
export interface ComposeResult {
|
|
74
77
|
timeline: Timeline;
|
package/dist/compose.js
CHANGED
|
@@ -8,6 +8,7 @@ import path from "node:path";
|
|
|
8
8
|
import { deriveIdleRegions, sourceToOutputMs } from "./idle.js";
|
|
9
9
|
import { stageLayout } from "./layout.js";
|
|
10
10
|
import { buildMarks, placeCaptions, targetRects } from "./marks.js";
|
|
11
|
+
import { normalizeMusicConfig } from "./music.js";
|
|
11
12
|
import { buildCursorData, buildProject, DEFAULT_LOOK } from "./project.js";
|
|
12
13
|
import { deriveZoomRegions } from "./zoom.js";
|
|
13
14
|
export const TIMELINE_VERSION = 1;
|
|
@@ -76,17 +77,29 @@ export function compose(input, opts = {}) {
|
|
|
76
77
|
durationMs: input.durationMs,
|
|
77
78
|
actions: input.actions,
|
|
78
79
|
captions,
|
|
80
|
+
blurs: input.blurs,
|
|
81
|
+
arrows: input.arrows,
|
|
82
|
+
images: resolvedImages,
|
|
79
83
|
voiceCues,
|
|
80
84
|
zoomRegions,
|
|
81
85
|
trimRegions,
|
|
82
86
|
speedRegions,
|
|
83
87
|
layout,
|
|
84
|
-
look,
|
|
88
|
+
look: resolvedLook,
|
|
85
89
|
});
|
|
86
90
|
const marksPath = path.join(input.outDir, "marks.json");
|
|
87
91
|
fs.writeFileSync(marksPath, JSON.stringify(marks, null, 1));
|
|
88
92
|
// Never persist secret apiKey into timeline.json.
|
|
89
93
|
const safeVoice = input.voice ? (({ apiKey: _k, ...rest }) => rest)(input.voice) : undefined;
|
|
94
|
+
const normMusic = normalizeMusicConfig(input.music);
|
|
95
|
+
const safeMusic = normMusic
|
|
96
|
+
? (({ apiKey: _k, ...rest }) => ({
|
|
97
|
+
...rest,
|
|
98
|
+
...(rest.src && !/^https?:\/\//i.test(rest.src) && !path.isAbsolute(rest.src)
|
|
99
|
+
? { src: path.resolve(input.baseDir ?? process.cwd(), rest.src) }
|
|
100
|
+
: {}),
|
|
101
|
+
}))(normMusic)
|
|
102
|
+
: undefined;
|
|
90
103
|
const timeline = {
|
|
91
104
|
version: TIMELINE_VERSION,
|
|
92
105
|
scenario: input.name,
|
|
@@ -107,6 +120,7 @@ export function compose(input, opts = {}) {
|
|
|
107
120
|
trimIdle: idleOpts ?? false,
|
|
108
121
|
...(input.cursor ? { cursor: input.cursor } : {}),
|
|
109
122
|
...(safeVoice ? { voice: safeVoice } : {}),
|
|
123
|
+
...(safeMusic ? { music: safeMusic } : {}),
|
|
110
124
|
},
|
|
111
125
|
actions: input.actions.map(roundAction),
|
|
112
126
|
zoomRegions,
|
|
@@ -188,5 +202,6 @@ export function rezoom(dir, overrides = {}) {
|
|
|
188
202
|
trimIdle: trimIdle ?? false,
|
|
189
203
|
cursor,
|
|
190
204
|
voice: tl.options?.voice,
|
|
205
|
+
music: tl.options?.music,
|
|
191
206
|
}, { keepProjectFrom: overrides.look ? undefined : projectPath });
|
|
192
207
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/** demoreel: scripted product demo videos (videos as code), rendered by OpenScreen's exporter. */
|
|
2
2
|
export { type DryRunError, type DryRunOptions, type DryRunResult, type RecordOptions, type RecordResult, type Scenario, type ScenarioContext, defineScenario, dryRunScenario, recordScenario, resolveStorageState, } from "./record.ts";
|
|
3
3
|
export { type ActionOptions, applyZoomAnchor, type ArrowOptions, type BlurOptions, type ClickRippleOptions, DEFAULT_PACING, describeTarget, type HighlightOptions, type ImageOptions, type PacingOptions, type PressOptions, resolveTarget, type SayOptions, Scene, type SceneClock, type Target, type TargetSpec, type VoiceCueHandle, ZOOM_ATTRIBUTE, type ZoomOptions as SceneZoomOptions, } from "./scene.ts";
|
|
4
|
-
export { buildVoiceVtt, createVoiceSynthesizer, DEFAULT_VOICE_GAP_MS, DEFAULT_VOICE_PAD_MS, findWordTiming, formatDryRunVoiceSummary, formatVoiceSummary, lintVoiceCues, muxVoiceTrack, type SayDeliveryOptions, type SynthesizedCue, type VoiceConfig, type VoiceFinding, VOICE_PROVIDERS, type VoiceProviderName, type VoiceSynthesizer, } from "./voice.ts";
|
|
4
|
+
export { buildVoiceVtt, chunkVoiceCaptions, createVoiceSynthesizer, DEFAULT_VOICE_GAP_MS, DEFAULT_VOICE_PAD_MS, findWordTiming, formatDryRunVoiceSummary, formatVoiceSummary, lintVoiceCues, muxVoiceTrack, type SayDeliveryOptions, type SynthesizedCue, type VoiceConfig, type VoiceFinding, VOICE_PROVIDERS, type VoiceProviderName, type VoiceSynthesizer, } from "./voice.ts";
|
|
5
|
+
export { bucketMusicDurationMs, buildDuckingVolumeExpr, defaultMusicCacheDir, extractLyriaAudio, MUSIC_PROVIDERS, type MusicConfig, type MusicInput, type MusicProviderName, muxAudioTracks, type MuxAudioOptions, normalizeMusicConfig, type ResolvedMusicTrack, resolveMusicTrack, } from "./music.ts";
|
|
5
6
|
export { DEFAULT_ZOOM_OPTIONS, DEPTH_SCALES, deriveZoomRegions, depthForBox, normalizeDepth, type ZoomOptions } from "./zoom.ts";
|
|
6
7
|
export { DEFAULT_IDLE_OPTIONS, deriveIdleRegions, idleIntervals, type IdleOptions, sourceToOutputMs } from "./idle.ts";
|
|
7
8
|
export { arrowAnnotations, blurAnnotations, buildCursorData, buildProject, type BuildProjectOptions, captionAnnotations, DEFAULT_LOOK, formatKeycap, imageAnnotations, keycapAnnotations, type KeyHudOptions, type KeyHudPosition, keycapRect, type LookOptions, normalizeSamples, type OpenScreenProject, resolveImageDataUrl, type WatermarkOptions, type WatermarkPosition, writeProject, } from "./project.ts";
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/** demoreel: scripted product demo videos (videos as code), rendered by OpenScreen's exporter. */
|
|
2
2
|
export { defineScenario, dryRunScenario, recordScenario, resolveStorageState, } from "./record.js";
|
|
3
3
|
export { applyZoomAnchor, DEFAULT_PACING, describeTarget, resolveTarget, Scene, ZOOM_ATTRIBUTE, } from "./scene.js";
|
|
4
|
-
export { buildVoiceVtt, createVoiceSynthesizer, DEFAULT_VOICE_GAP_MS, DEFAULT_VOICE_PAD_MS, findWordTiming, formatDryRunVoiceSummary, formatVoiceSummary, lintVoiceCues, muxVoiceTrack, VOICE_PROVIDERS, } from "./voice.js";
|
|
4
|
+
export { buildVoiceVtt, chunkVoiceCaptions, createVoiceSynthesizer, DEFAULT_VOICE_GAP_MS, DEFAULT_VOICE_PAD_MS, findWordTiming, formatDryRunVoiceSummary, formatVoiceSummary, lintVoiceCues, muxVoiceTrack, VOICE_PROVIDERS, } from "./voice.js";
|
|
5
|
+
export { bucketMusicDurationMs, buildDuckingVolumeExpr, defaultMusicCacheDir, extractLyriaAudio, MUSIC_PROVIDERS, muxAudioTracks, normalizeMusicConfig, resolveMusicTrack, } from "./music.js";
|
|
5
6
|
export { DEFAULT_ZOOM_OPTIONS, DEPTH_SCALES, deriveZoomRegions, depthForBox, normalizeDepth } from "./zoom.js";
|
|
6
7
|
export { DEFAULT_IDLE_OPTIONS, deriveIdleRegions, idleIntervals, sourceToOutputMs } from "./idle.js";
|
|
7
8
|
export { arrowAnnotations, blurAnnotations, buildCursorData, buildProject, captionAnnotations, DEFAULT_LOOK, formatKeycap, imageAnnotations, keycapAnnotations, keycapRect, normalizeSamples, resolveImageDataUrl, writeProject, } from "./project.js";
|
package/dist/layout.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* compositeLayout.ts::centerRect, focusUtils.ts::clampFocusToScale and
|
|
5
5
|
* zoomTransform.ts::computeZoomTransform for the no-webcam, no-crop case demoreel writes.
|
|
6
6
|
*/
|
|
7
|
-
import type { Box, Depth, Viewport } from "./types.ts";
|
|
7
|
+
import type { Box, Depth, Viewport, ZoomRegion } from "./types.ts";
|
|
8
8
|
/** OpenScreen ZOOM_DEPTH_SCALES (src/components/video-editor/types.ts). */
|
|
9
9
|
export declare const DEPTH_SCALES: Record<Depth, number>;
|
|
10
10
|
/** A rectangle in stage-normalised coordinates (0-1 of the output canvas). */
|
|
@@ -50,3 +50,12 @@ export declare function zoomRect(r: NormRect, depth: Depth, focus: {
|
|
|
50
50
|
}): NormRect;
|
|
51
51
|
/** Clips a rect to the unit square; null if nothing is left. */
|
|
52
52
|
export declare function clipUnit(r: NormRect): NormRect | null;
|
|
53
|
+
/** Approximate zoom progress (0-1) of a region at recording time t. */
|
|
54
|
+
export declare function zoomProgress(r: ZoomRegion, t: number): number;
|
|
55
|
+
/** The camera at time t: the dominant zoom region and its progress. */
|
|
56
|
+
export declare function cameraAt(regions: ZoomRegion[], t: number): {
|
|
57
|
+
region: ZoomRegion;
|
|
58
|
+
p: number;
|
|
59
|
+
} | null;
|
|
60
|
+
/** Stage rect -> output-frame rect under the camera at time t (OpenScreen computeZoomTransform). */
|
|
61
|
+
export declare function applyCamera(rect: NormRect, regions: ZoomRegion[], t: number): NormRect;
|
package/dist/layout.js
CHANGED
|
@@ -53,3 +53,44 @@ export function clipUnit(r) {
|
|
|
53
53
|
return null;
|
|
54
54
|
return { x: x0, y: y0, w: x1 - x0, h: y1 - y0 };
|
|
55
55
|
}
|
|
56
|
+
const ZOOM_IN_BEFORE_MS = 1022;
|
|
57
|
+
const ZOOM_IN_AFTER_MS = 500;
|
|
58
|
+
const ZOOM_OUT_MS = 1016;
|
|
59
|
+
const smooth = (x) => {
|
|
60
|
+
const t = Math.min(1, Math.max(0, x));
|
|
61
|
+
return t * t * (3 - 2 * t);
|
|
62
|
+
};
|
|
63
|
+
/** Approximate zoom progress (0-1) of a region at recording time t. */
|
|
64
|
+
export function zoomProgress(r, t) {
|
|
65
|
+
const inStart = r.startMs - ZOOM_IN_BEFORE_MS;
|
|
66
|
+
if (t <= inStart || t >= r.endMs + ZOOM_OUT_MS)
|
|
67
|
+
return 0;
|
|
68
|
+
if (t < r.startMs + ZOOM_IN_AFTER_MS)
|
|
69
|
+
return smooth((t - inStart) / (ZOOM_IN_BEFORE_MS + ZOOM_IN_AFTER_MS));
|
|
70
|
+
if (t <= r.endMs)
|
|
71
|
+
return 1;
|
|
72
|
+
return 1 - smooth((t - r.endMs) / ZOOM_OUT_MS);
|
|
73
|
+
}
|
|
74
|
+
/** The camera at time t: the dominant zoom region and its progress. */
|
|
75
|
+
export function cameraAt(regions, t) {
|
|
76
|
+
let best = null;
|
|
77
|
+
for (const r of regions) {
|
|
78
|
+
const p = zoomProgress(r, t);
|
|
79
|
+
if (p > 0 && (!best || p > best.p))
|
|
80
|
+
best = { region: r, p };
|
|
81
|
+
}
|
|
82
|
+
return best;
|
|
83
|
+
}
|
|
84
|
+
/** Stage rect -> output-frame rect under the camera at time t (OpenScreen computeZoomTransform). */
|
|
85
|
+
export function applyCamera(rect, regions, t) {
|
|
86
|
+
const cam = cameraAt(regions, t);
|
|
87
|
+
if (!cam)
|
|
88
|
+
return rect;
|
|
89
|
+
const depth = Math.min(6, Math.max(1, Math.round(cam.region.depth)));
|
|
90
|
+
const s = DEPTH_SCALES[depth];
|
|
91
|
+
const f = clampFocus(cam.region.focus, s);
|
|
92
|
+
const scale = 1 + (s - 1) * cam.p;
|
|
93
|
+
const ox = (0.5 - f.cx * s) * cam.p;
|
|
94
|
+
const oy = (0.5 - f.cy * s) * cam.p;
|
|
95
|
+
return { x: rect.x * scale + ox, y: rect.y * scale + oy, w: rect.w * scale, h: rect.h * scale };
|
|
96
|
+
}
|
package/dist/marks.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { type NormRect, type StageLayout } from "./layout.ts";
|
|
1
|
+
import { applyCamera, cameraAt, type NormRect, type StageLayout, zoomProgress } from "./layout.ts";
|
|
2
2
|
import { type LookOptions } from "./project.ts";
|
|
3
|
-
import type { ActionRecord, Caption, SpeedRegion, TrimRegion, Viewport, VoiceCue, ZoomRegion } from "./types.ts";
|
|
3
|
+
import type { ActionRecord, ArrowAnnotation, BlurAnnotation, Caption, ImageAnnotation, SpeedRegion, TrimRegion, Viewport, VoiceCue, ZoomRegion } from "./types.ts";
|
|
4
|
+
export { applyCamera, cameraAt, zoomProgress };
|
|
4
5
|
export interface MarkPoint {
|
|
5
6
|
t: number;
|
|
6
7
|
x: number;
|
|
@@ -36,12 +37,15 @@ export interface MarksInput {
|
|
|
36
37
|
durationMs: number;
|
|
37
38
|
actions: ActionRecord[];
|
|
38
39
|
captions: Caption[];
|
|
40
|
+
blurs?: BlurAnnotation[];
|
|
41
|
+
arrows?: ArrowAnnotation[];
|
|
42
|
+
images?: ImageAnnotation[];
|
|
39
43
|
voiceCues?: VoiceCue[];
|
|
40
44
|
zoomRegions: ZoomRegion[];
|
|
41
45
|
trimRegions?: TrimRegion[];
|
|
42
46
|
speedRegions?: SpeedRegion[];
|
|
43
47
|
layout: StageLayout;
|
|
44
|
-
look: Pick<LookOptions, "captionPosition">;
|
|
48
|
+
look: Pick<LookOptions, "captionPosition" | "watermark">;
|
|
45
49
|
}
|
|
46
50
|
export interface TargetRect {
|
|
47
51
|
action: ActionRecord;
|
|
@@ -58,13 +62,4 @@ export declare function targetRects(input: Pick<MarksInput, "actions" | "viewpor
|
|
|
58
62
|
* while it is shown (with 400 ms slack); then top, if that overlaps less.
|
|
59
63
|
*/
|
|
60
64
|
export declare function placeCaptions(captions: Caption[], targets: TargetRect[], position: LookOptions["captionPosition"]): Caption[];
|
|
61
|
-
/** Approximate zoom progress (0-1) of a region at recording time t. */
|
|
62
|
-
export declare function zoomProgress(r: ZoomRegion, t: number): number;
|
|
63
|
-
/** The camera at time t: the dominant zoom region and its progress. */
|
|
64
|
-
export declare function cameraAt(regions: ZoomRegion[], t: number): {
|
|
65
|
-
region: ZoomRegion;
|
|
66
|
-
p: number;
|
|
67
|
-
} | null;
|
|
68
|
-
/** Stage rect -> output-frame rect under the camera at time t (OpenScreen computeZoomTransform). */
|
|
69
|
-
export declare function applyCamera(rect: NormRect, regions: ZoomRegion[], t: number): NormRect;
|
|
70
65
|
export declare function buildMarks(input: MarksInput): Marks;
|
package/dist/marks.js
CHANGED
|
@@ -6,14 +6,15 @@
|
|
|
6
6
|
* so `framesheet inspect out.mp4 --marks marks.json` draws them where they appear.
|
|
7
7
|
*/
|
|
8
8
|
import { sourceToOutputMs } from "./idle.js";
|
|
9
|
-
import { clipUnit, DEPTH_SCALES,
|
|
10
|
-
import { captionRect } from "./project.js";
|
|
9
|
+
import { applyCamera, boxToStage, cameraAt, clipUnit, DEPTH_SCALES, toStage, zoomProgress, } from "./layout.js";
|
|
10
|
+
import { arrowRectForTarget, captionRect } from "./project.js";
|
|
11
11
|
import { normalizeDepth } from "./zoom.js";
|
|
12
|
+
export { applyCamera, cameraAt, zoomProgress };
|
|
12
13
|
/** Action target boxes in output-frame coordinates (padding + zoom camera applied). */
|
|
13
14
|
export function targetRects(input) {
|
|
14
15
|
const out = [];
|
|
15
16
|
for (const a of input.actions) {
|
|
16
|
-
if (!a.box || a.kind === "zoom")
|
|
17
|
+
if (!a.box || a.kind === "zoom" || a.kind === "blur" || a.kind === "arrow" || a.kind === "image")
|
|
17
18
|
continue;
|
|
18
19
|
// Sample the camera once the cursor has landed (zoom is then (nearly) complete).
|
|
19
20
|
const t = Math.min(a.endMs, a.arriveMs + 300);
|
|
@@ -42,46 +43,6 @@ export function placeCaptions(captions, targets, position) {
|
|
|
42
43
|
return { ...c, position: bottom > 0 && cost("top") < bottom ? "top" : "bottom" };
|
|
43
44
|
});
|
|
44
45
|
}
|
|
45
|
-
const ZOOM_IN_BEFORE_MS = 1022;
|
|
46
|
-
const ZOOM_IN_AFTER_MS = 500;
|
|
47
|
-
const ZOOM_OUT_MS = 1016;
|
|
48
|
-
const smooth = (x) => {
|
|
49
|
-
const t = Math.min(1, Math.max(0, x));
|
|
50
|
-
return t * t * (3 - 2 * t);
|
|
51
|
-
};
|
|
52
|
-
/** Approximate zoom progress (0-1) of a region at recording time t. */
|
|
53
|
-
export function zoomProgress(r, t) {
|
|
54
|
-
const inStart = r.startMs - ZOOM_IN_BEFORE_MS;
|
|
55
|
-
if (t <= inStart || t >= r.endMs + ZOOM_OUT_MS)
|
|
56
|
-
return 0;
|
|
57
|
-
if (t < r.startMs + ZOOM_IN_AFTER_MS)
|
|
58
|
-
return smooth((t - inStart) / (ZOOM_IN_BEFORE_MS + ZOOM_IN_AFTER_MS));
|
|
59
|
-
if (t <= r.endMs)
|
|
60
|
-
return 1;
|
|
61
|
-
return 1 - smooth((t - r.endMs) / ZOOM_OUT_MS);
|
|
62
|
-
}
|
|
63
|
-
/** The camera at time t: the dominant zoom region and its progress. */
|
|
64
|
-
export function cameraAt(regions, t) {
|
|
65
|
-
let best = null;
|
|
66
|
-
for (const r of regions) {
|
|
67
|
-
const p = zoomProgress(r, t);
|
|
68
|
-
if (p > 0 && (!best || p > best.p))
|
|
69
|
-
best = { region: r, p };
|
|
70
|
-
}
|
|
71
|
-
return best;
|
|
72
|
-
}
|
|
73
|
-
/** Stage rect -> output-frame rect under the camera at time t (OpenScreen computeZoomTransform). */
|
|
74
|
-
export function applyCamera(rect, regions, t) {
|
|
75
|
-
const cam = cameraAt(regions, t);
|
|
76
|
-
if (!cam)
|
|
77
|
-
return rect;
|
|
78
|
-
const s = DEPTH_SCALES[normalizeDepth(cam.region.depth)];
|
|
79
|
-
const f = clampFocus(cam.region.focus, s);
|
|
80
|
-
const scale = 1 + (s - 1) * cam.p;
|
|
81
|
-
const ox = (0.5 - f.cx * s) * cam.p;
|
|
82
|
-
const oy = (0.5 - f.cy * s) * cam.p;
|
|
83
|
-
return { x: rect.x * scale + ox, y: rect.y * scale + oy, w: rect.w * scale, h: rect.h * scale };
|
|
84
|
-
}
|
|
85
46
|
const r4 = (v) => Math.round(v * 10000) / 10000;
|
|
86
47
|
const r3 = (v) => Math.round(v * 1000) / 1000;
|
|
87
48
|
function describe(a) {
|
|
@@ -141,6 +102,75 @@ export function buildMarks(input) {
|
|
|
141
102
|
kind: "voice",
|
|
142
103
|
});
|
|
143
104
|
}
|
|
105
|
+
for (const b of input.blurs ?? []) {
|
|
106
|
+
const bEndMs = b.endMs === "end" ? input.durationMs : b.endMs;
|
|
107
|
+
const start = out(b.startMs);
|
|
108
|
+
const sampleT = Math.min(bEndMs, b.startMs + Math.min(350, (bEndMs - b.startMs) / 2));
|
|
109
|
+
let rect = null;
|
|
110
|
+
if (b.rect) {
|
|
111
|
+
rect = clipUnit({ x: b.rect.x / 100, y: b.rect.y / 100, w: b.rect.width / 100, h: b.rect.height / 100 });
|
|
112
|
+
}
|
|
113
|
+
else if (b.box) {
|
|
114
|
+
const pad = b.padding ?? 4;
|
|
115
|
+
const padded = {
|
|
116
|
+
x: Math.max(0, b.box.x - pad),
|
|
117
|
+
y: Math.max(0, b.box.y - pad),
|
|
118
|
+
width: b.box.width + pad * 2,
|
|
119
|
+
height: b.box.height + pad * 2,
|
|
120
|
+
};
|
|
121
|
+
rect = clipUnit(applyCamera(boxToStage(layout, vp, padded), zr, sampleT));
|
|
122
|
+
}
|
|
123
|
+
marks.regions.push({
|
|
124
|
+
start,
|
|
125
|
+
end: Math.max(start, Math.min(endS, out(bEndMs))),
|
|
126
|
+
...(box(rect) ?? {}),
|
|
127
|
+
label: b.label ?? "blur",
|
|
128
|
+
kind: "blur",
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
for (const a of input.arrows ?? []) {
|
|
132
|
+
const start = out(a.startMs);
|
|
133
|
+
const sizePct = Math.min(40, Math.max(3, a.size ?? 9));
|
|
134
|
+
let rect = null;
|
|
135
|
+
if (a.rect) {
|
|
136
|
+
rect = clipUnit({ x: a.rect.x / 100, y: a.rect.y / 100, w: a.rect.width / 100, h: a.rect.height / 100 });
|
|
137
|
+
}
|
|
138
|
+
else if (a.box) {
|
|
139
|
+
const sampleT = Math.min(a.endMs, a.startMs + Math.min(350, (a.endMs - a.startMs) / 2));
|
|
140
|
+
const stage = applyCamera(boxToStage(layout, vp, a.box), zr, sampleT);
|
|
141
|
+
const r = arrowRectForTarget(stage, a.direction, sizePct);
|
|
142
|
+
rect = clipUnit({ x: r.x / 100, y: r.y / 100, w: r.width / 100, h: r.height / 100 });
|
|
143
|
+
}
|
|
144
|
+
marks.regions.push({
|
|
145
|
+
start,
|
|
146
|
+
end: Math.max(start, Math.min(endS, out(a.endMs))),
|
|
147
|
+
...(box(rect) ?? {}),
|
|
148
|
+
label: a.label ?? `arrow ${a.direction}`,
|
|
149
|
+
kind: "arrow",
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
const imageList = [...(input.images ?? [])];
|
|
153
|
+
if (input.look.watermark) {
|
|
154
|
+
const wm = input.look.watermark;
|
|
155
|
+
const w = wm.width ?? 10;
|
|
156
|
+
const h = wm.height ?? 8;
|
|
157
|
+
const pos = wm.position ?? "bottom-right";
|
|
158
|
+
const x = typeof pos === "object" ? pos.x : pos.endsWith("left") ? 2.5 : 97.5 - w;
|
|
159
|
+
const y = typeof pos === "object" ? pos.y : pos.startsWith("top") ? 2.5 : 97.5 - h;
|
|
160
|
+
imageList.push({ startMs: 0, endMs: "end", src: wm.src, x, y, width: w, height: h, label: "watermark" });
|
|
161
|
+
}
|
|
162
|
+
for (const img of imageList) {
|
|
163
|
+
const imgEndMs = img.endMs === "end" ? input.durationMs : img.endMs;
|
|
164
|
+
const start = out(img.startMs);
|
|
165
|
+
const rect = clipUnit({ x: img.x / 100, y: img.y / 100, w: img.width / 100, h: img.height / 100 });
|
|
166
|
+
marks.regions.push({
|
|
167
|
+
start,
|
|
168
|
+
end: Math.max(start, Math.min(endS, out(imgEndMs))),
|
|
169
|
+
...(box(rect) ?? {}),
|
|
170
|
+
label: img.label ?? "image",
|
|
171
|
+
kind: "image",
|
|
172
|
+
});
|
|
173
|
+
}
|
|
144
174
|
for (const cap of input.captions) {
|
|
145
175
|
const c = captionRect(cap.position ?? input.look.captionPosition);
|
|
146
176
|
const start = out(cap.startMs);
|
package/dist/mcp.js
CHANGED
|
@@ -15,6 +15,7 @@ import { readTimeline, rezoom } from "./compose.js";
|
|
|
15
15
|
import { checkFfmpeg, detectGpu, launchChromium } from "./env.js";
|
|
16
16
|
import { exportGif } from "./gif.js";
|
|
17
17
|
import { loadScenario } from "./load.js";
|
|
18
|
+
import { normalizeMusicConfig } from "./music.js";
|
|
18
19
|
import { dryRunScenario, recordScenario, resolveStorageState } from "./record.js";
|
|
19
20
|
import { renderProject, validateProject } from "./render.js";
|
|
20
21
|
import { extractFrame, findFramesheet, reviewSheet } from "./sheet.js";
|
|
@@ -248,6 +249,10 @@ export function createMcpServer() {
|
|
|
248
249
|
voiceProvider: z.enum(["edge", "openai", "elevenlabs", "gemini", "cartesia", "deepgram"]).optional().describe("Override voiceover TTS provider."),
|
|
249
250
|
voice: z.string().optional().describe("Override voiceover voice ID."),
|
|
250
251
|
noVoice: z.boolean().optional().describe("Disable voiceover synthesis for this run."),
|
|
252
|
+
music: z.string().optional().describe("Background music file path or HTTP(S) URL."),
|
|
253
|
+
musicProvider: z.enum(["elevenlabs", "gemini"]).optional().describe("AI background music provider (ElevenLabs Music or Google Lyria)."),
|
|
254
|
+
musicPrompt: z.string().optional().describe("Natural-language prompt for AI background music."),
|
|
255
|
+
noMusic: z.boolean().optional().describe("Disable background music for this run."),
|
|
251
256
|
}),
|
|
252
257
|
annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: true },
|
|
253
258
|
}, async (args, ctx) => {
|
|
@@ -271,6 +276,33 @@ export function createMcpServer() {
|
|
|
271
276
|
vc.enabled = false;
|
|
272
277
|
overrides.voice = vc;
|
|
273
278
|
}
|
|
279
|
+
const baseMusic = normalizeMusicConfig(scenario.music);
|
|
280
|
+
let effectiveMusic = baseMusic?.src && !/^https?:\/\//i.test(baseMusic.src) && !path.isAbsolute(baseMusic.src)
|
|
281
|
+
? { ...baseMusic, src: path.resolve(path.dirname(file), baseMusic.src) }
|
|
282
|
+
: baseMusic;
|
|
283
|
+
if (args.music || args.musicProvider || args.musicPrompt || args.noMusic) {
|
|
284
|
+
const mc = { ...effectiveMusic };
|
|
285
|
+
if (args.noMusic)
|
|
286
|
+
mc.enabled = false;
|
|
287
|
+
if (args.music) {
|
|
288
|
+
mc.src = /^https?:\/\//i.test(args.music) ? args.music : path.resolve(args.music);
|
|
289
|
+
delete mc.provider;
|
|
290
|
+
delete mc.prompt;
|
|
291
|
+
mc.enabled = true;
|
|
292
|
+
}
|
|
293
|
+
if (args.musicProvider) {
|
|
294
|
+
mc.provider = args.musicProvider;
|
|
295
|
+
delete mc.src;
|
|
296
|
+
mc.enabled = true;
|
|
297
|
+
}
|
|
298
|
+
if (args.musicPrompt) {
|
|
299
|
+
mc.prompt = args.musicPrompt;
|
|
300
|
+
delete mc.src;
|
|
301
|
+
mc.enabled = true;
|
|
302
|
+
}
|
|
303
|
+
effectiveMusic = mc;
|
|
304
|
+
overrides.music = mc;
|
|
305
|
+
}
|
|
274
306
|
const outDir = path.resolve(args.outDir ?? path.join("out", scenario.name));
|
|
275
307
|
progress(5, `Recording "${scenario.name}"...`);
|
|
276
308
|
const rec = await recordScenario(scenario, {
|
|
@@ -303,6 +335,7 @@ export function createMcpServer() {
|
|
|
303
335
|
frameRate: args.fps,
|
|
304
336
|
quality: args.quality,
|
|
305
337
|
cursor: scenario.cursor,
|
|
338
|
+
...(effectiveMusic ? { music: effectiveMusic } : {}),
|
|
306
339
|
log: logStderr,
|
|
307
340
|
onProgress: (p) => progress(15 + p * 0.75, `Rendering ${Math.round(p)}%`),
|
|
308
341
|
});
|
|
@@ -314,6 +347,8 @@ export function createMcpServer() {
|
|
|
314
347
|
summary.renderMs = rendered.renderMs;
|
|
315
348
|
if (rendered.audioMuxed)
|
|
316
349
|
summary.audioMuxed = true;
|
|
350
|
+
if (rendered.musicMuxed)
|
|
351
|
+
summary.musicMuxed = true;
|
|
317
352
|
if (rendered.vttPath)
|
|
318
353
|
summary.vttPath = rendered.vttPath;
|
|
319
354
|
if (rec.timeline.voiceCues?.length) {
|