Spaces:
Runtime error

File size: 3,477 Bytes
65d68f5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/**
 * Day 19 Step 7 β€” a curated 2-4 minute confirmation sample: opening, a
 * concept explanation beat, a copy-this notebook card, a formula reveal, a
 * worked-example reveal, a common-mistakes card, a Q/A exam-answer reveal,
 * and a practice-sample reveal. Rendered from real scenes in the current
 * full-chapter plan (not a synthetic timeline), so this is exactly what a
 * viewer would see in the corresponding part of the full render.
 *
 * This must be reviewed and approved before ever rendering the full ~41
 * minute chapter β€” per the Day 19 constraint, no full MP4 render happens in
 * this phase regardless of how clean the stills/checker look.
 *
 * Usage:
 *   npm run video:day19-sample
 */

import { mkdirSync, writeFileSync } from "node:fs";
import { buildFullChapterTeachingPlan } from "../../src/video/tuition/fullChapterPlan";
import { buildTimeline, type TimelineScene, type TuitionVideoTimeline } from "../../src/video/tuition/renderLessonVideoPlan";

const OUT_DIR = "outputs/video/tuition/sound-waves/scene-review/sample";

// Scene ids picked from the current scene-index.json β€” one representative
// scene per teaching pattern the Day 19 spec asked to confirm.
const SAMPLE_SCENE_IDS = [
  "opening-4", // opening hook, not an objective dump
  "opening-10", // today's goals (split, not a 9-line dump)
  "concept-34", // a concept explanation beat with category label
  "concept-48", // "copy this" notebook card
  "formula-238", // formula reveal
  "worked_example-328", // worked-example reveal
  "common_mistakes-612", // common-mistakes card
  "board_answer-650", // Q/A exam-answer reveal (question -> board-style answer)
  "practice_sample-709", // sample-practice reveal ("Your turn")
];

// `buildFullChapterTeachingPlan` assigns scene ids from a shared
// module-level counter, so calling it more than once per process produces a
// second plan whose ids don't match the first β€” build it exactly once and
// reuse it for both the full timeline lookup and the `plan` prop below.
function buildSampleTimeline(full: TuitionVideoTimeline): TuitionVideoTimeline {
  const byId = new Map(full.scenes.map((s) => [s.scene.id, s]));

  let frameCursor = 0;
  let secondsCursor = 0;
  const scenes: TimelineScene[] = [];

  for (const id of SAMPLE_SCENE_IDS) {
    const chosen = byId.get(id);
    if (!chosen) {
      throw new Error(`Day19 sample: scene id "${id}" not found in the current plan's timeline`);
    }
    scenes.push({
      ...chosen,
      fromFrame: frameCursor,
      fromSeconds: secondsCursor,
    });
    frameCursor += chosen.durationInFrames;
    secondsCursor += chosen.durationSeconds;
  }

  return { fps: full.fps, totalFrames: frameCursor, totalSeconds: secondsCursor, scenes };
}

function main() {
  mkdirSync(OUT_DIR, { recursive: true });
  const plan = buildFullChapterTeachingPlan({
    classLevel: "Class 10",
    board: "Kerala SSLC",
    subject: "Physics",
    chapter: "Sound Waves",
  });
  const full = buildTimeline(plan);
  const explicitTimeline = buildSampleTimeline(full);

  writeFileSync(`${OUT_DIR}/render-props.json`, JSON.stringify({ plan, explicitTimeline }, null, 2), "utf-8");

  console.log("Day19 Sample Render Props");
  console.log("===========================");
  console.log(`Scenes: ${explicitTimeline.scenes.length}`);
  console.log(`Total duration: ${(explicitTimeline.totalSeconds / 60).toFixed(2)} min`);
  console.log(`Written to ${OUT_DIR}/render-props.json`);
}

main();