@slidevideo/cli 0.2.1 → 0.2.2

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 CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.2.2
6
+
7
+ - Support finite native PowerPoint slide transitions, broader finite `MainSequence` animations (including `Wipe`, `Split`, `Fly In`, emphasis, exit, motion paths, and automatic pre-click entry), static `.svg` graphics, cropped pictures, grouped shape targets, dynamic full-resolution window capture with output letterboxing, and storyboard video trims (`trim_start_ms` / `trim_end_ms`).
8
+
5
9
  ## 0.2.1
6
10
 
7
11
  - Add storyboard-controlled underline annotations with solid or dashed strokes and optional left-to-right wipes.
@@ -9,7 +9,7 @@ export declare class PowerPointAdapter implements PresentationAdapter {
9
9
  private prepared?;
10
10
  inspect(file: string): Promise<PresentationInspection>;
11
11
  private targets;
12
- inspectTargets(_deck: string, viewport: Viewport): Promise<PresentationInspection['annotation_targets']>;
12
+ inspectTargets(_deck: string, _viewport: Viewport): Promise<PresentationInspection['annotation_targets']>;
13
13
  private slide;
14
14
  validate(story: Storyboard, _inspection: PresentationInspection, options?: {
15
15
  viewport?: Viewport;
@@ -31,10 +31,21 @@ function nativeFailure(failure) {
31
31
  function object(value) { return value !== null && typeof value === 'object' && !Array.isArray(value); }
32
32
  function finite(value) { return typeof value === 'number' && Number.isFinite(value); }
33
33
  function rectangle(value) { return object(value) && ['x', 'y', 'width', 'height'].every(key => finite(value[key])) && Number(value.width) > 0 && Number(value.height) > 0; }
34
+ function effectSpanMs(effect) {
35
+ const cycleMs = effect.duration_ms * (effect.auto_reverse !== 0 ? 2 : 1);
36
+ const countSpan = effect.repeat_count > 0 ? cycleMs * effect.repeat_count : cycleMs;
37
+ if (effect.repeat_duration_ms > 0) {
38
+ return Math.max(0, effect.repeat_count > 0 ? Math.min(countSpan, effect.repeat_duration_ms) : effect.repeat_duration_ms);
39
+ }
40
+ return Math.max(0, countSpan);
41
+ }
42
+ function slideEntrySettleMs(slide) {
43
+ return Math.max(0, slide.transition_duration_ms) + Math.max(0, slide.entry_duration_ms);
44
+ }
34
45
  function parseDeck(value) {
35
46
  requireCondition(object(value) && value.version === 1 && value.kind === 'inspection' && typeof value.deck_sha256 === 'string' && finite(value.width) && finite(value.height) && value.width > 0 && value.height > 0 && Array.isArray(value.slides) && value.slides.length > 0 && Array.isArray(value.media) && Array.isArray(value.unsupported) && object(value.dependencies), 'POWERPOINT_PROTOCOL', 'Native inspection returned an invalid catalog', 5);
36
47
  for (const slide of value.slides) {
37
- requireCondition(object(slide) && typeof slide.id === 'string' && ['native_id', 'index', 'transition', 'auto_advance', 'hidden', 'interactive'].every(key => finite(slide[key])) && Array.isArray(slide.effects) && Array.isArray(slide.shapes), 'POWERPOINT_PROTOCOL', 'Native inspection returned an invalid slide', 5);
48
+ requireCondition(object(slide) && typeof slide.id === 'string' && ['native_id', 'index', 'transition', 'transition_duration_ms', 'auto_advance', 'hidden', 'interactive'].every(key => finite(slide[key])) && Array.isArray(slide.effects) && Array.isArray(slide.shapes), 'POWERPOINT_PROTOCOL', 'Native inspection returned an invalid slide', 5);
38
49
  for (const shape of slide.shapes) {
39
50
  requireCondition(object(shape), 'POWERPOINT_PROTOCOL', 'Native inspection returned an invalid shape identity', 5);
40
51
  const bounds = shape.bounds;
@@ -51,6 +62,7 @@ function parseDeck(value) {
51
62
  requireCondition(typeof version === 'string', 'POWERPOINT_PROTOCOL', 'Native inspection returned invalid dependency versions', 5);
52
63
  const deck = value;
53
64
  for (const slide of deck.slides) {
65
+ slide.entry_duration_ms = 0;
54
66
  slide.clicks = [];
55
67
  let previousStart = 0;
56
68
  let previousEnd = 0;
@@ -60,11 +72,12 @@ function parseDeck(value) {
60
72
  previousStart = 0;
61
73
  previousEnd = 0;
62
74
  }
63
- if (!slide.clicks.length)
64
- continue;
65
75
  const start = (effect.trigger === 3 ? previousEnd : previousStart) + effect.delay_ms;
66
- const end = start + effect.duration_ms;
67
- slide.clicks[slide.clicks.length - 1] = Math.max(slide.clicks[slide.clicks.length - 1], end);
76
+ const end = start + effectSpanMs(effect);
77
+ if (slide.clicks.length)
78
+ slide.clicks[slide.clicks.length - 1] = Math.max(slide.clicks[slide.clicks.length - 1], end);
79
+ else
80
+ slide.entry_duration_ms = Math.max(slide.entry_duration_ms, end);
68
81
  previousStart = start;
69
82
  previousEnd = end;
70
83
  }
@@ -251,8 +264,8 @@ class NativeSession {
251
264
  requireCondition(graceful && object(cleanup) && Array.isArray(cleanup.gaps) && cleanup.gaps.length === 0, 'POWERPOINT_CLEANUP', `Native cleanup could not be confirmed. Preserve the diagnostics in ${this.directory} and close only the identified private presentation if necessary.`, 5);
252
265
  }
253
266
  }
254
- function isSupportedNativeEffect(deck, slide, effect, clicked) {
255
- return [1, 10].includes(effect.type) && [1, 2, 3].includes(effect.trigger) && clicked && effect.duration_ms >= 0 && effect.delay_ms >= 0 && effect.repeat_count <= 1 && effect.repeat_count >= 0 && effect.repeat_duration_ms === 0 && effect.auto_reverse === 0 && effect.exit === 0 && !deck.media.some(media => media.native_id === slide.native_id && media.shape === effect.shape);
267
+ function isSupportedNativeEffect(deck, slide, effect) {
268
+ return [1, 2, 3].includes(effect.trigger) && effect.duration_ms >= 0 && effect.delay_ms >= 0 && effect.repeat_count >= 0 && effect.repeat_count <= 100 && effect.repeat_duration_ms >= 0 && effect.repeat_duration_ms <= 600000 && !deck.media.some(media => media.native_id === slide.native_id && media.shape === effect.shape);
256
269
  }
257
270
  function isSupportedNativeMedia(media) {
258
271
  return media.duration_ms > 0 && media.start_ms === 0 && Math.abs(media.end_ms - media.duration_ms) <= 1 && media.autoplay === 0 && media.loop === 0 && media.rewind === 0 && media.fullscreen === 0;
@@ -271,15 +284,12 @@ function deckCapabilityIssues(deck) {
271
284
  if (slide.id && (counts.get(slide.id) ?? 0) > 1) {
272
285
  issues.push({ slide: label, reason: `Slide name ${slide.id} is ambiguous; use slide-${slide.native_id}` });
273
286
  }
274
- if (slide.transition !== 0 || slide.auto_advance !== 0 || slide.hidden !== 0 || slide.interactive !== 0) {
275
- issues.push({ slide: label, reason: 'Requires slide cuts, manual advancement, visible slides and no interactive animation sequences' });
287
+ if (slide.transition_duration_ms < 0 || slide.auto_advance !== 0 || slide.hidden !== 0 || slide.interactive !== 0) {
288
+ issues.push({ slide: label, reason: 'Requires manual advancement, visible slides, finite transitions and no interactive animation sequences' });
276
289
  }
277
- let clicked = false;
278
290
  for (const effect of slide.effects) {
279
- if (effect.trigger === 1)
280
- clicked = true;
281
- if (!isSupportedNativeEffect(deck, slide, effect, clicked)) {
282
- issues.push({ slide: label, reason: 'Contains an unsupported effect; only finite click groups of entrance Appear and Fade effects are supported' });
291
+ if (!isSupportedNativeEffect(deck, slide, effect)) {
292
+ issues.push({ slide: label, reason: 'Contains an unsupported effect; only finite MainSequence animations without unbounded repeats, interactive triggers or video animations are supported' });
283
293
  break;
284
294
  }
285
295
  }
@@ -325,6 +335,8 @@ export class PowerPointAdapter {
325
335
  index: slide.index,
326
336
  clicks: slide.clicks.length,
327
337
  clicks_known: true,
338
+ ...(slide.transition_duration_ms > 0 ? { transition_duration_ms: slide.transition_duration_ms } : {}),
339
+ ...(slide.entry_duration_ms > 0 ? { entry_duration_ms: slide.entry_duration_ms } : {}),
328
340
  ...(slide.clicks.length ? { click_durations_ms: [...slide.clicks] } : {}),
329
341
  })),
330
342
  media_ids: [...new Set(this.deck.media.map(media => media.id))],
@@ -354,9 +366,8 @@ export class PowerPointAdapter {
354
366
  targets() {
355
367
  return this.deck.slides.map(slide => ({ slide: slide.id || `slide-${slide.native_id}`, clicks: slide.clicks.length, targets: slide.shapes.map(shape => ({ identity: String(shape.id), description: `Slide ${slide.index} (native ${slide.native_id}), shape ${shape.id}: ${shape.name}. ${shape.unsupported.length ? `Unsupported: ${shape.unsupported.join('; ')}` : `Stationary whole shape, visible from click ${shape.visible_from_click}`}` })) }));
356
368
  }
357
- async inspectTargets(_deck, viewport) {
369
+ async inspectTargets(_deck, _viewport) {
358
370
  requireCondition(this.deck, 'POWERPOINT_INSPECTION', 'Inspect the native deck before discovering annotation targets', 3);
359
- requireCondition(Math.abs(viewport.width / viewport.height - this.deck.width / this.deck.height) <= 2 / viewport.height, 'POWERPOINT_CAPABILITY', 'Native output aspect ratio must match the PowerPoint slide size. Adjust --width and --height or the deck page setup.', 3);
360
371
  return this.targets();
361
372
  }
362
373
  slide(id) {
@@ -368,21 +379,15 @@ export class PowerPointAdapter {
368
379
  const deck = this.deck;
369
380
  const schedule = options?.schedule;
370
381
  requireCondition(deck, 'POWERPOINT_INSPECTION', 'Inspect the native deck before validation', 3);
371
- if (options?.viewport) {
372
- requireCondition(Math.abs(options.viewport.width / options.viewport.height - deck.width / deck.height) <= 2 / options.viewport.height, 'POWERPOINT_CAPABILITY', 'Native output aspect ratio must match the PowerPoint slide size. Adjust --width and --height or the deck page setup.', 3);
373
- }
374
382
  requireCondition(deck.unsupported.length === 0, 'POWERPOINT_CAPABILITY', deck.unsupported.map(item => `${item.slide ? `Slide ${item.slide}: ` : ''}${item.reason}`).join('\n'), 3);
375
383
  for (const slide of deck.slides) {
376
- requireCondition(slide.transition === 0 && slide.auto_advance === 0 && slide.hidden === 0 && slide.interactive === 0, 'POWERPOINT_CAPABILITY', `Slide ${slide.id} requires slide cuts, manual advancement, visible slides and no interactive animation sequences`, 3);
377
- let clicked = false;
384
+ requireCondition(slide.transition_duration_ms >= 0 && slide.auto_advance === 0 && slide.hidden === 0 && slide.interactive === 0, 'POWERPOINT_CAPABILITY', `Slide ${slide.id} requires manual advancement, visible slides, finite transitions and no interactive animation sequences`, 3);
378
385
  for (const effect of slide.effects) {
379
- if (effect.trigger === 1)
380
- clicked = true;
381
- requireCondition(isSupportedNativeEffect(deck, slide, effect, clicked), 'POWERPOINT_CAPABILITY', `Slide ${slide.id} contains an unsupported effect. Only finite click groups of entrance Appear and Fade effects are supported; automatic entry, repeats, exits, interactive triggers and video animations are unsupported.`, 3);
386
+ requireCondition(isSupportedNativeEffect(deck, slide, effect), 'POWERPOINT_CAPABILITY', `Slide ${slide.id} contains an unsupported effect. Only finite MainSequence animations without unbounded repeats, interactive triggers or video animations are supported.`, 3);
382
387
  }
383
388
  }
384
389
  for (const media of deck.media)
385
- requireCondition(isSupportedNativeMedia(media), 'POWERPOINT_CAPABILITY', `Video ${media.id} requires full-source playback with no native trim, autoplay, loop, rewind or fullscreen transform`, 3);
390
+ requireCondition(isSupportedNativeMedia(media), 'POWERPOINT_CAPABILITY', `Video ${media.id} requires full-source embedded media with no native trim, autoplay, loop, rewind or fullscreen transform`, 3);
386
391
  for (const declaration of story.media) {
387
392
  const candidates = deck.media.filter(media => media.id === declaration.id);
388
393
  requireCondition(candidates.length > 0, 'MEDIA_TARGET', `The native deck has no embedded video named ${declaration.id}`, 3);
@@ -399,10 +404,13 @@ export class PowerPointAdapter {
399
404
  this.slide(scene.slide);
400
405
  const actions = [...story.scenes.flatMap(scene => scene.actions), ...story.cues.map(cue => ({ ...cue.action, id: cue.id }))];
401
406
  for (const action of actions) {
402
- if (action.type === 'slide')
403
- this.slide(action.target);
407
+ if (action.type === 'slide') {
408
+ const targetSlide = this.slide(action.target);
409
+ const requiredSettle = slideEntrySettleMs(targetSlide);
410
+ requireCondition(action.duration_ms + 0.1 >= requiredSettle, 'SLIDE_TRANSITION_DURATION', `Slide action ${action.id} must reserve at least ${requiredSettle} ms for ${targetSlide.id} transition and automatic entry animations`, 3);
411
+ }
404
412
  if (action.type === 'play')
405
- requireCondition((action.trim_start_ms ?? 0) === 0 && action.trim_end_ms === undefined && (action.rate ?? 1) === 1, 'POWERPOINT_CAPABILITY', `Video action ${action.id} requires full-source playback at rate 1 without storyboard trims`, 3);
413
+ requireCondition((action.rate ?? 1) === 1, 'POWERPOINT_CAPABILITY', `Video action ${action.id} requires playback rate 1 in native PowerPoint playback`, 3);
406
414
  }
407
415
  for (const annotation of story.annotations)
408
416
  requireCondition(annotation.target.type !== 'element', 'ANNOTATION_TARGET', `Annotation ${annotation.id} uses a Slidev selector. PowerPoint requires an existing shape ID or normalized region.`, 3);
@@ -447,7 +455,13 @@ export class PowerPointAdapter {
447
455
  if (action.type === 'slide') {
448
456
  slide = this.slide(action.target);
449
457
  click = 0;
450
- operations.push({ id: item.id, scene: item.scene, type: 'slide', at_ms: item.start_ms, end_ms: item.end_ms, native_id: slide.native_id, settle_ms: action.duration_ms });
458
+ const requiredSettle = item.start_ms > 0 ? slideEntrySettleMs(slide) : slide.entry_duration_ms;
459
+ if (item.start_ms > 0 && !item.id.endsWith(':slide')) {
460
+ requireCondition(action.duration_ms + 0.1 >= requiredSettle, 'SLIDE_TRANSITION_DURATION', `Slide action ${item.id} must reserve at least ${requiredSettle} ms for ${slide.id} transition and automatic entry animations`, 3);
461
+ }
462
+ const settleMs = Math.max(action.duration_ms, requiredSettle);
463
+ requireCondition(item.start_ms + settleMs <= schedule.duration_ms + 0.1, 'SLIDE_TRANSITION_DURATION', `Slide ${item.id} requires ${settleMs} ms to settle on ${slide.id}, exceeding the resolved schedule duration`, 3);
464
+ operations.push({ id: item.id, scene: item.scene, type: 'slide', at_ms: item.start_ms, end_ms: item.start_ms + settleMs, native_id: slide.native_id, settle_ms: settleMs });
451
465
  }
452
466
  if (action.type === 'reveal') {
453
467
  requireCondition(slide && action.click === click + 1 && action.click <= slide.clicks.length && action.duration_ms + 0.1 >= slide.clicks[action.click - 1], 'REVEAL_TARGET', `Reveal ${item.id} must execute the next native click and include its complete duration`, 3);
@@ -460,7 +474,9 @@ export class PowerPointAdapter {
460
474
  const source = schedule.media.find(media => media.id === action.media);
461
475
  requireCondition(candidates.length === 1 && declaration && source, 'MEDIA_TARGET', `Video ${action.media} is missing or ambiguous on the active native slide`, 3);
462
476
  requireCondition(Math.abs(source.duration_ms - candidates[0].duration_ms) <= 100, 'MEDIA_SOURCE_MISMATCH', `Native video duration differs from source for ${action.media}`);
463
- operations.push({ id: item.id, scene: item.scene, type: 'play', at_ms: item.start_ms, end_ms: item.end_ms, native_id: candidates[0].native_id, shape: candidates[0].shape, source_duration_ms: source.duration_ms, frame_period_ms: 0 });
477
+ const trimStart = action.trim_start_ms ?? 0;
478
+ const trimEnd = action.trim_end_ms ?? source.duration_ms;
479
+ operations.push({ id: item.id, scene: item.scene, type: 'play', at_ms: item.start_ms, end_ms: item.end_ms, native_id: candidates[0].native_id, shape: candidates[0].shape, source_duration_ms: source.duration_ms, trim_start_ms: trimStart, trim_end_ms: trimEnd, frame_period_ms: 0 });
464
480
  }
465
481
  }
466
482
  for (const [index, operation] of operations.entries())
@@ -357,6 +357,8 @@ export type PresentationInspection = {
357
357
  index: number;
358
358
  clicks: number;
359
359
  clicks_known?: boolean;
360
+ transition_duration_ms?: number;
361
+ entry_duration_ms?: number;
360
362
  click_durations_ms?: number[];
361
363
  }[];
362
364
  media_ids: string[];
@@ -57,6 +57,8 @@ export declare function produce(options: Options): Promise<{
57
57
  index: number;
58
58
  clicks: number;
59
59
  clicks_known?: boolean;
60
+ transition_duration_ms?: number;
61
+ entry_duration_ms?: number;
60
62
  click_durations_ms?: number[];
61
63
  }[];
62
64
  media_ids: string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slidevideo/cli",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Turn a slide deck into a narrated video.",
5
5
  "license": "SEE LICENSE IN LICENSE-TERMS.md",
6
6
  "type": "module",
@@ -17,7 +17,7 @@ Every storyboard `scene.slide` and `slide.target` value must match `^[a-zA-Z][a-
17
17
  ### PowerPoint
18
18
 
19
19
  - Set a unique native `Slide.Name` matching `^[a-zA-Z][a-zA-Z0-9_-]*$`, or use the unambiguous `slide-<SlideID>` alias returned by `slidevideo inspect --deck <file> --json`. `SlideID` is PowerPoint's internal identifier, not the one-based slide index.
20
- - Every slide must use cut transitions, manual advancement, and visible slides. Native slide transitions, timed `AdvanceOnTime` settings, hidden slides, and interactive trigger sequences fail `POWERPOINT_CAPABILITY`.
20
+ - Every slide must use manual advancement and visible slides, with either cut transitions or finite native slide transitions. Timed `AdvanceOnTime` settings, hidden slides, and interactive trigger sequences fail `POWERPOINT_CAPABILITY`. Explicit `slide` actions must reserve at least `transition_duration_ms + entry_duration_ms` as reported by `slidevideo inspect --deck <file> --json`.
21
21
 
22
22
  ## Click reveals
23
23
 
@@ -29,8 +29,8 @@ Every storyboard `scene.slide` and `slide.target` value must match `^[a-zA-Z][a-
29
29
 
30
30
  ### PowerPoint
31
31
 
32
- - Use sequential finite click groups made of entrance `Appear` or `Fade` effects only.
33
- - Automatic entry before the first click, repeats, exit effects, emphasis effects, motion paths, interactive triggers, and media animations fail `POWERPOINT_CAPABILITY`.
32
+ - Use finite `MainSequence` animations (automatic pre-click `WithPrevious`/`AfterPrevious` entry effects and sequential click groups across entrance, emphasis, exit, and motion presets).
33
+ - Unbounded repeats (`Until Next Click` / `Until End of Slide`), interactive triggers, speed transforms, and animations on embedded video shapes fail `POWERPOINT_CAPABILITY`.
34
34
  - Set `reveal.duration_ms` to at least the native click-group duration reported in `slides[].click_durations_ms` by `slidevideo inspect --deck <file> --json`. Each `reveal` must execute the next consecutive click step `1..N` on the active slide.
35
35
 
36
36
  ## Managed media
@@ -46,7 +46,7 @@ Every storyboard `scene.slide` and `slide.target` value must match `^[a-zA-Z][a-
46
46
 
47
47
  - Embed the local video file directly on the slide as an ungrouped shape and set `Shape.Name` to the storyboard `media[].id`. Linked or online video fails capability validation.
48
48
  - Point `media[].src` in `slidevideo.yaml` at the exact file embedded into the `.pptx` package so its SHA-256 digest and duration match.
49
- - Disable autoplay, loop, rewind, native trims, fullscreen playback, cropping, rotation, flipping, and shape animations on the video shape. PowerPoint `play` actions support full-source playback at `rate: 1` with `trim_start_ms` omitted or `0` and `trim_end_ms` omitted.
49
+ - Disable autoplay, loop, rewind, native trims, fullscreen playback, rotation, flipping, 3D transforms, and shape animations on the video shape. Static cropping and borders or shadows are allowed. PowerPoint `play` actions run at `rate: 1` and support optional storyboard `trim_start_ms` and `trim_end_ms`.
50
50
 
51
51
  ## Annotation targets and canvas bounds
52
52
 
@@ -60,8 +60,8 @@ Every storyboard `scene.slide` and `slide.target` value must match `^[a-zA-Z][a-
60
60
  ### PowerPoint
61
61
 
62
62
  - Shape annotations (`highlight` and `underline`) use `target: { type: shape, id: <number> }` with the integer shape ID reported by `slidevideo inspect --deck <file> --json`. Shape names are descriptive only and are not valid target identifiers.
63
- - `--width` and `--height` must match the native PowerPoint slide aspect ratio. The native slideshow window caps at `1600` physical pixels wide and scales uniformly to the output dimensions.
64
- - Grouped shapes, group members, cropped pictures, rotated or flipped shapes, paragraph-level text animations, and shapes hidden or dimmed after animation fail `ANNOTATION_TARGET`. Any entrance `Appear` or `Fade` on the target shape must finish settling before the annotation interval starts.
63
+ - `--width` and `--height` scale the native slide uniformly and letterbox when the output aspect ratio differs from the slide size. The native slideshow window sizes dynamically to the monitor bounds (using borderless capture during recording when windowed chrome would exceed the work area) to preserve full native resolution when the display permits.
64
+ - Static `.svg` media parts, unrotated cropped pictures, and stationary groups or group members are supported. Rotated, flipped, or 3D shapes, paragraph-level text animations, and shapes exited or hidden after animation fail `ANNOTATION_TARGET`. Any animation on the target shape must finish settling before the annotation interval starts.
65
65
  - Both Slidev and PowerPoint also accept `target: { type: region, units: normalized, x, y, width, height }` in `[0, 1]` slide coordinates without modifying the deck.
66
66
 
67
67
  ### Contrast presets
@@ -18,7 +18,7 @@ For a visual pacing review, use `play --storyboard <file>` and open the printed
18
18
 
19
19
  For a requested finished video, use `build`. It validates inputs, generates or reuses matching speech, resolves timing, captures the presentation, and assembles the MP4 at `1920` by `1080` and `30 fps` by default. Pass `--width` and `--height` together and optional `--fps` of `15`, `24`, `30`, or `60` to `build` or `record` to select another resolution or frame rate. `record` and `build` bind `width`, `height`, and `fps` in the run manifest. `assemble` and `build --resume` inherit those settings and fail with `RUN_MODE_MISMATCH` when you pass conflicting values.
20
20
 
21
- `tts` and `resolve` reject `--width`, `--height`, and `--fps` because speech cache keys and millisecond schedules are independent of pixel dimensions. Changing from `1280` by `720` to `1920` by `1080` requires a new run directory for capture and assembly while reusing cached speech and alignment through `--cache-dir`. Scaling within the same aspect ratio preserves Slidev layout and frame-fixed `overlays[].box` placement, while changing aspect ratio alters Slidev letterboxing and fails `POWERPOINT_CAPABILITY` when it diverges from a `.pptx` deck's slide size.
21
+ `tts` and `resolve` reject `--width`, `--height`, and `--fps` because speech cache keys and millisecond schedules are independent of pixel dimensions. Changing from `1280` by `720` to `1920` by `1080` requires a new run directory for capture and assembly while reusing cached speech and alignment through `--cache-dir`. Scaling within the same aspect ratio preserves Slidev and PowerPoint layout and frame-fixed `overlays[].box` placement, while changing aspect ratio alters letterboxing for both adapters.
22
22
 
23
23
  Use staged commands when an intermediate result is useful to the creator. `tts` prepares audio and alignment, `resolve` calculates the schedule, `record` captures from resolved inputs, and `assemble` produces the final MP4. Begin with a new or empty run directory. Commands reject a nonempty directory without a run manifest before writing run artifacts. A requested narration review can occur after `tts` and before capture. `record` does not generate speech implicitly.
24
24
 
@@ -95,7 +95,7 @@ Every scene action has required `id` and `type`. The other fields depend on the
95
95
  | `trim_end_ms` | Optional nonnegative source position. Default source duration. Must be after the start and no later than source duration. |
96
96
  | `rate` | Optional number from 0.5 to 2. Default `1`. Picture and source audio use the same rate. |
97
97
 
98
- The duration formula is `(trim_end_ms - trim_start_ms) / rate`, with omitted trims replaced by their defaults. Schema acceptance does not imply adapter support. Native PowerPoint currently accepts only start `0`, omitted end and rate `1`.
98
+ The duration formula is `(trim_end_ms - trim_start_ms) / rate`, with omitted trims replaced by their defaults. Schema acceptance does not imply adapter support. Native PowerPoint currently requires rate `1` and supports optional `trim_start_ms` and `trim_end_ms`.
99
99
 
100
100
  Source-audio volume is an explicit fixed gain. The storyboard has no automatic ducking option.
101
101
 
@@ -132,11 +132,11 @@ The storyboard reserves intended durations. The resolved schedule establishes ex
132
132
  | Concern | Slidev `.md` | Native PowerPoint `.pptx` |
133
133
  | --- | --- | --- |
134
134
  | Slide targets | Authored frontmatter `name`, otherwise `slide-<one-based effective index>`. Imports and filtering affect that index. | Unique native `Slide.Name`, or unambiguous `slide-<SlideID>`. SlideID is not the slide position. Names must also fit the YAML target syntax. |
135
- | Reveals | Native click-driven content, such as `v-click`. Steps advance and must fit known or runtime-checked bounds. | Consecutive finite entrance Appear/Fade click groups. The declared duration must cover the complete native group. |
136
- | Slide changes | Authored deck transition, with a matching settling allowance. | Cuts. Native slide transitions, timed advancement, hidden slides and interactive sequences are unsupported. |
137
- | Video | Managed media element with a matching declared source. Trims and rates follow the shared action contract. | Full embedded video at rate 1, with exact source-byte matching. No native trim, autoplay, loop, rewind or fullscreen transform. |
135
+ | Reveals | Native click-driven content, such as `v-click`. Steps advance and must fit known or runtime-checked bounds. | Consecutive finite `MainSequence` click groups (entrance, emphasis, exit, and motion presets). The declared duration must cover the complete native group. |
136
+ | Slide changes | Authored deck transition, with a matching settling allowance. | Cuts or finite native slide transitions, plus optional automatic pre-click entry animations. Timed advancement, hidden slides, and interactive sequences are unsupported. |
137
+ | Video | Managed media element with a matching declared source. Trims and rates follow the shared action contract. | Embedded video at rate `1` with exact source-byte matching and optional storyboard `trim_start_ms` / `trim_end_ms`. No native trim, autoplay, loop, rewind, or fullscreen transform. |
138
138
  | Runtime | Playwright-controlled Chromium and the playback addon. | Windows desktop PowerPoint and FFmpeg native window capture on an unlocked interactive desktop. |
139
- | Viewport and aspect ratio | Scales the deck to `--width` and `--height`, letterboxing when the aspect ratio differs from the slide canvas. | `--width` and `--height` must match the native PowerPoint slide aspect ratio. The native slideshow window is capped at 1600 physical pixels wide and scaled to output dimensions. |
139
+ | Viewport and aspect ratio | Scales the deck to `--width` and `--height`, letterboxing when the aspect ratio differs from the slide canvas. | Scales the deck to `--width` and `--height`, letterboxing when the aspect ratio differs from the slide size and sizing the capture window dynamically to the monitor bounds. |
140
140
 
141
141
  Linked or online media and unsupported dynamic PowerPoint objects fail capability validation. Run `slidevideo inspect --deck <file> --json` to list slide targets, `slide-<SlideID>` aliases, click counts, native click-group durations, media IDs, and unsupported native features before scheduling them in the storyboard.
142
142
 
@@ -220,7 +220,7 @@ Requested final-frame verification reports fill and bottom-border checks separat
220
220
 
221
221
  The duration is positive milliseconds. An interval containing no output frame at the selected frame rate fails with `ANNOTATION_FRAME_RANGE`. Intervals are half-open `[start,end)` and do not extend scenes. They must fit one scene, slide visit, and settled reveal state. An annotation may end at a navigation or reveal boundary, and it cannot cross one or start during settling. Array order sets the drawing order, so later annotations draw above earlier ones. The first active frame is the first output frame at or after the resolved start, and removal begins on the first frame at or after the end.
222
222
 
223
- Targets are stationary, visible, and axis-aligned. Missing, ambiguous, hidden, rotated, reflected, grouped, masked, clipped, or moving targets fail with annotation context. Slidev excludes navigation, notes, and duplicate hidden slide instances and samples geometry each animation frame. Native shape support excludes groups and members, cropped pictures, paragraph animations, and hide or dim-after-animation effects, and supported entrances must have settled. PowerPoint schedules native geometry samples 50 ms apart. Movement above 0.5 output pixels invalidates the target. Sampling checks the documented stationary subset rather than tracking moving targets or recognizing pixels.
223
+ Targets are stationary, visible, and axis-aligned. Missing, ambiguous, hidden, rotated, reflected, masked, clipped, or moving targets fail with annotation context (including Slidev SVG `<g>` groups). Slidev excludes navigation, notes, and duplicate hidden slide instances and samples geometry each animation frame. Native PowerPoint shape support includes stationary unrotated groups, group members, and cropped pictures, while excluding hidden, rotated, flipped, 3D, paragraph-animated, moving or resized, exited, and hide- or dim-after-animation targets; supported animations must have settled. PowerPoint schedules native geometry samples 50 ms apart. Movement above 0.5 output pixels invalidates the target. Sampling checks the documented stationary subset rather than tracking moving targets or recognizing pixels.
224
224
 
225
225
  For a PowerPoint shape, use a target such as `{ type: shape, id: 2 }` when `slidevideo inspect --deck slides.pptx --json` or `slidevideo inspect --storyboard slidevideo.yaml --json` lists that ID on the selected slide without unsupported shape diagnostics.
226
226
 
@@ -35,12 +35,20 @@ namespace SlideVideo {
35
35
  private delegate bool EnumProc(IntPtr window, IntPtr parameter);
36
36
  [StructLayout(LayoutKind.Sequential)] private struct Rect { public int Left, Top, Right, Bottom; }
37
37
  [StructLayout(LayoutKind.Sequential)] private struct Point { public int X, Y; }
38
+ [StructLayout(LayoutKind.Sequential)] private struct MonitorInfo { public int cbSize; public Rect rcMonitor; public Rect rcWork; public uint dwFlags; }
38
39
  [DllImport("user32.dll")] private static extern bool ClientToScreen(IntPtr window, ref Point point);
39
40
  [DllImport("user32.dll")] private static extern bool EnumWindows(EnumProc callback, IntPtr parameter);
40
41
  [DllImport("user32.dll")] private static extern bool EnumChildWindows(IntPtr window, EnumProc callback, IntPtr parameter);
41
42
  [DllImport("user32.dll")] private static extern bool PrintWindow(IntPtr window, IntPtr dc, uint flags);
42
43
  [DllImport("user32.dll")] private static extern bool IsWindowVisible(IntPtr window);
43
44
  [DllImport("user32.dll")] private static extern bool GetClientRect(IntPtr window, out Rect rectangle);
45
+ [DllImport("user32.dll")] private static extern bool GetWindowRect(IntPtr window, out Rect rectangle);
46
+ [DllImport("user32.dll")] private static extern IntPtr MonitorFromWindow(IntPtr window, uint flags);
47
+ [DllImport("user32.dll")] private static extern bool GetMonitorInfo(IntPtr monitor, ref MonitorInfo info);
48
+ [DllImport("user32.dll", EntryPoint = "GetWindowLong")] private static extern int GetWindowLong32(IntPtr window, int index);
49
+ [DllImport("user32.dll", EntryPoint = "SetWindowLong")] private static extern int SetWindowLong32(IntPtr window, int index, int newLong);
50
+ [DllImport("user32.dll", EntryPoint = "GetWindowLongPtr")] private static extern IntPtr GetWindowLongPtr64(IntPtr window, int index);
51
+ [DllImport("user32.dll", EntryPoint = "SetWindowLongPtr")] private static extern IntPtr SetWindowLongPtr64(IntPtr window, int index, IntPtr newLong);
44
52
  [DllImport("user32.dll", CharSet = CharSet.Unicode)] private static extern int GetWindowText(IntPtr window, StringBuilder text, int length);
45
53
  [DllImport("user32.dll", CharSet = CharSet.Unicode)] private static extern int GetClassName(IntPtr window, StringBuilder text, int length);
46
54
  [DllImport("user32.dll")] private static extern uint GetWindowThreadProcessId(IntPtr window, out uint process);
@@ -99,6 +107,80 @@ namespace SlideVideo {
99
107
  return type.ToString() + " | " + title.ToString();
100
108
  }
101
109
 
110
+ private static long GetWindowStyle(IntPtr window) {
111
+ return IntPtr.Size == 8 ? GetWindowLongPtr64(window, -16).ToInt64() : (long)GetWindowLong32(window, -16);
112
+ }
113
+
114
+ private static void SetWindowStyle(IntPtr window, long style) {
115
+ if (IntPtr.Size == 8) SetWindowLongPtr64(window, -16, new IntPtr(style));
116
+ else SetWindowLong32(window, -16, unchecked((int)style));
117
+ }
118
+
119
+ public static string PlaceForAudience(long handle, int outputWidth, int outputHeight, double deckAspect, bool topmost, bool allowBorderless) {
120
+ var window = new IntPtr(handle);
121
+ var monitor = MonitorFromWindow(window, 2);
122
+ var info = new MonitorInfo();
123
+ info.cbSize = Marshal.SizeOf(typeof(MonitorInfo));
124
+ int workLeft = 0, workTop = 0, workWidth = 1600, workHeight = 900;
125
+ int monLeft = 0, monTop = 0, monWidth = 1600, monHeight = 900;
126
+ if (monitor != IntPtr.Zero && GetMonitorInfo(monitor, ref info)) {
127
+ workLeft = info.rcWork.Left;
128
+ workTop = info.rcWork.Top;
129
+ workWidth = Math.Max(320, info.rcWork.Right - info.rcWork.Left);
130
+ workHeight = Math.Max(180, info.rcWork.Bottom - info.rcWork.Top);
131
+ monLeft = info.rcMonitor.Left;
132
+ monTop = info.rcMonitor.Top;
133
+ monWidth = Math.Max(320, info.rcMonitor.Right - info.rcMonitor.Left);
134
+ monHeight = Math.Max(180, info.rcMonitor.Bottom - info.rcMonitor.Top);
135
+ }
136
+
137
+ double minScale = Math.Max(320.0 / deckAspect, 180.0);
138
+ double contentScale = Math.Max(minScale, Math.Min((double)outputWidth / deckAspect, (double)outputHeight));
139
+ int targetContentWidth = (int)Math.Round(deckAspect * contentScale, MidpointRounding.AwayFromZero);
140
+ int targetContentHeight = (int)Math.Round(contentScale, MidpointRounding.AwayFromZero);
141
+
142
+ int chromeWidth = 0, chromeHeight = 0;
143
+ Rect outerRect, clientRect;
144
+ if (GetWindowRect(window, out outerRect) && GetClientRect(window, out clientRect)) {
145
+ chromeWidth = Math.Max(0, (outerRect.Right - outerRect.Left) - clientRect.Right);
146
+ chromeHeight = Math.Max(0, (outerRect.Bottom - outerRect.Top) - clientRect.Bottom);
147
+ }
148
+
149
+ IntPtr insertAfter = topmost ? new IntPtr(-1) : new IntPtr(-2);
150
+ uint baseFlags = topmost ? 0x0040u : 0x0050u;
151
+
152
+ int desiredOuterWidth = targetContentWidth + chromeWidth;
153
+ int desiredOuterHeight = targetContentHeight + chromeHeight;
154
+ if (desiredOuterWidth <= workWidth && desiredOuterHeight <= workHeight) {
155
+ if (!SetWindowPos(window, insertAfter, workLeft, workTop, desiredOuterWidth, desiredOuterHeight, baseFlags)) throw new InvalidOperationException("Cannot position the audience window.");
156
+ if (topmost) SetForegroundWindow(window);
157
+ DwmFlush();
158
+ return "windowed";
159
+ }
160
+
161
+ if (allowBorderless) {
162
+ long style = GetWindowStyle(window);
163
+ SetWindowStyle(window, style & ~0x00CF0000L);
164
+ double monScale = Math.Min((double)monWidth / targetContentWidth, (double)monHeight / targetContentHeight);
165
+ int borderlessWidth = monScale >= 1.0 ? targetContentWidth : (int)Math.Round(targetContentWidth * monScale, MidpointRounding.AwayFromZero);
166
+ int borderlessHeight = monScale >= 1.0 ? targetContentHeight : (int)Math.Round(targetContentHeight * monScale, MidpointRounding.AwayFromZero);
167
+ if (!SetWindowPos(window, insertAfter, monLeft, monTop, borderlessWidth, borderlessHeight, baseFlags | 0x0020u)) throw new InvalidOperationException("Cannot position the borderless audience window.");
168
+ if (topmost) SetForegroundWindow(window);
169
+ DwmFlush();
170
+ return "borderless";
171
+ }
172
+
173
+ int availContentWidth = Math.Max(1, workWidth - chromeWidth);
174
+ int availContentHeight = Math.Max(1, workHeight - chromeHeight);
175
+ double fitScale = Math.Min((double)availContentWidth / targetContentWidth, (double)availContentHeight / targetContentHeight);
176
+ int fitOuterWidth = Math.Min(workWidth, (int)Math.Round(targetContentWidth * fitScale, MidpointRounding.AwayFromZero) + chromeWidth);
177
+ int fitOuterHeight = Math.Min(workHeight, (int)Math.Round(targetContentHeight * fitScale, MidpointRounding.AwayFromZero) + chromeHeight);
178
+ if (!SetWindowPos(window, insertAfter, workLeft, workTop, fitOuterWidth, fitOuterHeight, baseFlags)) throw new InvalidOperationException("Cannot position the fitted audience window.");
179
+ if (topmost) SetForegroundWindow(window);
180
+ DwmFlush();
181
+ return "windowed";
182
+ }
183
+
102
184
  public static void Place(long handle, int width, int height) {
103
185
  var window = new IntPtr(handle);
104
186
  if (!SetWindowPos(window, new IntPtr(-1), 0, 0, width, height, 0x40)) throw new InvalidOperationException("Cannot position the audience window.");
@@ -143,10 +225,12 @@ namespace SlideVideo {
143
225
  if (!PrintWindow(new IntPtr(handle), dc, 3)) throw new InvalidOperationException("PowerPoint did not render the live preview window.");
144
226
  } finally { graphics.ReleaseHdc(dc); }
145
227
  }
228
+ var content = OutputContent(rectangle, width, height);
146
229
  using (var output = new Bitmap(width, height)) {
147
230
  using (var graphics = Graphics.FromImage(output)) {
231
+ graphics.Clear(Color.Black);
148
232
  graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
149
- graphics.DrawImage(image, new Rectangle(0, 0, width, height), new Rectangle(rectangle.left, rectangle.top, rectangle.width, rectangle.height), GraphicsUnit.Pixel);
233
+ graphics.DrawImage(image, new Rectangle(content.x, content.y, content.width, content.height), new Rectangle(rectangle.left, rectangle.top, rectangle.width, rectangle.height), GraphicsUnit.Pixel);
150
234
  }
151
235
  using (var stream = new System.IO.MemoryStream()) {
152
236
  output.Save(stream, ImageFormat.Jpeg);
@@ -123,7 +123,7 @@ function Read-Package([string]$file) {
123
123
  }
124
124
  }
125
125
  }
126
- if ($entry.FullName -match '\.(gif|svg|glb|gltf)$' -or $entry.FullName -match '(^|/)(activeX|embeddings)/') {
126
+ if ($entry.FullName -match '\.(gif|glb|gltf)$' -or $entry.FullName -match '(^|/)(activeX|embeddings)/') {
127
127
  $unsupported.Add(@{ slide = ''; reason = ('Dynamic or externally controlled package content is unsupported: ' + $entry.FullName) })
128
128
  }
129
129
  }
@@ -138,14 +138,35 @@ function Read-Package([string]$file) {
138
138
  $relationshipId = $slideId.GetAttribute('id', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships')
139
139
  $part = Part-Name 'ppt/presentation.xml' $mapping[$relationshipId]
140
140
  $slideXml = Read-Part $zip $part
141
+ $entranceClickByShape = @{}
142
+ $animReasonsByShape = @{}
143
+ $mainSeq = $slideXml.SelectSingleNode('//*[local-name()="cTn"][@nodeType="mainSeq"]')
144
+ if ($null -ne $mainSeq) {
145
+ $seqClick = 0
146
+ foreach ($effectNode in $mainSeq.SelectNodes('.//*[local-name()="cTn"][@nodeType="clickEffect" or @nodeType="withEffect" or @nodeType="afterEffect"]')) {
147
+ if ($effectNode.GetAttribute('nodeType') -eq 'clickEffect') { $seqClick++ }
148
+ $presetClass = $effectNode.GetAttribute('presetClass')
149
+ $hasGeometryMotion = $null -ne $effectNode.SelectSingleNode('.//*[local-name()="animMotion" or local-name()="animScale" or local-name()="animRot" or local-name()="anim"]')
150
+ foreach ($spTarget in $effectNode.SelectNodes('.//*[local-name()="spTgt"][@spid]')) {
151
+ $spid = [int]$spTarget.GetAttribute('spid')
152
+ if ($presetClass -eq 'entr') {
153
+ $prev = $(if ($entranceClickByShape.ContainsKey($spid)) { [int]$entranceClickByShape[$spid] } else { 0 })
154
+ $entranceClickByShape[$spid] = [Math]::Max($prev, $seqClick)
155
+ }
156
+ if ($presetClass -eq 'path' -or ($presetClass -ne 'entr' -and $hasGeometryMotion)) {
157
+ if (!$animReasonsByShape.ContainsKey($spid)) { $animReasonsByShape[$spid] = [Collections.Generic.List[string]]::new() }
158
+ $animReasonsByShape[$spid].Add('moving or resized animated target')
159
+ }
160
+ }
161
+ }
162
+ }
141
163
  foreach ($identity in $slideXml.SelectNodes('//*[local-name()="cNvPr"]')) {
142
- $owner = $identity.ParentNode.ParentNode
164
+ $spid = [int]$identity.GetAttribute('id')
143
165
  $reasons = [Collections.Generic.List[string]]::new()
144
166
  if ($identity.GetAttribute('hidden') -in @('1', 'true')) { $reasons.Add('hidden shape') }
145
- if ($owner.LocalName -eq 'grpSp' -or $null -ne $owner.SelectSingleNode('ancestor::*[local-name()="grpSp"]')) { $reasons.Add('grouped shape') }
146
- $crop = $owner.SelectSingleNode('./*[local-name()="blipFill"]/*[local-name()="srcRect"]')
147
- if ($null -ne $crop -and @($crop.Attributes | Where-Object { $_.Value -ne '0' }).Count -gt 0) { $reasons.Add('cropped image') }
148
- $targets.Add(@{ native_id = $nativeId; id = [int]$identity.GetAttribute('id'); unsupported = @($reasons.ToArray()) })
167
+ if ($animReasonsByShape.ContainsKey($spid)) { foreach ($reason in $animReasonsByShape[$spid]) { $reasons.Add($reason) } }
168
+ $visibleClick = $(if ($entranceClickByShape.ContainsKey($spid)) { [int]$entranceClickByShape[$spid] } else { 0 })
169
+ $targets.Add(@{ native_id = $nativeId; id = $spid; unsupported = @($reasons.ToArray() | Select-Object -Unique); visible_from_click = $visibleClick })
149
170
  }
150
171
  $slideRelations = @{}
151
172
  $relationPart = ([IO.Path]::GetDirectoryName($part).Replace('\', '/') + '/_rels/' + [IO.Path]::GetFileName($part) + '.rels')
@@ -172,33 +193,28 @@ function Read-Package([string]$file) {
172
193
  $unsupported.Add(@{ slide = [string]$nativeId; reason = 'Video relationships do not identify one embedded source.' })
173
194
  }
174
195
  }
175
- $crop = $picture.SelectSingleNode('.//*[local-name()="srcRect"]')
176
196
  $transform = $picture.SelectSingleNode('./*[local-name()="spPr"]/*[local-name()="xfrm"]')
177
- if ($null -ne $crop -or ($null -ne $transform -and ($transform.HasAttribute('rot') -or $transform.HasAttribute('flipH') -or $transform.HasAttribute('flipV')))) {
178
- $unsupported.Add(@{ slide = [string]$nativeId; reason = ('Video cropping, rotation and flipping are unsupported: ' + $shape.GetAttribute('name')) })
197
+ if ($null -ne $transform -and ($transform.HasAttribute('rot') -or $transform.HasAttribute('flipH') -or $transform.HasAttribute('flipV'))) {
198
+ $unsupported.Add(@{ slide = [string]$nativeId; reason = ('Video rotation and flipping are unsupported: ' + $shape.GetAttribute('name')) })
179
199
  }
180
200
  $shapeId = [int]$shape.GetAttribute('id')
181
201
  $nativeVideo = $slideXml.SelectSingleNode(('//*[local-name()="video"][.//*[local-name()="spTgt"][@spid="' + $shapeId + '"]]'))
182
202
  $fullscreen = 0
183
203
  if ($null -ne $nativeVideo -and $nativeVideo.GetAttribute('fullScrn') -in @('1', 'true')) { $fullscreen = -1 }
184
204
  foreach ($property in $picture.SelectNodes('./*[local-name()="spPr"]/*')) {
185
- if ($property.LocalName -notin @('xfrm', 'prstGeom')) { $unsupported.Add(@{ slide = [string]$nativeId; reason = ('Video shape effects are unsupported: ' + $shape.GetAttribute('name')) }) }
205
+ if ($property.LocalName -notin @('xfrm', 'prstGeom', 'ln', 'effectLst', 'solidFill', 'gradFill', 'noFill')) { $unsupported.Add(@{ slide = [string]$nativeId; reason = ('Unsupported video shape transform or 3D effect: ' + $shape.GetAttribute('name')) }) }
186
206
  }
187
207
  $media.Add(@{ id = $shape.GetAttribute('name'); native_id = $nativeId; shape = $shapeId; sha256 = (Part-Hash $zip $source); part = $source; fullscreen = $fullscreen })
188
208
  }
189
209
  if ($null -ne $slideXml.SelectSingleNode('//*[local-name()="sndAc" or local-name()="snd" or local-name()="sndTgt" or local-name()="audio" or local-name()="oleObj" or local-name()="contentPart"]')) {
190
210
  $unsupported.Add(@{ slide = [string]$nativeId; reason = 'Native audio, animation or slide sounds, OLE and dynamic content are unsupported.' })
191
211
  }
192
- if ($null -ne $slideXml.SelectSingleNode('//*[local-name()="animMotion" or local-name()="animScale" or local-name()="animRot" or local-name()="animClr" or local-name()="anim" or local-name()="cmd"]')) {
193
- $unsupported.Add(@{ slide = [string]$nativeId; reason = 'Custom motion, scale, rotation, color and command animation behaviors are unsupported.' })
194
- }
195
- foreach ($effect in $slideXml.SelectNodes('//*[local-name()="animEffect"]')) {
196
- if ($effect.GetAttribute('filter') -ne 'fade' -or $effect.GetAttribute('transition') -ne 'in') { $unsupported.Add(@{ slide = [string]$nativeId; reason = 'Only native entrance Fade animation filters are supported.' }) }
212
+ if ($null -ne $slideXml.SelectSingleNode('//*[local-name()="cmd"]')) {
213
+ $unsupported.Add(@{ slide = [string]$nativeId; reason = 'Command animation behaviors are unsupported.' })
197
214
  }
198
215
  foreach ($node in $slideXml.SelectNodes('//*[local-name()="cTn"]')) {
199
216
  if ($node.HasAttribute('spd') -and $node.GetAttribute('spd') -ne '100000') { $unsupported.Add(@{ slide = [string]$nativeId; reason = 'Native animation or media speed transforms are unsupported.' }) }
200
- if ($node.HasAttribute('autoRev') -and $node.GetAttribute('autoRev') -ne '0') { $unsupported.Add(@{ slide = [string]$nativeId; reason = 'Native auto-reverse is unsupported.' }) }
201
- if ($node.HasAttribute('repeatCount') -or $node.HasAttribute('repeatDur')) { $unsupported.Add(@{ slide = [string]$nativeId; reason = 'Explicit native repeats are unsupported.' }) }
217
+ if (($node.HasAttribute('repeatCount') -and $node.GetAttribute('repeatCount') -eq 'indefinite') -or ($node.HasAttribute('repeatDur') -and $node.GetAttribute('repeatDur') -eq 'indefinite')) { $unsupported.Add(@{ slide = [string]$nativeId; reason = 'Unbounded native animation repeats are unsupported.' }) }
202
218
  }
203
219
  }
204
220
  return @{ media = @($media.ToArray()); unsupported = @($unsupported.ToArray()); targets = @($targets.ToArray()) }
@@ -216,32 +232,68 @@ function Open-PrivateDeck([bool]$visible) {
216
232
  $script:presentation = $app.Presentations.Open($privateDeck, 0, 0, $(if ($visible) { -1 } else { 0 }))
217
233
  Write-Json 'ownership.json' @{ helper_pid = $PID; helper_started_ticks = ([Diagnostics.Process]::GetCurrentProcess().StartTime.ToUniversalTime().Ticks.ToString()); powerpoint_pid = $processId; powerpoint_started_ticks = $process.StartTime.ToUniversalTime().Ticks.ToString(); application_created = $createdApplication; presentation = $privateDeck }
218
234
  }
219
- function Inspect-Shapes($slide, $shapes, $package, [bool]$grouped) {
235
+ function Find-ShapeById($shapes, [int]$targetId, [bool]$ancestorInvalid = $false) {
236
+ $found = [Collections.Generic.List[object]]::new()
237
+ foreach ($shape in $shapes) {
238
+ $invalid = $ancestorInvalid -or ([int]$shape.Visible -ne -1) -or ([Math]::Abs([double]$shape.Rotation % 360) -gt 0.001) -or ([int]$shape.ThreeD.Visible -ne 0) -or ([int]$shape.HorizontalFlip -ne 0) -or ([int]$shape.VerticalFlip -ne 0)
239
+ if ([int]$shape.Id -eq $targetId) { $found.Add(@{ shape = $shape; invalid = $invalid }) }
240
+ if ([int]$shape.Type -eq 6) {
241
+ foreach ($child in (Find-ShapeById $shape.GroupItems $targetId $invalid)) { $found.Add($child) }
242
+ }
243
+ }
244
+ return @($found.ToArray())
245
+ }
246
+ function Inspect-Shapes($slide, $shapes, $package, [bool]$ancestorTransformed, [int]$ancestorVisibleFromClick = 0, [string[]]$ancestorAnimReasons = @()) {
220
247
  foreach ($shape in $shapes) {
221
248
  Check-Cancel
222
249
  $reasons = [Collections.Generic.List[string]]::new()
250
+ $animReasons = [Collections.Generic.List[string]]::new()
223
251
  $bounds = @{ x = 0.0; y = 0.0; width = 0.0; height = 0.0 }
224
- $visibleFromClick = 0
252
+ $visibleFromClick = $ancestorVisibleFromClick
253
+ $isTransformed = $ancestorTransformed
254
+ foreach ($inherited in $ancestorAnimReasons) {
255
+ $reasons.Add($inherited)
256
+ $animReasons.Add($inherited)
257
+ }
225
258
  try {
226
259
  $metadata = @($package.targets | Where-Object { $_.native_id -eq $slide.SlideID -and $_.id -eq $shape.Id })
227
260
  if ($metadata.Count -ne 1) { $reasons.Add('shape identity is absent or ambiguous in the original slide package') }
228
- else { foreach ($reason in $metadata[0].unsupported) { $reasons.Add($reason) } }
229
- if ($grouped -or [int]$shape.Type -eq 6) { $reasons.Add('grouped shape') }
230
- if ([int]$shape.Visible -ne -1) { $reasons.Add('hidden shape') }
231
- if ([Math]::Abs([double]$shape.Rotation % 360) -gt 0.001 -or [int]$shape.ThreeD.Visible -ne 0) { $reasons.Add('rotated or three-dimensional shape') }
232
- if ([int]$shape.HorizontalFlip -ne 0 -or [int]$shape.VerticalFlip -ne 0) { $reasons.Add('flipped shape') }
261
+ else {
262
+ foreach ($reason in $metadata[0].unsupported) {
263
+ $reasons.Add($reason)
264
+ if ($reason -ne 'hidden shape') { $animReasons.Add($reason) }
265
+ }
266
+ $visibleFromClick = [Math]::Max($visibleFromClick, [int]$metadata[0].visible_from_click)
267
+ }
268
+ if ($ancestorTransformed) { $reasons.Add('ancestor group is hidden, rotated, flipped or three-dimensional') }
269
+ if ([int]$shape.Visible -ne -1) { $reasons.Add('hidden shape'); $isTransformed = $true }
270
+ if ([Math]::Abs([double]$shape.Rotation % 360) -gt 0.001 -or [int]$shape.ThreeD.Visible -ne 0) { $reasons.Add('rotated or three-dimensional shape'); $isTransformed = $true }
271
+ if ([int]$shape.HorizontalFlip -ne 0 -or [int]$shape.VerticalFlip -ne 0) { $reasons.Add('flipped shape'); $isTransformed = $true }
233
272
  $bounds = @{ x = [double]$shape.Left / $presentation.PageSetup.SlideWidth; y = [double]$shape.Top / $presentation.PageSetup.SlideHeight; width = [double]$shape.Width / $presentation.PageSetup.SlideWidth; height = [double]$shape.Height / $presentation.PageSetup.SlideHeight }
234
273
  if ($bounds.width -le 0 -or $bounds.height -le 0 -or $bounds.x -lt 0 -or $bounds.y -lt 0 -or $bounds.x + $bounds.width -gt 1.000001 -or $bounds.y + $bounds.height -gt 1.000001) { $reasons.Add('degenerate shape or shape clipped by slide bounds') }
235
- $click = 0
236
274
  foreach ($effect in $slide.TimeLine.MainSequence) {
237
- if ([int]$effect.Timing.TriggerType -eq 1) { $click++ }
238
275
  if ([int]$effect.Shape.Id -ne [int]$shape.Id) { continue }
239
- if ([int]$effect.EffectType -notin @(1, 10) -or [int]$effect.Exit -ne 0 -or [int]$effect.Timing.TriggerType -notin @(1, 2, 3) -or $click -eq 0 -or [int]$effect.Paragraph -gt 0 -or [int]$effect.EffectInformation.AfterEffect -ne 0) { $reasons.Add('moving, partial-text, hidden-after-animation or unsupported animated target') }
240
- $visibleFromClick = [Math]::Max($visibleFromClick, $click)
276
+ if ([int]$effect.Exit -ne 0 -or [int]$effect.Timing.TriggerType -notin @(1, 2, 3) -or [int]$effect.Paragraph -gt 0 -or [int]$effect.EffectInformation.AfterEffect -ne 0 -or [double]$effect.Timing.RepeatCount -lt 0 -or [double]$effect.Timing.RepeatCount -gt 100 -or [double]$effect.Timing.RepeatDuration -lt 0) {
277
+ $reason = 'exited, partial-text, hidden-after-animation or unbounded animated target'
278
+ $reasons.Add($reason)
279
+ $animReasons.Add($reason)
280
+ }
241
281
  }
242
282
  } catch { $reasons.Add('native target geometry is unavailable: ' + $_.Exception.Message) }
283
+ $children = @()
284
+ if ([int]$shape.Type -eq 6) {
285
+ $children = @(Inspect-Shapes $slide $shape.GroupItems $package $isTransformed $visibleFromClick @($animReasons.ToArray() | Select-Object -Unique))
286
+ foreach ($child in $children) {
287
+ $visibleFromClick = [Math]::Max($visibleFromClick, [int]$child.visible_from_click)
288
+ foreach ($childReason in $child.unsupported) {
289
+ if ($childReason -in @('moving or resized animated target', 'exited, partial-text, hidden-after-animation or unbounded animated target')) {
290
+ $reasons.Add($childReason)
291
+ }
292
+ }
293
+ }
294
+ }
243
295
  @{ id = [int]$shape.Id; name = [string]$shape.Name; bounds = $bounds; unsupported = @($reasons.ToArray() | Select-Object -Unique); visible_from_click = $visibleFromClick }
244
- if ([int]$shape.Type -eq 6) { Inspect-Shapes $slide $shape.GroupItems $package $true }
296
+ foreach ($child in $children) { $child }
245
297
  }
246
298
  }
247
299
  function Inspect-Native($package) {
@@ -254,7 +306,9 @@ function Inspect-Native($package) {
254
306
  $effects.Add(@{ type = [int]$effect.EffectType; trigger = [int]$timing.TriggerType; duration_ms = [double]$timing.Duration * 1000; delay_ms = [double]$timing.TriggerDelayTime * 1000; repeat_count = [double]$timing.RepeatCount; repeat_duration_ms = [double]$timing.RepeatDuration * 1000; auto_reverse = [int]$timing.AutoReverse; exit = [int]$effect.Exit; shape = [int]$effect.Shape.Id; paragraph = [int]$effect.Paragraph })
255
307
  }
256
308
  $shapes = @(Inspect-Shapes $slide $slide.Shapes $package $false)
257
- $slides.Add(@{ id = [string]$slide.Name; native_id = [int]$slide.SlideID; index = [int]$slide.SlideIndex; effects = @($effects.ToArray()); shapes = $shapes; transition = [int]$slide.SlideShowTransition.EntryEffect; auto_advance = [int]$slide.SlideShowTransition.AdvanceOnTime; hidden = [int]$slide.SlideShowTransition.Hidden; interactive = [int]$slide.TimeLine.InteractiveSequences.Count })
309
+ $transitionEffect = [int]$slide.SlideShowTransition.EntryEffect
310
+ $transitionDurationMs = $(if ($transitionEffect -ne 0) { [Math]::Round([double]$slide.SlideShowTransition.Duration * 1000) } else { 0 })
311
+ $slides.Add(@{ id = [string]$slide.Name; native_id = [int]$slide.SlideID; index = [int]$slide.SlideIndex; effects = @($effects.ToArray()); shapes = $shapes; transition = $transitionEffect; transition_duration_ms = $transitionDurationMs; auto_advance = [int]$slide.SlideShowTransition.AdvanceOnTime; hidden = [int]$slide.SlideShowTransition.Hidden; interactive = [int]$slide.TimeLine.InteractiveSequences.Count })
258
312
  foreach ($shape in $slide.Shapes) {
259
313
  if ([int]$shape.Type -eq 16) {
260
314
  if ([int]$shape.MediaType -ne 3) { $package.unsupported += @{ slide = [string]$slide.Name; reason = ('Only native video media shapes are supported: ' + $shape.Name) }; continue }
@@ -282,9 +336,16 @@ function Dependencies {
282
336
  return @{ powerpoint = [string]$app.Version; office_build = $office; windows = [Environment]::OSVersion.VersionString; powershell = $PSVersionTable.PSVersion.ToString(); ffmpeg = $script:ffmpegVersion }
283
337
  }
284
338
  function Slide-ById([int]$nativeId) { return $presentation.Slides.FindBySlideID($nativeId) }
285
- function Select-Slide([int]$nativeId) {
339
+ function Select-Slide([int]$nativeId, [bool]$cut = $false) {
286
340
  $slide = Slide-ById $nativeId
287
- $show.View.GotoSlide([int]$slide.SlideIndex, -1)
341
+ if ($cut) {
342
+ $saved = [int]$slide.SlideShowTransition.EntryEffect
343
+ $slide.SlideShowTransition.EntryEffect = 0
344
+ try { $show.View.GotoSlide([int]$slide.SlideIndex, -1) }
345
+ finally { $slide.SlideShowTransition.EntryEffect = $saved }
346
+ } else {
347
+ $show.View.GotoSlide([int]$slide.SlideIndex, -1)
348
+ }
288
349
  if ([int]$show.View.Slide.SlideID -ne $nativeId -or [int]$show.View.GetClickIndex() -ne 0) { Fail 'POWERPOINT_NAVIGATION' ('Native slide did not reset: ' + $nativeId) }
289
350
  }
290
351
  function Apply-Operation($operation) {
@@ -297,7 +358,7 @@ function Apply-Operation($operation) {
297
358
  if ([int]$show.View.Slide.SlideID -ne $operation.native_id) { Fail 'POWERPOINT_MEDIA' ('Wrong native slide for media ' + $operation.id) }
298
359
  $player = $show.View.Player([int]$operation.shape)
299
360
  $player.Stop()
300
- $player.CurrentPosition = 0
361
+ $player.CurrentPosition = [int][Math]::Round([double]$operation.trim_start_ms)
301
362
  $player.Play()
302
363
  return $player
303
364
  } else { Fail 'POWERPOINT_PROTOCOL' ('Unknown operation ' + $operation.type) }
@@ -342,10 +403,10 @@ function Measure-Annotation($request, [bool]$allowPaused = $false) {
342
403
  if ($request.target.type -eq 'region') {
343
404
  $bounds = @{ x = [double]$request.target.x; y = [double]$request.target.y; width = [double]$request.target.width; height = [double]$request.target.height }
344
405
  } else {
345
- $matches = @($show.View.Slide.Shapes | Where-Object { $_.Id -eq $request.target.id })
406
+ $matches = @(Find-ShapeById $show.View.Slide.Shapes ([int]$request.target.id))
346
407
  if ($matches.Count -ne 1) { Fail 'ANNOTATION_TARGET' ($context + ', shape ' + $request.target.id + ': actual shape is missing or ambiguous.') }
347
- $shape = $matches[0]
348
- if ([int]$shape.Visible -ne -1 -or [int]$shape.Type -eq 6 -or [Math]::Abs([double]$shape.Rotation % 360) -gt 0.001 -or [int]$shape.ThreeD.Visible -ne 0 -or [int]$shape.HorizontalFlip -ne 0 -or [int]$shape.VerticalFlip -ne 0) { Fail 'ANNOTATION_TARGET' ($context + ', shape ' + $request.target.id + ': actual target is hidden, grouped or transformed.') }
408
+ $shape = $matches[0].shape
409
+ if ($matches[0].invalid) { Fail 'ANNOTATION_TARGET' ($context + ', shape ' + $request.target.id + ': actual target is hidden or transformed.') }
349
410
  $bounds = @{ x = [double]$shape.Left / $presentation.PageSetup.SlideWidth; y = [double]$shape.Top / $presentation.PageSetup.SlideHeight; width = [double]$shape.Width / $presentation.PageSetup.SlideWidth; height = [double]$shape.Height / $presentation.PageSetup.SlideHeight }
350
411
  }
351
412
  foreach ($value in $bounds.Values) { if ([double]::IsNaN($value) -or [double]::IsInfinity($value)) { Fail 'ANNOTATION_GEOMETRY' ($context + ': nonfinite bounds.') } }
@@ -392,11 +453,19 @@ function Check-Media {
392
453
  $position = [double]$monitor.player.CurrentPosition
393
454
  $state = [int]$monitor.player.State
394
455
  if ($position -gt $monitor.last_position + 1) { $monitor.last_position = $position; $monitor.advanced_at = $now }
395
- $expected = $now - $monitor.operation.at_ms
396
- if ($state -in @($ppPaused, $ppStopped) -and $expected -ge $monitor.operation.source_duration_ms - 200 -and $monitor.last_position -ge $monitor.operation.source_duration_ms - 200) {
456
+ $trimStart = [double]$monitor.operation.trim_start_ms
457
+ $trimEnd = [double]$monitor.operation.trim_end_ms
458
+ $elapsed = $now - $monitor.operation.at_ms
459
+ $expected = $trimStart + $elapsed
460
+ $isTrimmedEnd = $trimEnd -lt ([double]$monitor.operation.source_duration_ms - 50)
461
+ if ($isTrimmedEnd -and ($now -ge $monitor.operation.end_ms -or ($position -gt $trimStart + 1 -and $position -ge $trimEnd - 30))) {
462
+ $monitor.player.Pause()
463
+ $events.Add(@{ id = ($monitor.operation.id + ':ended'); type = 'media-ended'; scheduled_ms = $monitor.operation.end_ms; observed_ms = $now; media_ms = $position })
464
+ [void]$activeMedia.Remove($monitor)
465
+ } elseif ($state -in @($ppPaused, $ppStopped) -and $expected -ge $trimEnd - 200 -and $monitor.last_position -ge $trimEnd - 200) {
397
466
  $events.Add(@{ id = ($monitor.operation.id + ':ended'); type = 'media-ended'; scheduled_ms = $monitor.operation.end_ms; observed_ms = $now; media_ms = $monitor.last_position })
398
467
  [void]$activeMedia.Remove($monitor)
399
- } elseif ($now -gt $monitor.operation.end_ms + 250 -or ($expected -gt 300 -and [Math]::Abs($position - $expected) -gt 200) -or ($now - $monitor.advanced_at -gt 250) -or ($expected -gt 150 -and $state -ne $ppPlaying)) {
468
+ } elseif ($now -gt $monitor.operation.end_ms + 250 -or ($elapsed -gt 300 -and [Math]::Abs($position - $expected) -gt 200) -or ($now - $monitor.advanced_at -gt 250) -or ($elapsed -gt 150 -and $state -ne $ppPlaying)) {
400
469
  Fail 'POWERPOINT_MEDIA_STALL' ('Native media stalled: ' + $monitor.operation.id + ', expected ' + [int]$expected + ' ms, observed ' + $position + ' ms, state ' + $state)
401
470
  }
402
471
  }
@@ -404,7 +473,7 @@ function Check-Media {
404
473
  function Wait-MediaCompletion {
405
474
  Check-Media
406
475
  foreach ($monitor in @($activeMedia.ToArray())) {
407
- if ($monitor.last_position -lt $monitor.operation.source_duration_ms - 200) {
476
+ if ($monitor.last_position -lt [double]$monitor.operation.trim_end_ms - 200) {
408
477
  Fail 'POWERPOINT_MEDIA_STALL' ('Native media is not within completion tolerance at the action boundary: ' + $monitor.operation.id)
409
478
  }
410
479
  }
@@ -461,27 +530,32 @@ function Save-Reference([string]$label) {
461
530
  return $file
462
531
  }
463
532
  function Rehearse {
464
- Select-Slide $job.operations[0].native_id
465
- Wait-Until ($clock.Elapsed.TotalMilliseconds + 300)
533
+ Select-Slide $job.operations[0].native_id $true
534
+ Wait-Until ($clock.Elapsed.TotalMilliseconds + [Math]::Max(300, [double]$job.operations[0].settle_ms + 200))
466
535
  $number = 0
467
536
  foreach ($operation in $job.operations) {
468
537
  Check-Cancel
469
538
  $number++
539
+ if ($number -eq 1 -and $operation.type -eq 'slide' -and $operation.at_ms -eq 0) { continue }
470
540
  $before = Save-Reference ('reference-' + $number + '-before')
471
541
  $exclude = @($job.media | Where-Object { $_.native_id -eq [int]$show.View.Slide.SlideID } | ForEach-Object { @{ left = $_.left; top = $_.top; right = $_.right; bottom = $_.bottom } })
472
542
  $player = Apply-Operation $operation
473
543
  if ($operation.type -eq 'play') {
474
544
  $player.Pause()
475
- $samples = @(500, 1500 | Where-Object { $_ -lt $operation.source_duration_ms })
476
- if ($samples.Count -eq 0) { $samples = @($operation.source_duration_ms / 2) }
477
- foreach ($sample in $samples) {
478
- $player.CurrentPosition = [int]$sample
545
+ $trimStart = [double]$operation.trim_start_ms
546
+ $trimEnd = [double]$operation.trim_end_ms
547
+ $clipDuration = $trimEnd - $trimStart
548
+ $offsets = @(500, 1500 | Where-Object { $_ -lt $clipDuration })
549
+ if ($offsets.Count -eq 0) { $offsets = @($clipDuration / 2) }
550
+ foreach ($offset in $offsets) {
551
+ $samplePos = [int][Math]::Round($trimStart + $offset)
552
+ $player.CurrentPosition = $samplePos
479
553
  Wait-Until ($clock.Elapsed.TotalMilliseconds + 250)
480
- if ([Math]::Abs([double]$player.CurrentPosition - $sample) -gt $operation.frame_period_ms) { Fail 'POWERPOINT_REFERENCE' ('Native video seek is unbounded: ' + $operation.id) }
481
- $after = Save-Reference ('reference-' + $number + '-sample-' + $sample)
482
- $references.Add(@{ id = ($operation.id.Replace(':', '-') + '-' + $sample); expected_ms = $operation.at_ms + $sample; before = $before; after = $after; mode = 'sample'; frame_period_ms = $operation.frame_period_ms })
554
+ if ([Math]::Abs([double]$player.CurrentPosition - $samplePos) -gt $operation.frame_period_ms) { Fail 'POWERPOINT_REFERENCE' ('Native video seek is unbounded: ' + $operation.id) }
555
+ $after = Save-Reference ('reference-' + $number + '-sample-' + [int]$offset)
556
+ $references.Add(@{ id = ($operation.id.Replace(':', '-') + '-' + [int]$offset); expected_ms = $operation.at_ms + $offset; before = $before; after = $after; mode = 'sample'; frame_period_ms = $operation.frame_period_ms })
483
557
  }
484
- $player.CurrentPosition = [int][Math]::Max(0, $operation.source_duration_ms - $operation.frame_period_ms)
558
+ $player.CurrentPosition = [int][Math]::Max($trimStart, $trimEnd - $operation.frame_period_ms)
485
559
  Wait-Until ($clock.Elapsed.TotalMilliseconds + 200)
486
560
  $player.Pause()
487
561
  } elseif ($operation.at_ms -gt 0) {
@@ -564,11 +638,9 @@ try {
564
638
  $initialViewState = [int]$show.View.State
565
639
  $show.View.State = 1
566
640
  $show.View.AcceleratorsEnabled = 0
567
- $captureWidth = [Math]::Min([int]$job.output.width, 1600)
568
- $captureHeight = [int][Math]::Round($captureWidth / $deckAspect)
569
- [SlideVideo.Native]::Place($window, $captureWidth, $captureHeight)
641
+ $windowMode = [SlideVideo.Native]::PlaceForAudience($window, [int]$job.output.width, [int]$job.output.height, $deckAspect, $true, $true)
570
642
  $show.View.GotoSlide([int]$markerSlides['#ff00ff'], -1)
571
- Write-Json 'window.json' @{ hwnd = $window.ToString(); editor_hwnd = $editorWindow.ToString(); description = [SlideVideo.Native]::Describe($window); initial_state = $initialViewState; state = [int]$show.View.State; slide_id = [int]$show.View.Slide.SlideID; marker_slide_id = [int]$presentation.Slides.Item([int]$markerSlides['#ff00ff']).SlideID; marker_rgb = [int]$show.View.Slide.Background.Fill.ForeColor.RGB; follows_master = [int]$show.View.Slide.FollowMasterBackground }
643
+ Write-Json 'window.json' @{ hwnd = $window.ToString(); editor_hwnd = $editorWindow.ToString(); description = [SlideVideo.Native]::Describe($window); mode = $windowMode; initial_state = $initialViewState; state = [int]$show.View.State; slide_id = [int]$show.View.Slide.SlideID; marker_slide_id = [int]$presentation.Slides.Item([int]$markerSlides['#ff00ff']).SlideID; marker_rgb = [int]$show.View.Slide.Background.Fill.ForeColor.RGB; follows_master = [int]$show.View.Slide.FollowMasterBackground }
572
644
  $geometry = $null
573
645
  $deadline = $clock.Elapsed.TotalMilliseconds + 5000
574
646
  do {
@@ -587,14 +659,15 @@ try {
587
659
  $outputContent = [SlideVideo.Native]::OutputContent($geometry, [int]$job.output.width, [int]$job.output.height)
588
660
  if ($job.geometry_requests.Count -gt 0) { $scaleFilter = ('scale=' + $outputContent.width + ':' + $outputContent.height + ':flags=bicubic,format=rgb24,pad=' + $job.output.width + ':' + $job.output.height + ':' + $outputContent.x + ':' + $outputContent.y + ',setsar=1') }
589
661
  $captureFilter = ('crop=' + $geometry.width + ':' + $geometry.height + ':' + $geometry.left + ':' + $geometry.top + ':exact=1,' + $scaleFilter)
590
- Write-Json 'geometry.json' @{ version = 1; hwnd = $window.ToString(); rectangle = $geometry; deck_aspect = $deckAspect; requested = $job.output; filter = $captureFilter }
662
+ Write-Json 'geometry.json' @{ version = 1; hwnd = $window.ToString(); mode = $windowMode; rectangle = $geometry; output_content = $outputContent; scale_x = [double]$outputContent.width / $geometry.width; scale_y = [double]$outputContent.height / $geometry.height; deck_aspect = $deckAspect; requested = $job.output; filter = $captureFilter }
591
663
  if ($job.verify_timing) { Rehearse }
592
664
  $firstOperation = $job.operations[0]
593
665
  if ($firstOperation.type -ne 'slide' -or $firstOperation.at_ms -ne 0) { Fail 'POWERPOINT_PROTOCOL' 'The native schedule must initialize a slide at time zero.' }
594
- Select-Slide $firstOperation.native_id
666
+ Select-Slide $firstOperation.native_id $true
667
+ $firstOnsetMatchesYellow = [SlideVideo.Native]::ColorPresent($window, $geometry, '#ffff00')
595
668
  Wait-Until ($clock.Elapsed.TotalMilliseconds + 200)
596
669
  $firstReadback = [SlideVideo.Native]::Readback($window, $geometry)
597
- $deadline = $clock.Elapsed.TotalMilliseconds + 5000
670
+ $deadline = $clock.Elapsed.TotalMilliseconds + [Math]::Max(5000, [double]$firstOperation.settle_ms + 3000)
598
671
  do {
599
672
  Wait-Until ($clock.Elapsed.TotalMilliseconds + 30)
600
673
  $nextReadback = [SlideVideo.Native]::Readback($window, $geometry)
@@ -642,17 +715,20 @@ try {
642
715
  Show-Marker '#ff00ff'
643
716
  if ($job.verify_timing) { Show-Marker '#00ffff' }
644
717
  Show-Marker '#ffff00'
718
+ $markerReadback = $(if ([double]$firstOperation.settle_ms -gt 0) { [SlideVideo.Native]::Readback($window, $geometry) } else { '' })
645
719
  $initialLower = $clock.Elapsed.TotalMilliseconds
646
- Select-Slide $firstOperation.native_id
647
- $deadline = $clock.Elapsed.TotalMilliseconds + 5000
720
+ Select-Slide $firstOperation.native_id $true
721
+ $deadline = $clock.Elapsed.TotalMilliseconds + [Math]::Max(5000, [double]$firstOperation.settle_ms + 3000)
648
722
  do {
649
723
  Check-Cancel
650
- $ready = [SlideVideo.Native]::Readback($window, $geometry) -eq $firstReadback
724
+ $currentReadback = [SlideVideo.Native]::Readback($window, $geometry)
725
+ $ready = $(if ([double]$firstOperation.settle_ms -gt 0) { $firstOnsetMatchesYellow -or ($currentReadback -ne $markerReadback) } else { $currentReadback -eq $firstReadback })
651
726
  if (!$ready) { Start-Sleep -Milliseconds 1 }
652
727
  } while (!$ready -and $clock.Elapsed.TotalMilliseconds -lt $deadline)
653
- if (!$ready) { Fail 'POWERPOINT_READINESS' 'The actual audience pixels did not return to the initialized first-slide state.' }
728
+ if (!$ready) { Fail 'POWERPOINT_READINESS' 'The actual audience pixels did not transition to the initialized first-slide state.' }
654
729
  $script:origin = $clock.Elapsed.TotalMilliseconds
655
- Write-Json 'startup.json' @{ version = 1; native_id = $firstOperation.native_id; readback_sha256 = $firstReadback; navigation_started_ms = $initialLower - $origin; initialized_by_ms = 0; method = 'native target state and matching physical audience readback' }
730
+ $startupMethod = $(if ([double]$firstOperation.settle_ms -gt 0) { 'native target state and first-slide entry onset readback' } else { 'native target state and matching physical audience readback' })
731
+ Write-Json 'startup.json' @{ version = 1; native_id = $firstOperation.native_id; readback_sha256 = $firstReadback; navigation_started_ms = $initialLower - $origin; initialized_by_ms = 0; method = $startupMethod }
656
732
  foreach ($marker in $markers) { $marker.observed_ms -= $origin; $marker.rendered_by_ms -= $origin }
657
733
  $script:activeVisit = [string]$firstOperation.id
658
734
  $script:activeScene = [string]$firstOperation.scene
@@ -15,9 +15,7 @@ function Run-Preview {
15
15
  } while ($window -eq 0 -and $clock.Elapsed.TotalMilliseconds -lt $deadline)
16
16
  if ($window -eq 0) { Fail 'POWERPOINT_WINDOW' 'Cannot identify the slideshow owned by the private preview deck.' }
17
17
  $show.View.AcceleratorsEnabled = 0
18
- $previewWidth = [Math]::Min([int]$job.output.width, 1600)
19
- $previewHeight = [int][Math]::Round($previewWidth / $deckAspect)
20
- [SlideVideo.Native]::PlacePreview($window, $previewWidth, $previewHeight)
18
+ [void][SlideVideo.Native]::PlaceForAudience($window, [int]$job.output.width, [int]$job.output.height, $deckAspect, $false, $false)
21
19
  $first = $job.operations[0]
22
20
  if ($first.type -ne 'slide' -or $first.at_ms -ne 0) { Fail 'POWERPOINT_PROTOCOL' 'The preview schedule must initialize a slide at time zero.' }
23
21
  Apply-Operation $first
@@ -28,6 +26,9 @@ function Run-Preview {
28
26
  try { $script:geometry = [SlideVideo.Native]::PreviewContent($window, $deckAspect) }
29
27
  catch { if ($clock.Elapsed.TotalMilliseconds -gt $deadline) { Fail 'POWERPOINT_GEOMETRY' $_.Exception.Message }; Start-Sleep -Milliseconds 20 }
30
28
  } while ($null -eq $geometry)
29
+ $previewViewportWidth = [int]$job.output.width
30
+ $previewViewportHeight = [int]$job.output.height
31
+ $previewContent = [SlideVideo.Native]::OutputContent($geometry, $previewViewportWidth, $previewViewportHeight)
31
32
  $previewClock = [Diagnostics.Stopwatch]::new()
32
33
  $status = 'paused'
33
34
  $nextOperation = 1
@@ -92,8 +93,8 @@ function Run-Preview {
92
93
  }
93
94
  }
94
95
  )
95
- $state = @{ position_ms = $position; status = $status; duration_ms = $job.duration_ms; targets = @($targets); viewport = @{ width = $previewWidth; height = $previewHeight }; content = @{ x = 0; y = 0; width = $previewWidth; height = $previewHeight } }
96
- if ($action -eq 'frame') { $state.image = [SlideVideo.Native]::PreviewJpeg($window, $geometry, $previewWidth, $previewHeight) }
96
+ $state = @{ position_ms = $position; status = $status; duration_ms = $job.duration_ms; targets = @($targets); viewport = @{ width = $previewViewportWidth; height = $previewViewportHeight }; content = @{ x = $previewContent.x; y = $previewContent.y; width = $previewContent.width; height = $previewContent.height } }
97
+ if ($action -eq 'frame') { $state.image = [SlideVideo.Native]::PreviewJpeg($window, $geometry, $previewViewportWidth, $previewViewportHeight) }
97
98
  [Console]::WriteLine('SLIDEVIDEO_PREVIEW ' + (ConvertTo-Json -InputObject @{ id = $command.id; state = $state } -Depth 30 -Compress))
98
99
  [Console]::Out.Flush()
99
100
  }