@slidevideo/cli 0.10.0 → 0.11.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.
@@ -9,15 +9,8 @@ export type Narration = {
9
9
  text: string;
10
10
  voice?: Voice;
11
11
  };
12
- export type VisualAction = {
13
- type: 'slide';
14
- target: string;
15
- duration_ms: number;
16
- } | {
17
- type: 'reveal';
18
- click: number;
19
- duration_ms: number;
20
- } | {
12
+ export type PlayOverflow = 'continuous' | 'freeze' | 'fit_video';
13
+ export type PlayAction = {
21
14
  type: 'play';
22
15
  media: string;
23
16
  audio: 'source' | 'muted';
@@ -25,11 +18,24 @@ export type VisualAction = {
25
18
  trim_start_ms?: number;
26
19
  trim_end_ms?: number;
27
20
  rate?: number;
21
+ overflow?: PlayOverflow;
22
+ min_rate?: number;
23
+ max_rate?: number;
28
24
  };
29
- export type Action = (VisualAction | {
25
+ export type SpeakAction = {
30
26
  type: 'speak';
31
27
  segment: string;
28
+ };
29
+ export type VisualAction = {
30
+ type: 'slide';
31
+ target: string;
32
+ duration_ms: number;
32
33
  } | {
34
+ type: 'reveal';
35
+ click: number;
36
+ duration_ms: number;
37
+ } | PlayAction;
38
+ export type Action = (VisualAction | SpeakAction | {
33
39
  type: 'hold';
34
40
  duration_ms: number;
35
41
  }) & {
@@ -42,10 +48,33 @@ export type PhraseCue = {
42
48
  boundary: 'start' | 'end';
43
49
  offset_ms: number;
44
50
  };
51
+ export type MediaCue = {
52
+ media: string;
53
+ time_ms: number;
54
+ play?: string;
55
+ offset_ms?: number;
56
+ };
57
+ export type PhraseAlign = {
58
+ phrase: string;
59
+ occurrence?: number;
60
+ boundary: 'start' | 'end';
61
+ offset_ms?: number;
62
+ };
45
63
  export type Cue = {
46
64
  id: string;
47
65
  at: PhraseCue;
48
66
  action: VisualAction;
67
+ align?: never;
68
+ } | {
69
+ id: string;
70
+ at: MediaCue;
71
+ action: VisualAction;
72
+ align?: never;
73
+ } | {
74
+ id: string;
75
+ at: MediaCue;
76
+ action: SpeakAction;
77
+ align?: PhraseAlign;
49
78
  };
50
79
  export type Rectangle = {
51
80
  x: number;
@@ -102,7 +131,7 @@ export type WordFollowTiming = {
102
131
  tokens?: WordFollowTokenMap[];
103
132
  };
104
133
  export type AnnotationTiming = {
105
- at: number | PhraseCue;
134
+ at: number | PhraseCue | MediaCue;
106
135
  duration_ms: number;
107
136
  follow?: never;
108
137
  } | {
@@ -481,21 +510,37 @@ export type ResolvedOverlay = Pick<ImageOverlay, 'id' | 'src' | 'box' | 'opacity
481
510
  end_ms: number;
482
511
  }[];
483
512
  };
513
+ export type MediaSceneAction = (PlayAction | SpeakAction | {
514
+ type: 'hold';
515
+ duration_ms: number;
516
+ }) & {
517
+ id: string;
518
+ };
519
+ export type SlideScene = {
520
+ id: string;
521
+ slide: string;
522
+ media?: never;
523
+ duration_ms?: number;
524
+ actions: Action[];
525
+ };
526
+ export type MediaScene = {
527
+ id: string;
528
+ media: string;
529
+ slide?: never;
530
+ duration_ms?: number;
531
+ actions: MediaSceneAction[];
532
+ };
533
+ export type Scene = SlideScene | MediaScene;
484
534
  export type Storyboard = {
485
535
  version: 1;
486
- deck: string;
536
+ deck?: string;
487
537
  voice?: Voice;
488
538
  media: {
489
539
  id: string;
490
540
  src: string;
491
541
  }[];
492
542
  narration: Narration[];
493
- scenes: {
494
- id: string;
495
- slide: string;
496
- duration_ms?: number;
497
- actions: Action[];
498
- }[];
543
+ scenes: Scene[];
499
544
  cues: Cue[];
500
545
  annotations: Annotation[];
501
546
  overlays?: ImageOverlay[];
@@ -552,9 +597,23 @@ export type ScheduledAction = {
552
597
  form: string;
553
598
  };
554
599
  };
600
+ export type ScheduleScene = {
601
+ id: string;
602
+ kind: 'slide';
603
+ slide: string;
604
+ start_ms: number;
605
+ end_ms: number;
606
+ } | {
607
+ id: string;
608
+ kind: 'media';
609
+ media: string;
610
+ start_ms: number;
611
+ end_ms: number;
612
+ };
555
613
  export type Schedule = {
556
614
  version: 1;
557
615
  duration_ms: number;
616
+ scenes?: ScheduleScene[];
558
617
  actions: ScheduledAction[];
559
618
  media: {
560
619
  id: string;
package/dist/pipeline.js CHANGED
@@ -2,6 +2,7 @@ import { mkdir, readdir, rm } from 'node:fs/promises';
2
2
  import { dirname, join, resolve } from 'node:path';
3
3
  import { defaultVideoOutput, defaultViewport } from './contracts.js';
4
4
  import { loadStoryboard, fingerprint } from './storyboard.js';
5
+ import { hasSlideScenes, hasStandaloneMediaSchedule, projectDeckSchedule } from './standalone-media.js';
5
6
  import { presentationAdapter, ttsAdapters } from './adapters/registry.js';
6
7
  import { generateSpeech, resolveSpeechCache } from './speech.js';
7
8
  import { resolveTiming } from './timing.js';
@@ -93,14 +94,17 @@ export async function produce(options) {
93
94
  const source = resolve(options.storyboard);
94
95
  const story = await loadStoryboard(source);
95
96
  const overlays = story.overlays ?? [];
96
- const adapter = presentationAdapter(story.deck);
97
+ const adapter = hasSlideScenes(story) ? presentationAdapter(story.deck) : undefined;
97
98
  const initialViewport = options.command === 'inspect'
98
99
  ? (options.inspect?.kind === 'storyboard' ? options.inspect.viewport : undefined) ?? options.viewport ?? defaultViewport
99
100
  : options.command === 'validate'
100
101
  ? options.viewport ?? defaultViewport
101
102
  : undefined;
102
- const inspection = await adapter.inspect(story.deck);
103
- await adapter.validate(story, inspection, initialViewport ? { viewport: initialViewport } : undefined);
103
+ const inspection = adapter
104
+ ? await adapter.inspect(story.deck)
105
+ : { slides: [], media_ids: [], files: [], capabilities: ['standalone-media'] };
106
+ if (adapter)
107
+ await adapter.validate(story, inspection, initialViewport ? { viewport: initialViewport } : undefined);
104
108
  for (const segment of story.narration) {
105
109
  const voice = segment.voice ?? story.voice;
106
110
  requireCondition(voice, 'VOICE_REQUIRED', `Narration ${segment.id} needs a voice`);
@@ -115,6 +119,8 @@ export async function produce(options) {
115
119
  if (inspection.slides.some(slide => slide.clicks_known === false))
116
120
  result.warnings.push('Slides without explicit click bounds require runtime reveal checks before recording.');
117
121
  if (options.command === 'inspect') {
122
+ if (!adapter)
123
+ return { ...result, inspection: { ...inspection, annotation_targets: [] } };
118
124
  requireCondition(adapter.inspectTargets, 'ANNOTATION_CAPABILITY', `Adapter ${adapter.id} does not expose annotation targets`, 3);
119
125
  activeAdapter = adapter;
120
126
  try {
@@ -157,12 +163,13 @@ export async function produce(options) {
157
163
  throw error;
158
164
  }
159
165
  requireCondition(entries.length === 0, 'NEW_RUN_REQUIRED', 'build requires a new or empty directory. Use --resume for unchanged inputs.');
160
- await adapter.validate(story, inspection, { viewport: options.viewport ?? defaultViewport });
166
+ if (adapter)
167
+ await adapter.validate(story, inspection, { viewport: options.viewport ?? defaultViewport });
161
168
  }
162
169
  await mkdir(directory, { recursive: true });
163
170
  }
164
171
  else {
165
- if (options.command === 'build') {
172
+ if (options.command === 'build' && adapter) {
166
173
  await adapter.validate(story, inspection, { viewport: options.viewport ?? defaultViewport });
167
174
  }
168
175
  directory = await createDefaultRunDirectory();
@@ -193,7 +200,7 @@ export async function produce(options) {
193
200
  if (['build', 'record', 'assemble'].includes(options.command)) {
194
201
  requireCondition(recordedMode === undefined || recordedMode === production.verify_timing, 'RUN_MODE_MISMATCH', 'Timing verification differs from this run. Start a new run directory.');
195
202
  requireCondition(recordedVideo === undefined || (recordedVideo.width === video.width && recordedVideo.height === video.height && recordedVideo.fps === video.fps), 'RUN_MODE_MISMATCH', 'Output dimensions or frame rate differ from this run. Start a new run directory.');
196
- if (!(options.command === 'build' && !options.resume) && (options.command !== 'assemble' || recordedVideo !== undefined)) {
203
+ if (adapter && !(options.command === 'build' && !options.resume) && (options.command !== 'assemble' || recordedVideo !== undefined)) {
197
204
  await adapter.validate(story, inspection, { viewport: video });
198
205
  }
199
206
  if (options.command === 'build' || options.command === 'record') {
@@ -216,7 +223,8 @@ export async function produce(options) {
216
223
  const verifiedSpeech = new Map();
217
224
  const resolveSchedule = async () => {
218
225
  const schedule = await resolveTiming(story, await json(speechPath), verifiedSpeech);
219
- await adapter.validate(story, inspection, { ...(resolveViewport ? { viewport: resolveViewport } : {}), schedule });
226
+ if (adapter)
227
+ await adapter.validate(story, inspection, { ...(resolveViewport ? { viewport: resolveViewport } : {}), schedule });
220
228
  return schedule;
221
229
  };
222
230
  const selected = options.command === 'build' ? ['tts', 'resolve', 'record', 'assemble'] : [options.command];
@@ -299,34 +307,55 @@ export async function produce(options) {
299
307
  artifacts.push(schedulePath);
300
308
  }
301
309
  if (stage === 'record') {
302
- activeAdapter = adapter;
303
- let recordError;
304
- try {
305
- await adapter.prepare(story, schedule, join(directory, 'recording'), production);
306
- const visual = await adapter.execute(options.progress);
310
+ if (!adapter) {
311
+ const mapping = { offset_ms: 0, rate: 1, trim_start_ms: 0, trim_end_ms: schedule.duration_ms };
312
+ const visual = {
313
+ version: 1,
314
+ file: '',
315
+ properties: { width: video.width, height: video.height, duration_ms: schedule.duration_ms, fps: video.fps, has_audio: false },
316
+ events: [],
317
+ origin: { method: 'opening_markers', uncertainty_ms: 0, mapping },
318
+ timing: { version: 1, status: 'not_evaluated', target_ms: 100, uncertainty_ms: 0, mapping, checks: [], coverage: [], gaps: ['Standalone MP4 scenes are assembled directly from source media without presentation capture.'] },
319
+ provenance: { adapter: 'standalone-media', version: '1' },
320
+ };
307
321
  await saveJson(visualPath, visual);
308
- requireCondition(visual.timing.status !== 'failed' && (!production.verify_timing || visual.timing.status === 'accepted'), 'TIMING_ACCEPTANCE', 'Presentation artifact has no required timing result', 6);
309
- artifacts.push(visual.file, ...visual.timing.checks.map(check => check.evidence));
310
- Object.assign(run.manifest.versions, visual.provenance.dependencies, { [`presentation:${visual.provenance.adapter}`]: visual.provenance.version });
311
- }
312
- catch (error) {
313
- recordError = error;
314
- throw error;
322
+ artifacts.push(visualPath);
323
+ run.manifest.versions['presentation:standalone-media'] = '1';
324
+ run.manifest.versions.ffmpeg = (await execute('ffmpeg', ['-version'])).toString().split('\n')[0];
315
325
  }
316
- finally {
326
+ else {
327
+ const projection = hasStandaloneMediaSchedule(schedule) ? projectDeckSchedule(story, schedule) : undefined;
328
+ const recordStory = projection?.storyboard ?? story;
329
+ const recordSchedule = projection?.schedule ?? schedule;
330
+ activeAdapter = adapter;
331
+ let recordError;
317
332
  try {
318
- await adapter.cleanup();
333
+ await adapter.prepare(recordStory, recordSchedule, join(directory, 'recording'), production);
334
+ const visual = await adapter.execute(options.progress);
335
+ await saveJson(visualPath, visual);
336
+ requireCondition(visual.timing.status !== 'failed' && (!production.verify_timing || visual.timing.status === 'accepted'), 'TIMING_ACCEPTANCE', 'Presentation artifact has no required timing result', 6);
337
+ artifacts.push(visual.file, ...visual.timing.checks.map(check => check.evidence));
338
+ Object.assign(run.manifest.versions, visual.provenance.dependencies, { [`presentation:${visual.provenance.adapter}`]: visual.provenance.version });
319
339
  }
320
- catch (cleanupError) {
321
- if (!recordError && !interrupted && !controller.signal.aborted)
322
- throw cleanupError;
340
+ catch (error) {
341
+ recordError = error;
342
+ throw error;
323
343
  }
324
344
  finally {
325
- activeAdapter = undefined;
345
+ try {
346
+ await adapter.cleanup();
347
+ }
348
+ catch (cleanupError) {
349
+ if (!recordError && !interrupted && !controller.signal.aborted)
350
+ throw cleanupError;
351
+ }
352
+ finally {
353
+ activeAdapter = undefined;
354
+ }
326
355
  }
356
+ artifacts.push(...await filesIn(join(directory, 'recording')));
357
+ run.manifest.versions.ffmpeg = (await execute('ffmpeg', ['-version'])).toString().split('\n')[0];
327
358
  }
328
- artifacts.push(...await filesIn(join(directory, 'recording')));
329
- run.manifest.versions.ffmpeg = (await execute('ffmpeg', ['-version'])).toString().split('\n')[0];
330
359
  }
331
360
  if (stage === 'assemble') {
332
361
  requireCondition(run.manifest.video, 'RUN_MANIFEST', 'Run manifest has no recorded video output settings. Start a new run directory.');
@@ -8,9 +8,14 @@ export type PreviewSession = {
8
8
  } | NativePreview;
9
9
  export type PreviewScene = {
10
10
  id: string;
11
+ kind?: 'slide' | 'media';
11
12
  slide: string;
13
+ media?: string;
14
+ media_url?: string;
12
15
  start_ms: number;
13
16
  end_ms: number;
17
+ deck_start_ms?: number;
18
+ deck_end_ms?: number;
14
19
  };
15
20
  export type PreviewAudioCue = {
16
21
  segment: string;
@@ -18,6 +23,17 @@ export type PreviewAudioCue = {
18
23
  end_ms: number;
19
24
  url: string;
20
25
  };
26
+ export type PreviewMediaSlice = {
27
+ media: string;
28
+ scene: string;
29
+ start_ms: number;
30
+ end_ms: number;
31
+ trim_start_ms: number;
32
+ trim_end_ms: number;
33
+ rate: number;
34
+ audio?: 'source' | 'muted';
35
+ volume?: number;
36
+ };
21
37
  export type PlayerConfig = {
22
38
  deck: string;
23
39
  duration: number;
@@ -27,10 +43,14 @@ export type PlayerConfig = {
27
43
  approximate_cues: string[];
28
44
  scenes: PreviewScene[];
29
45
  audio: PreviewAudioCue[];
46
+ media?: PreviewMediaSlice[];
47
+ standalone_annotations?: ResolvedAnnotation[];
30
48
  stage: {
31
49
  url: string;
32
50
  } | {
33
51
  annotations: ResolvedAnnotation[];
52
+ } | {
53
+ standalone: true;
34
54
  };
35
55
  };
36
56
  export type NativeFrame = {