@slidevideo/cli 0.2.2 → 0.3.1
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/CHANGELOG.md +18 -0
- package/README.md +2 -2
- package/addons/slidevideo/geometry.ts +334 -1
- package/addons/slidevideo/global-top.vue +311 -24
- package/addons/slidevideo/preview.ts +242 -25
- package/assets/fonts/OFL-LICENSES.txt +95 -0
- package/assets/fonts/instrument-serif-latin-2.woff2 +0 -0
- package/assets/fonts/instrument-serif-latin-ext-1.woff2 +0 -0
- package/assets/fonts/jetbrains-mono-latin-4.woff2 +0 -0
- package/assets/fonts/jetbrains-mono-latin-ext-3.woff2 +0 -0
- package/assets/fonts/plus-jakarta-sans-latin-6.woff2 +0 -0
- package/assets/fonts/plus-jakarta-sans-latin-ext-5.woff2 +0 -0
- package/dist/adapters/browser-runtime.d.ts +13 -1
- package/dist/adapters/capture-compression.d.ts +15 -0
- package/dist/adapters/capture-compression.js +69 -0
- package/dist/adapters/powerpoint-preview.d.ts +1 -1
- package/dist/adapters/powerpoint-preview.js +13 -2
- package/dist/adapters/powerpoint.js +108 -16
- package/dist/adapters/slidev-inspection.js +7 -2
- package/dist/adapters/slidev.js +362 -3
- package/dist/annotation-paint.d.ts +195 -5
- package/dist/annotation-paint.js +1188 -2
- package/dist/annotations.d.ts +26 -2
- package/dist/annotations.js +1117 -29
- package/dist/captions.d.ts +6 -0
- package/dist/captions.js +320 -0
- package/dist/cli.js +40 -17
- package/dist/compositor.js +51 -3
- package/dist/contracts.d.ts +253 -14
- package/dist/pipeline.d.ts +6 -1
- package/dist/pipeline.js +66 -19
- package/dist/preview/contracts.d.ts +14 -0
- package/dist/preview/player.js +523 -33
- package/dist/preview/server.d.ts +1 -1
- package/dist/preview/server.js +124 -3
- package/dist/preview/view.d.ts +1 -1
- package/dist/preview/view.js +26 -7
- package/dist/run.d.ts +1 -0
- package/dist/run.js +20 -0
- package/dist/speech.d.ts +10 -1
- package/dist/speech.js +18 -2
- package/dist/stamp-fonts.d.ts +17 -0
- package/dist/stamp-fonts.js +202 -0
- package/dist/storyboard.js +60 -3
- package/dist/timing.d.ts +2 -0
- package/dist/timing.js +277 -11
- package/package.json +14 -1
- package/schemas/annotation-geometry.v1.json +111 -0
- package/schemas/schedule.v1.json +1672 -84
- package/schemas/storyboard.v1.json +3725 -85
- package/skills/slidevideo/SKILL.md +5 -5
- package/skills/slidevideo/references/decks.md +6 -4
- package/skills/slidevideo/references/production.md +12 -11
- package/skills/slidevideo/references/storyboard.md +268 -5
- package/tools/powerpoint/powerpoint.ps1 +278 -40
- package/tools/powerpoint/preview.ps1 +69 -1
package/dist/storyboard.js
CHANGED
|
@@ -3,6 +3,7 @@ import { dirname, extname, isAbsolute, resolve } from 'node:path';
|
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
4
|
import { parse } from 'yaml';
|
|
5
5
|
import { Ajv } from 'ajv';
|
|
6
|
+
import { unsupportedStampGlyph } from './stamp-fonts.js';
|
|
6
7
|
import { requireCondition, ProductionError } from './errors.js';
|
|
7
8
|
import { hashFile, digest } from './media.js';
|
|
8
9
|
const validate = new Ajv({ allErrors: true }).compile(JSON.parse(await readFile(fileURLToPath(new URL('../schemas/storyboard.v1.json', import.meta.url)), 'utf8')));
|
|
@@ -43,7 +44,30 @@ export async function loadStoryboard(file) {
|
|
|
43
44
|
for (const annotation of data.annotations) {
|
|
44
45
|
const context = { annotation: annotation.id, target: annotation.target };
|
|
45
46
|
requireCondition(data.scenes.some(scene => scene.id === annotation.scene), 'ANNOTATION_SCENE', `Annotation ${annotation.id}: unknown scene ${annotation.scene}`, 2, context);
|
|
46
|
-
|
|
47
|
+
if ('at' in annotation && annotation.at !== undefined) {
|
|
48
|
+
if (typeof annotation.at !== 'number') {
|
|
49
|
+
requireCondition(segments.has(annotation.at.segment), 'CUE_REFERENCE', `Annotation ${annotation.id}: unknown narration ${annotation.at.segment}`, 2, context);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
const follow = annotation.follow;
|
|
54
|
+
requireCondition(segments.has(follow.segment), 'CUE_REFERENCE', `Annotation ${annotation.id}: unknown narration ${follow.segment}`, 2, context);
|
|
55
|
+
requireCondition(follow.phrase === undefined || follow.phrase.trim().length > 0, 'CUE_PHRASE_MISSING', `Annotation ${annotation.id}: follow phrase cannot be empty or whitespace`, 2, context);
|
|
56
|
+
requireCondition(follow.occurrence === undefined || follow.phrase !== undefined, 'ANNOTATION_FOLLOW', `Annotation ${annotation.id}: follow occurrence requires an explicit phrase`, 2, context);
|
|
57
|
+
const mode = follow.mode ?? 'words';
|
|
58
|
+
if (mode === 'words') {
|
|
59
|
+
requireCondition(annotation.target.type === 'text', 'ANNOTATION_FOLLOW', `Annotation ${annotation.id}: word-following mode requires a text target`, 2, context);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
requireCondition(follow.tokens === undefined, 'ANNOTATION_FOLLOW', `Annotation ${annotation.id}: follow tokens require mode: words`, 2, context);
|
|
63
|
+
}
|
|
64
|
+
for (const token of follow.tokens ?? []) {
|
|
65
|
+
requireCondition(token.text.trim().length > 0 && token.phrase.trim().length > 0, 'ANNOTATION_FOLLOW', `Annotation ${annotation.id}: follow token text and phrase cannot be whitespace`, 2, context);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (annotation.target.type === 'text') {
|
|
69
|
+
requireCondition(annotation.target.text.trim().length > 0, 'ANNOTATION_TARGET', `Annotation ${annotation.id}: text target cannot be empty or whitespace`, 2, context);
|
|
70
|
+
}
|
|
47
71
|
if (annotation.target.type === 'region') {
|
|
48
72
|
const { x, y, width, height } = annotation.target;
|
|
49
73
|
requireCondition(x + width <= 1 && y + height <= 1, 'ANNOTATION_BOUNDS', `Annotation ${annotation.id}: region exceeds normalized slide bounds`, 2, context);
|
|
@@ -52,10 +76,43 @@ export async function loadStoryboard(file) {
|
|
|
52
76
|
requireCondition(top < 1 && top + annotation.appearance.width > 0, 'ANNOTATION_BOUNDS', `Annotation ${annotation.id}: underline offset places stroke outside normalized slide bounds`, 2, context);
|
|
53
77
|
}
|
|
54
78
|
}
|
|
55
|
-
if (annotation.effect === '
|
|
79
|
+
if (annotation.effect === 'laser') {
|
|
80
|
+
let totalDwell = 0;
|
|
81
|
+
for (const point of annotation.target.points) {
|
|
82
|
+
totalDwell += point.dwell_ms ?? 0;
|
|
83
|
+
if ('target' in point) {
|
|
84
|
+
if (point.target.type === 'text') {
|
|
85
|
+
requireCondition(point.target.text.trim().length > 0, 'ANNOTATION_TARGET', `Annotation ${annotation.id}: laser waypoint text target cannot be empty or whitespace`, 2, context);
|
|
86
|
+
}
|
|
87
|
+
if (point.target.type === 'region') {
|
|
88
|
+
const { x, y, width, height } = point.target;
|
|
89
|
+
requireCondition(x + width <= 1 && y + height <= 1, 'ANNOTATION_BOUNDS', `Annotation ${annotation.id}: laser waypoint region exceeds normalized slide bounds`, 2, context);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if ('duration_ms' in annotation && annotation.duration_ms !== undefined) {
|
|
94
|
+
const validDwell = annotation.target.points.length >= 2
|
|
95
|
+
? totalDwell < annotation.duration_ms
|
|
96
|
+
: totalDwell <= annotation.duration_ms;
|
|
97
|
+
requireCondition(validDwell, 'ANNOTATION_MOTION', `Annotation ${annotation.id}: laser waypoint dwell (${totalDwell} ms) leaves no traversal time within duration (${annotation.duration_ms} ms)`, 2, context);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (annotation.effect === 'zoom' && annotation.appearance?.scale !== undefined && annotation.appearance?.max_scale !== undefined) {
|
|
101
|
+
requireCondition(annotation.appearance.scale <= annotation.appearance.max_scale, 'ANNOTATION_ZOOM', `Annotation ${annotation.id}: zoom scale (${annotation.appearance.scale}) exceeds max_scale (${annotation.appearance.max_scale})`, 2, context);
|
|
102
|
+
}
|
|
103
|
+
if (annotation.effect === 'stamp') {
|
|
104
|
+
const text = annotation.appearance.text;
|
|
105
|
+
if (text !== undefined) {
|
|
106
|
+
requireCondition(text.trim().length > 0, 'STAMP_CONTENT', `Annotation ${annotation.id}: stamp text cannot be empty or whitespace`, 2, context);
|
|
107
|
+
const font = annotation.appearance.font ?? 'sans';
|
|
108
|
+
const badChar = unsupportedStampGlyph(text, font);
|
|
109
|
+
requireCondition(badChar === undefined, 'STAMP_GLYPH', `Annotation ${annotation.id}: character ${JSON.stringify(badChar)} is not supported by the bundled ${font} stamp font; use characters covered by the bundled font or appearance.symbol (check, cross, warning, star, info, arrow-right)`, 2, context);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if ((annotation.effect === 'underline' || annotation.effect === 'spotlight' || annotation.effect === 'zoom' || annotation.effect === 'laser' || annotation.effect === 'stamp') && annotation.motion && 'duration_ms' in annotation && annotation.duration_ms !== undefined) {
|
|
56
113
|
const inMs = annotation.motion.in_ms ?? 0;
|
|
57
114
|
const outMs = annotation.motion.out_ms ?? 0;
|
|
58
|
-
requireCondition(inMs + outMs <= annotation.duration_ms, 'ANNOTATION_MOTION', `Annotation ${annotation.id}:
|
|
115
|
+
requireCondition(inMs + outMs <= annotation.duration_ms, 'ANNOTATION_MOTION', `Annotation ${annotation.id}: ${annotation.motion.type} motion exceeds annotation duration`, 2, context);
|
|
59
116
|
}
|
|
60
117
|
}
|
|
61
118
|
const scenes = new Set(data.scenes.map(scene => scene.id));
|
package/dist/timing.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Schedule, SpeechManifest, Storyboard, TtsAdapter } from './contracts.js';
|
|
2
|
+
import { type VerifiedSpeechAudio } from './speech.js';
|
|
2
3
|
export declare function resolveTiming(story: Storyboard, speech: SpeechManifest): Promise<Schedule>;
|
|
3
4
|
export declare function resolvePreviewTiming(story: Storyboard, adapters: ReadonlyMap<string, TtsAdapter>, cache?: string): Promise<{
|
|
4
5
|
schedule: Schedule;
|
|
5
6
|
approximate: string[];
|
|
7
|
+
audio: Map<string, VerifiedSpeechAudio>;
|
|
6
8
|
}>;
|
package/dist/timing.js
CHANGED
|
@@ -9,6 +9,7 @@ export async function resolveTiming(story, speech) {
|
|
|
9
9
|
export async function resolvePreviewTiming(story, adapters, cache) {
|
|
10
10
|
const assets = [];
|
|
11
11
|
const approximate = [];
|
|
12
|
+
const audio = new Map();
|
|
12
13
|
for (const segment of story.narration) {
|
|
13
14
|
const voice = segment.voice ?? story.voice;
|
|
14
15
|
requireCondition(voice, 'VOICE_REQUIRED', `Narration ${segment.id} needs a voice`);
|
|
@@ -16,15 +17,18 @@ export async function resolvePreviewTiming(story, adapters, cache) {
|
|
|
16
17
|
requireCondition(adapter, 'TTS_ADAPTER', `Unsupported TTS provider ${voice.provider}`, 3);
|
|
17
18
|
adapter.validate(voice);
|
|
18
19
|
const retained = await retainedSpeechTiming(segment, voice, adapter, cache);
|
|
19
|
-
if (retained)
|
|
20
|
-
assets.push(retained);
|
|
20
|
+
if (retained) {
|
|
21
|
+
assets.push(retained.timing);
|
|
22
|
+
if (retained.audio)
|
|
23
|
+
audio.set(segment.id, retained.audio);
|
|
24
|
+
}
|
|
21
25
|
else {
|
|
22
26
|
approximate.push(segment.id);
|
|
23
27
|
const words = segment.text.trim().split(/\s+/).filter(Boolean).length;
|
|
24
28
|
assets.push({ id: segment.id, duration_ms: Math.max(1000, words * 60000 / 150), transcript: { original: segment.text, normalized: segment.text }, alignment: null });
|
|
25
29
|
}
|
|
26
30
|
}
|
|
27
|
-
return { schedule: await resolveSchedule(story, assets), approximate };
|
|
31
|
+
return { schedule: await resolveSchedule(story, assets), approximate, audio };
|
|
28
32
|
}
|
|
29
33
|
async function resolveSchedule(story, speech) {
|
|
30
34
|
const media = await Promise.all(story.media.map(async (item) => ({ ...item, ...await probe(item.src) })));
|
|
@@ -117,20 +121,282 @@ async function resolveSchedule(story, speech) {
|
|
|
117
121
|
requireCondition(other.start_ms >= item.end_ms, 'MEDIA_NAVIGATION', `Slide ${other.id} interrupts media ${item.id}`);
|
|
118
122
|
}
|
|
119
123
|
}
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
124
|
+
const visuals = actions.filter(item => item.action.type === 'slide' || item.action.type === 'reveal');
|
|
125
|
+
const usedIds = new Set([
|
|
126
|
+
...story.scenes.map(s => s.id),
|
|
127
|
+
...story.narration.map(n => n.id),
|
|
128
|
+
...story.media.map(m => m.id),
|
|
129
|
+
...story.cues.map(c => c.id),
|
|
130
|
+
...(story.overlays ?? []).map(o => o.id),
|
|
131
|
+
...story.scenes.flatMap(s => s.actions.map(a => a.id)),
|
|
132
|
+
]);
|
|
133
|
+
const normalizeSpaces = (value) => value.trim().replace(/\s+/g, ' ');
|
|
134
|
+
const wordPattern = /[\p{L}\p{N}]+(?:['’\-/.,][\p{L}\p{N}]+)*/gu;
|
|
135
|
+
const tokenizeWords = (value) => [...value.matchAll(wordPattern)].map(match => ({
|
|
136
|
+
text: match[0],
|
|
137
|
+
start: match.index,
|
|
138
|
+
end: match.index + match[0].length,
|
|
139
|
+
}));
|
|
140
|
+
const canonicalWord = (value) => value.normalize('NFC').replace(/’/g, "'").toLowerCase();
|
|
141
|
+
function findExactMatch(haystack, needle, occurrence, codes, label, context) {
|
|
142
|
+
const matches = [];
|
|
143
|
+
let pos = haystack.indexOf(needle);
|
|
144
|
+
while (pos >= 0) {
|
|
145
|
+
matches.push(pos);
|
|
146
|
+
pos = haystack.indexOf(needle, pos + 1);
|
|
147
|
+
}
|
|
148
|
+
requireCondition(matches.length > 0, codes.missing, `${label}: ${JSON.stringify(needle)} not found`, 2, context);
|
|
149
|
+
requireCondition(occurrence !== undefined || matches.length === 1, codes.ambiguous, `${label}: specify occurrence for repeated ${JSON.stringify(needle)}`, 2, context);
|
|
150
|
+
const start = matches[(occurrence ?? 1) - 1];
|
|
151
|
+
requireCondition(start !== undefined, codes.occurrence, `${label}: occurrence ${occurrence} does not exist`, 2, context);
|
|
152
|
+
return start;
|
|
153
|
+
}
|
|
154
|
+
function buildResolvedAnnotation(annotation, resolvedId, sourceId, target, segmentScene, time, end, cue_span, context) {
|
|
155
|
+
requireCondition(!usedIds.has(resolvedId), 'DUPLICATE_ID', `Duplicate resolved annotation ID ${resolvedId}`, 2, context);
|
|
156
|
+
usedIds.add(resolvedId);
|
|
157
|
+
requireCondition(end > time, 'ANNOTATION_DURATION', `Annotation ${resolvedId}: interval must have positive duration`, 2, context);
|
|
123
158
|
const range = sceneRanges.get(annotation.scene);
|
|
124
|
-
requireCondition(
|
|
125
|
-
const visuals = actions.filter(item => item.action.type === 'slide' || item.action.type === 'reveal');
|
|
159
|
+
requireCondition(segmentScene === annotation.scene && time >= range.start && end <= range.end, 'ANNOTATION_RANGE', `Annotation ${resolvedId}: interval must fit its narration scene ${annotation.scene}`, 2, context);
|
|
126
160
|
const preceding = visuals.filter(item => item.start_ms <= time);
|
|
127
161
|
const slide = preceding.findLast(item => item.action.type === 'slide');
|
|
128
162
|
const state = preceding.at(-1);
|
|
129
|
-
requireCondition(time >= state.end_ms && !visuals.some(item => item.start_ms > time && item.start_ms < end), 'ANNOTATION_STATE', `Annotation ${
|
|
163
|
+
requireCondition(time >= state.end_ms && !visuals.some(item => item.start_ms > time && item.start_ms < end), 'ANNOTATION_STATE', `Annotation ${resolvedId}: interval must fit one settled slide visit and reveal state`, 2, context);
|
|
130
164
|
const click = state.action.type === 'reveal' ? state.action.click : 0;
|
|
131
|
-
requireCondition(slide.action.type === 'slide', 'ANNOTATION_STATE', `Annotation ${
|
|
132
|
-
|
|
165
|
+
requireCondition(slide.action.type === 'slide', 'ANNOTATION_STATE', `Annotation ${resolvedId}: no active slide`, 2, context);
|
|
166
|
+
const windowFields = {
|
|
167
|
+
start_ms: time,
|
|
168
|
+
end_ms: end,
|
|
169
|
+
slide: slide.action.target,
|
|
170
|
+
visit: slide.id,
|
|
171
|
+
click,
|
|
172
|
+
...(cue_span ? { cue_span } : {}),
|
|
173
|
+
...(sourceId ? { source_id: sourceId } : {}),
|
|
174
|
+
};
|
|
175
|
+
if (annotation.effect === 'laser') {
|
|
176
|
+
const pathTarget = target;
|
|
177
|
+
const totalDwell = pathTarget.points.reduce((sum, pt) => sum + (pt.dwell_ms ?? 0), 0);
|
|
178
|
+
const validDwell = pathTarget.points.length >= 2 ? totalDwell < end - time : totalDwell <= end - time;
|
|
179
|
+
requireCondition(validDwell, 'ANNOTATION_MOTION', `Annotation ${resolvedId}: laser waypoint dwell (${Math.round(totalDwell)} ms) leaves no traversal time within resolved duration (${Math.round(end - time)} ms)`, 2, context);
|
|
180
|
+
if (annotation.motion) {
|
|
181
|
+
const inMs = annotation.motion.in_ms ?? 0;
|
|
182
|
+
const outMs = annotation.motion.out_ms ?? 0;
|
|
183
|
+
requireCondition(inMs + outMs <= end - time, 'ANNOTATION_MOTION', `Annotation ${resolvedId}: fade motion exceeds resolved duration (${Math.round(end - time)} ms)`, 2, context);
|
|
184
|
+
}
|
|
185
|
+
return {
|
|
186
|
+
id: resolvedId,
|
|
187
|
+
scene: annotation.scene,
|
|
188
|
+
effect: 'laser',
|
|
189
|
+
target: pathTarget,
|
|
190
|
+
...(annotation.appearance ? { appearance: annotation.appearance } : {}),
|
|
191
|
+
...(annotation.motion ? { motion: annotation.motion } : {}),
|
|
192
|
+
...windowFields,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
if (annotation.effect === 'stamp') {
|
|
196
|
+
if (annotation.motion) {
|
|
197
|
+
const inMs = annotation.motion.in_ms ?? 0;
|
|
198
|
+
const outMs = annotation.motion.out_ms ?? 0;
|
|
199
|
+
requireCondition(inMs + outMs <= end - time, 'ANNOTATION_MOTION', `Annotation ${resolvedId}: ${annotation.motion.type} motion exceeds resolved duration (${Math.round(end - time)} ms)`, 2, context);
|
|
200
|
+
}
|
|
201
|
+
return {
|
|
202
|
+
id: resolvedId,
|
|
203
|
+
scene: annotation.scene,
|
|
204
|
+
effect: 'stamp',
|
|
205
|
+
target: target,
|
|
206
|
+
appearance: annotation.appearance,
|
|
207
|
+
...(annotation.motion ? { motion: annotation.motion } : {}),
|
|
208
|
+
...windowFields,
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
const singleTarget = target;
|
|
212
|
+
if (annotation.effect === 'underline') {
|
|
213
|
+
if (annotation.motion) {
|
|
214
|
+
const inMs = annotation.motion.in_ms ?? 0;
|
|
215
|
+
const outMs = annotation.motion.out_ms ?? 0;
|
|
216
|
+
requireCondition(inMs + outMs <= end - time, 'ANNOTATION_MOTION', `Annotation ${resolvedId}: wipe motion exceeds resolved duration (${Math.round(end - time)} ms)`, 2, context);
|
|
217
|
+
}
|
|
218
|
+
return {
|
|
219
|
+
id: resolvedId,
|
|
220
|
+
scene: annotation.scene,
|
|
221
|
+
effect: 'underline',
|
|
222
|
+
target: singleTarget,
|
|
223
|
+
appearance: annotation.appearance,
|
|
224
|
+
...(annotation.motion ? { motion: annotation.motion } : {}),
|
|
225
|
+
...windowFields,
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
if (annotation.effect === 'spotlight') {
|
|
229
|
+
if (annotation.motion) {
|
|
230
|
+
const inMs = annotation.motion.in_ms ?? 0;
|
|
231
|
+
const outMs = annotation.motion.out_ms ?? 0;
|
|
232
|
+
requireCondition(inMs + outMs <= end - time, 'ANNOTATION_MOTION', `Annotation ${resolvedId}: fade motion exceeds resolved duration (${Math.round(end - time)} ms)`, 2, context);
|
|
233
|
+
}
|
|
234
|
+
return {
|
|
235
|
+
id: resolvedId,
|
|
236
|
+
scene: annotation.scene,
|
|
237
|
+
effect: 'spotlight',
|
|
238
|
+
target: singleTarget,
|
|
239
|
+
appearance: annotation.appearance,
|
|
240
|
+
...(annotation.motion ? { motion: annotation.motion } : {}),
|
|
241
|
+
...windowFields,
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
if (annotation.effect === 'zoom') {
|
|
245
|
+
if (annotation.motion) {
|
|
246
|
+
const inMs = annotation.motion.in_ms ?? 0;
|
|
247
|
+
const outMs = annotation.motion.out_ms ?? 0;
|
|
248
|
+
requireCondition(inMs + outMs <= end - time, 'ANNOTATION_MOTION', `Annotation ${resolvedId}: ease motion exceeds resolved duration (${Math.round(end - time)} ms)`, 2, context);
|
|
249
|
+
}
|
|
250
|
+
return {
|
|
251
|
+
id: resolvedId,
|
|
252
|
+
scene: annotation.scene,
|
|
253
|
+
effect: 'zoom',
|
|
254
|
+
target: singleTarget,
|
|
255
|
+
...(annotation.appearance ? { appearance: annotation.appearance } : {}),
|
|
256
|
+
...(annotation.motion ? { motion: annotation.motion } : {}),
|
|
257
|
+
...windowFields,
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
return {
|
|
261
|
+
id: resolvedId,
|
|
262
|
+
scene: annotation.scene,
|
|
263
|
+
effect: 'highlight',
|
|
264
|
+
target: singleTarget,
|
|
265
|
+
appearance: annotation.appearance,
|
|
266
|
+
...windowFields,
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
const annotations = story.annotations.flatMap((annotation) => {
|
|
270
|
+
const normalizeTarget = (t) => {
|
|
271
|
+
if (t.type === 'path') {
|
|
272
|
+
return {
|
|
273
|
+
...t,
|
|
274
|
+
points: t.points.map(pt => 'target' in pt && pt.target.type === 'text'
|
|
275
|
+
? { ...pt, target: { ...pt.target, text: normalizeSpaces(pt.target.text) } }
|
|
276
|
+
: pt),
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
return t.type === 'text' ? { ...t, text: normalizeSpaces(t.text) } : t;
|
|
280
|
+
};
|
|
281
|
+
const normalizedTarget = normalizeTarget(annotation.target);
|
|
282
|
+
if ('at' in annotation && annotation.at !== undefined) {
|
|
283
|
+
if (typeof annotation.at === 'number') {
|
|
284
|
+
const range = sceneRanges.get(annotation.scene);
|
|
285
|
+
const time = range.start + annotation.at;
|
|
286
|
+
const context = { annotation: annotation.id, scene: annotation.scene, target: normalizedTarget };
|
|
287
|
+
return [buildResolvedAnnotation(annotation, annotation.id, undefined, normalizedTarget, annotation.scene, time, time + annotation.duration_ms, undefined, context)];
|
|
288
|
+
}
|
|
289
|
+
const { time, segment, context, cue_span } = phrase({ id: annotation.id, at: annotation.at }, normalizedTarget);
|
|
290
|
+
return [buildResolvedAnnotation(annotation, annotation.id, undefined, normalizedTarget, segment.scene, time, time + annotation.duration_ms, cue_span, context)];
|
|
291
|
+
}
|
|
292
|
+
const follow = annotation.follow;
|
|
293
|
+
const segment = segments.get(follow.segment);
|
|
294
|
+
const asset = assets.get(follow.segment);
|
|
295
|
+
const alignment = asset.alignment;
|
|
296
|
+
const context = { annotation: annotation.id, segment: follow.segment, target: normalizedTarget };
|
|
297
|
+
requireCondition(alignment && alignment.units.length > 0, 'CUE_ALIGNMENT_REQUIRED', `Annotation ${annotation.id} requires alignment for ${follow.segment}`, 2, context);
|
|
298
|
+
const offsetMs = follow.offset_ms ?? 0;
|
|
299
|
+
const lingerMs = follow.linger_ms ?? 180;
|
|
300
|
+
const extendWithLinger = (startMs, rawEndMs) => {
|
|
301
|
+
if (lingerMs <= 0)
|
|
302
|
+
return rawEndMs;
|
|
303
|
+
const range = sceneRanges.get(annotation.scene);
|
|
304
|
+
if (!range || rawEndMs > range.end)
|
|
305
|
+
return rawEndMs;
|
|
306
|
+
const nextVisual = visuals.find(item => item.start_ms > startMs);
|
|
307
|
+
if (nextVisual && rawEndMs > nextVisual.start_ms)
|
|
308
|
+
return rawEndMs;
|
|
309
|
+
let ceiling = Math.min(range.end, nextVisual ? nextVisual.start_ms : Infinity);
|
|
310
|
+
if (rawEndMs <= cursor - 70)
|
|
311
|
+
ceiling = Math.min(ceiling, cursor - 70);
|
|
312
|
+
return Math.max(rawEndMs, Math.min(rawEndMs + lingerMs, ceiling));
|
|
313
|
+
};
|
|
314
|
+
const windowStart = follow.phrase !== undefined
|
|
315
|
+
? findExactMatch(alignment.text, follow.phrase, follow.occurrence, { missing: 'CUE_PHRASE_MISSING', ambiguous: 'CUE_AMBIGUOUS', occurrence: 'CUE_OCCURRENCE' }, `Annotation ${annotation.id}`, context)
|
|
316
|
+
: 0;
|
|
317
|
+
const windowEnd = follow.phrase !== undefined ? windowStart + follow.phrase.length : alignment.text.length;
|
|
318
|
+
requireCondition(windowEnd > windowStart, 'CUE_PHRASE_MISSING', `Annotation ${annotation.id}: empty spoken transcript`, 2, context);
|
|
319
|
+
const spanTiming = (spanStart, spanEnd, label) => {
|
|
320
|
+
const first = alignment.units.find(unit => unit.start === spanStart);
|
|
321
|
+
const last = alignment.units.find(unit => unit.end === spanEnd);
|
|
322
|
+
requireCondition(first && last, 'CUE_BOUNDARY', `Annotation ${annotation.id}: exact aligned boundaries unavailable for ${label}`, 2, context);
|
|
323
|
+
const start_ms = segment.start_ms + first.start_ms + offsetMs;
|
|
324
|
+
const end_ms = segment.start_ms + last.end_ms + offsetMs;
|
|
325
|
+
requireCondition(end_ms > start_ms, 'ANNOTATION_DURATION', `Annotation ${annotation.id}: aligned interval for ${label} has zero or negative duration`, 2, context);
|
|
326
|
+
return { start_ms, end_ms, cue_span: { segment: follow.segment, start: spanStart, end: spanEnd, form: alignment.form } };
|
|
327
|
+
};
|
|
328
|
+
const mode = follow.mode ?? 'words';
|
|
329
|
+
if (mode === 'phrase') {
|
|
330
|
+
const phraseStart = follow.phrase !== undefined ? windowStart : alignment.units[0].start;
|
|
331
|
+
const phraseEnd = follow.phrase !== undefined ? windowEnd : alignment.units.at(-1).end;
|
|
332
|
+
const timing = spanTiming(phraseStart, phraseEnd, follow.phrase ? JSON.stringify(follow.phrase) : follow.segment);
|
|
333
|
+
const endMs = extendWithLinger(timing.start_ms, timing.end_ms);
|
|
334
|
+
return [buildResolvedAnnotation(annotation, annotation.id, annotation.id, normalizedTarget, segment.scene, timing.start_ms, endMs, timing.cue_span, context)];
|
|
335
|
+
}
|
|
336
|
+
requireCondition(normalizedTarget.type === 'text', 'ANNOTATION_FOLLOW', `Annotation ${annotation.id}: word-following mode requires a text target`, 2, context);
|
|
337
|
+
const spokenWindow = alignment.text.slice(windowStart, windowEnd);
|
|
338
|
+
const intervals = [];
|
|
339
|
+
if (follow.tokens) {
|
|
340
|
+
let prevSpokenEnd = -1;
|
|
341
|
+
for (const [idx, token] of follow.tokens.entries()) {
|
|
342
|
+
const dispNeedle = normalizeSpaces(token.text);
|
|
343
|
+
const dispStart = findExactMatch(normalizedTarget.text, dispNeedle, token.occurrence, { missing: 'FOLLOW_TEXT_MISSING', ambiguous: 'FOLLOW_AMBIGUOUS', occurrence: 'FOLLOW_OCCURRENCE' }, `Annotation ${annotation.id} token ${idx + 1} text`, context);
|
|
344
|
+
const relSpoken = findExactMatch(spokenWindow, token.phrase, token.phrase_occurrence, { missing: 'CUE_PHRASE_MISSING', ambiguous: 'CUE_AMBIGUOUS', occurrence: 'CUE_OCCURRENCE' }, `Annotation ${annotation.id} token ${idx + 1} phrase`, context);
|
|
345
|
+
const absStart = windowStart + relSpoken;
|
|
346
|
+
const absEnd = absStart + token.phrase.length;
|
|
347
|
+
requireCondition(absStart >= prevSpokenEnd, 'ANNOTATION_ORDER', `Annotation ${annotation.id}: follow tokens must advance monotonically in speech`, 2, context);
|
|
348
|
+
prevSpokenEnd = absEnd;
|
|
349
|
+
const timing = spanTiming(absStart, absEnd, JSON.stringify(token.phrase));
|
|
350
|
+
intervals.push({ slice: { start: dispStart, end: dispStart + dispNeedle.length }, ...timing });
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
else {
|
|
354
|
+
const displayWords = tokenizeWords(normalizedTarget.text);
|
|
355
|
+
const spokenWords = tokenizeWords(spokenWindow);
|
|
356
|
+
requireCondition(displayWords.length > 0 && spokenWords.length > 0, 'ANNOTATION_FOLLOW', `Annotation ${annotation.id}: target text and spoken phrase must contain words`, 2, context);
|
|
357
|
+
requireCondition(displayWords.length === spokenWords.length, 'FOLLOW_TEXT_MISMATCH', `Annotation ${annotation.id}: display text has ${displayWords.length} words but spoken phrase has ${spokenWords.length} words; supply follow.tokens for editorial differences`, 2, context);
|
|
358
|
+
for (let i = 0; i < displayWords.length; i++) {
|
|
359
|
+
requireCondition(canonicalWord(displayWords[i].text) === canonicalWord(spokenWords[i].text), 'FOLLOW_TEXT_MISMATCH', `Annotation ${annotation.id}: word ${i + 1} differs between display (${JSON.stringify(displayWords[i].text)}) and speech (${JSON.stringify(spokenWords[i].text)}); supply follow.tokens for editorial differences`, 2, context);
|
|
360
|
+
const timing = spanTiming(windowStart + spokenWords[i].start, windowStart + spokenWords[i].end, JSON.stringify(spokenWords[i].text));
|
|
361
|
+
intervals.push({ slice: { start: displayWords[i].start, end: displayWords[i].end }, ...timing });
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
for (let i = 0; i < intervals.length - 1; i++) {
|
|
365
|
+
const cur = intervals[i];
|
|
366
|
+
const next = intervals[i + 1];
|
|
367
|
+
requireCondition(next.start_ms > cur.start_ms, 'ANNOTATION_ORDER', `Annotation ${annotation.id}: aligned word intervals must strictly advance in start time`, 2, context);
|
|
368
|
+
if (cur.end_ms > next.start_ms) {
|
|
369
|
+
cur.end_ms = next.start_ms;
|
|
370
|
+
requireCondition(cur.end_ms > cur.start_ms, 'ANNOTATION_DURATION', `Annotation ${annotation.id}: overlapping word boundaries collapsed word ${i + 1} to zero duration`, 2, context);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
if (lingerMs > 0) {
|
|
374
|
+
for (let i = 0; i < intervals.length; i++) {
|
|
375
|
+
const cur = intervals[i];
|
|
376
|
+
let targetEnd = extendWithLinger(cur.start_ms, cur.end_ms);
|
|
377
|
+
if (i < intervals.length - 1) {
|
|
378
|
+
const next = intervals[i + 1];
|
|
379
|
+
targetEnd = Math.min(targetEnd, next.start_ms);
|
|
380
|
+
const range = sceneRanges.get(annotation.scene);
|
|
381
|
+
const nextVisual = visuals.find(item => item.start_ms > cur.start_ms);
|
|
382
|
+
const ceiling = Math.min(range?.end ?? Infinity, nextVisual ? nextVisual.start_ms : Infinity);
|
|
383
|
+
if (next.start_ms <= ceiling && next.start_ms > targetEnd && next.start_ms - targetEnd < 75) {
|
|
384
|
+
targetEnd = next.start_ms;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
cur.end_ms = targetEnd;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
return intervals.map((item, idx) => buildResolvedAnnotation(annotation, `${annotation.id}:${idx + 1}`, annotation.id, { ...normalizedTarget, slice: item.slice }, segment.scene, item.start_ms, item.end_ms, item.cue_span, context));
|
|
133
391
|
});
|
|
392
|
+
const zooms = annotations
|
|
393
|
+
.filter(item => item.effect === 'zoom')
|
|
394
|
+
.sort((a, b) => a.start_ms - b.start_ms || a.end_ms - b.end_ms);
|
|
395
|
+
for (let i = 1; i < zooms.length; i++) {
|
|
396
|
+
const prev = zooms[i - 1];
|
|
397
|
+
const cur = zooms[i];
|
|
398
|
+
requireCondition(cur.start_ms >= prev.end_ms, 'ANNOTATION_ZOOM_OVERLAP', `Zoom annotations ${prev.id} (${Math.round(prev.start_ms)}..${Math.round(prev.end_ms)} ms) and ${cur.id} (${Math.round(cur.start_ms)}..${Math.round(cur.end_ms)} ms) overlap`, 2, { annotations: [prev.id, cur.id] });
|
|
399
|
+
}
|
|
134
400
|
requireCondition(cursor > 0, 'EMPTY_PRODUCTION', 'Production needs a positive duration');
|
|
135
401
|
const overlays = (story.overlays ?? []).map(overlay => {
|
|
136
402
|
const { id, src, box, opacity } = overlay;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slidevideo/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Turn a slide deck into a narrated video.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE-TERMS.md",
|
|
6
6
|
"type": "module",
|
|
@@ -31,8 +31,17 @@
|
|
|
31
31
|
"addons/slidevideo/package.json",
|
|
32
32
|
"addons/slidevideo/playback-entries.ts",
|
|
33
33
|
"addons/slidevideo/preview.ts",
|
|
34
|
+
"assets/fonts/OFL-LICENSES.txt",
|
|
35
|
+
"assets/fonts/instrument-serif-latin-2.woff2",
|
|
36
|
+
"assets/fonts/instrument-serif-latin-ext-1.woff2",
|
|
37
|
+
"assets/fonts/jetbrains-mono-latin-4.woff2",
|
|
38
|
+
"assets/fonts/jetbrains-mono-latin-ext-3.woff2",
|
|
39
|
+
"assets/fonts/plus-jakarta-sans-latin-6.woff2",
|
|
40
|
+
"assets/fonts/plus-jakarta-sans-latin-ext-5.woff2",
|
|
34
41
|
"dist/adapters/browser-runtime.d.ts",
|
|
35
42
|
"dist/adapters/browser-runtime.js",
|
|
43
|
+
"dist/adapters/capture-compression.d.ts",
|
|
44
|
+
"dist/adapters/capture-compression.js",
|
|
36
45
|
"dist/adapters/edge.d.ts",
|
|
37
46
|
"dist/adapters/edge.js",
|
|
38
47
|
"dist/adapters/elevenlabs.d.ts",
|
|
@@ -59,6 +68,8 @@
|
|
|
59
68
|
"dist/assembly.js",
|
|
60
69
|
"dist/calibration.d.ts",
|
|
61
70
|
"dist/calibration.js",
|
|
71
|
+
"dist/captions.d.ts",
|
|
72
|
+
"dist/captions.js",
|
|
62
73
|
"dist/cli.d.ts",
|
|
63
74
|
"dist/cli.js",
|
|
64
75
|
"dist/compositor.d.ts",
|
|
@@ -102,6 +113,8 @@
|
|
|
102
113
|
"dist/skill-install.js",
|
|
103
114
|
"dist/speech.d.ts",
|
|
104
115
|
"dist/speech.js",
|
|
116
|
+
"dist/stamp-fonts.d.ts",
|
|
117
|
+
"dist/stamp-fonts.js",
|
|
105
118
|
"dist/storyboard.d.ts",
|
|
106
119
|
"dist/storyboard.js",
|
|
107
120
|
"dist/timing.d.ts",
|
|
@@ -356,6 +356,117 @@
|
|
|
356
356
|
"minItems": 1
|
|
357
357
|
}
|
|
358
358
|
}
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
"properties": {
|
|
362
|
+
"target": {
|
|
363
|
+
"type": "object",
|
|
364
|
+
"properties": {
|
|
365
|
+
"type": {
|
|
366
|
+
"const": "text"
|
|
367
|
+
},
|
|
368
|
+
"container": {
|
|
369
|
+
"oneOf": [
|
|
370
|
+
{
|
|
371
|
+
"type": "object",
|
|
372
|
+
"additionalProperties": false,
|
|
373
|
+
"properties": {
|
|
374
|
+
"type": {
|
|
375
|
+
"const": "element"
|
|
376
|
+
},
|
|
377
|
+
"selector": {
|
|
378
|
+
"type": "string",
|
|
379
|
+
"minLength": 1
|
|
380
|
+
}
|
|
381
|
+
},
|
|
382
|
+
"required": [
|
|
383
|
+
"type",
|
|
384
|
+
"selector"
|
|
385
|
+
]
|
|
386
|
+
},
|
|
387
|
+
{
|
|
388
|
+
"type": "object",
|
|
389
|
+
"additionalProperties": false,
|
|
390
|
+
"properties": {
|
|
391
|
+
"type": {
|
|
392
|
+
"const": "shape"
|
|
393
|
+
},
|
|
394
|
+
"id": {
|
|
395
|
+
"type": "integer",
|
|
396
|
+
"minimum": 1
|
|
397
|
+
}
|
|
398
|
+
},
|
|
399
|
+
"required": [
|
|
400
|
+
"type",
|
|
401
|
+
"id"
|
|
402
|
+
]
|
|
403
|
+
}
|
|
404
|
+
]
|
|
405
|
+
},
|
|
406
|
+
"text": {
|
|
407
|
+
"type": "string",
|
|
408
|
+
"minLength": 1
|
|
409
|
+
},
|
|
410
|
+
"occurrence": {
|
|
411
|
+
"type": "integer",
|
|
412
|
+
"minimum": 1
|
|
413
|
+
},
|
|
414
|
+
"slice": {
|
|
415
|
+
"type": "object",
|
|
416
|
+
"properties": {
|
|
417
|
+
"start": {
|
|
418
|
+
"type": "integer",
|
|
419
|
+
"minimum": 0
|
|
420
|
+
},
|
|
421
|
+
"end": {
|
|
422
|
+
"type": "integer",
|
|
423
|
+
"minimum": 1
|
|
424
|
+
}
|
|
425
|
+
},
|
|
426
|
+
"required": [
|
|
427
|
+
"start",
|
|
428
|
+
"end"
|
|
429
|
+
],
|
|
430
|
+
"additionalProperties": false
|
|
431
|
+
}
|
|
432
|
+
},
|
|
433
|
+
"required": [
|
|
434
|
+
"type",
|
|
435
|
+
"text"
|
|
436
|
+
],
|
|
437
|
+
"additionalProperties": false
|
|
438
|
+
},
|
|
439
|
+
"fragments": {
|
|
440
|
+
"type": "array",
|
|
441
|
+
"items": {
|
|
442
|
+
"type": "object",
|
|
443
|
+
"properties": {
|
|
444
|
+
"x": {
|
|
445
|
+
"type": "number"
|
|
446
|
+
},
|
|
447
|
+
"y": {
|
|
448
|
+
"type": "number"
|
|
449
|
+
},
|
|
450
|
+
"width": {
|
|
451
|
+
"type": "number",
|
|
452
|
+
"exclusiveMinimum": 0
|
|
453
|
+
},
|
|
454
|
+
"height": {
|
|
455
|
+
"type": "number",
|
|
456
|
+
"exclusiveMinimum": 0
|
|
457
|
+
}
|
|
458
|
+
},
|
|
459
|
+
"required": [
|
|
460
|
+
"x",
|
|
461
|
+
"y",
|
|
462
|
+
"width",
|
|
463
|
+
"height"
|
|
464
|
+
],
|
|
465
|
+
"additionalProperties": false
|
|
466
|
+
},
|
|
467
|
+
"minItems": 1
|
|
468
|
+
}
|
|
469
|
+
}
|
|
359
470
|
}
|
|
360
471
|
]
|
|
361
472
|
}
|