@lssm-tech/lib.video-gen 3.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +79 -0
- package/dist/browser/compositions/api-overview.js +1 -0
- package/dist/browser/compositions/index.js +1 -0
- package/dist/browser/compositions/primitives/animated-text.js +1 -0
- package/dist/browser/compositions/primitives/brand-frame.js +1 -0
- package/dist/browser/compositions/primitives/code-block.js +1 -0
- package/dist/browser/compositions/primitives/index.js +1 -0
- package/dist/browser/compositions/primitives/progress-bar.js +1 -0
- package/dist/browser/compositions/primitives/terminal.js +1 -0
- package/dist/browser/compositions/primitives/transition.js +1 -0
- package/dist/browser/compositions/social-clip.js +1 -0
- package/dist/browser/compositions/terminal-demo.js +1 -0
- package/dist/browser/design/index.js +1 -0
- package/dist/browser/design/layouts.js +1 -0
- package/dist/browser/design/motion.js +1 -0
- package/dist/browser/design/tokens.js +1 -0
- package/dist/browser/design/typography.js +1 -0
- package/dist/browser/docs/compositions.docblock.js +1 -0
- package/dist/browser/docs/design.docblock.js +172 -0
- package/dist/browser/docs/generators.docblock.js +165 -0
- package/dist/browser/docs/rendering.docblock.js +175 -0
- package/dist/browser/docs/video-gen.docblock.js +126 -0
- package/dist/browser/generators/index.js +82 -0
- package/dist/browser/generators/scene-planner.js +82 -0
- package/dist/browser/generators/script-generator.js +82 -0
- package/dist/browser/generators/video-generator.js +82 -0
- package/dist/browser/i18n/catalogs/en.js +28 -0
- package/dist/browser/i18n/catalogs/es.js +28 -0
- package/dist/browser/i18n/catalogs/fr.js +28 -0
- package/dist/browser/i18n/catalogs/index.js +82 -0
- package/dist/browser/i18n/index.js +82 -0
- package/dist/browser/i18n/keys.js +1 -0
- package/dist/browser/i18n/locale.js +1 -0
- package/dist/browser/i18n/messages.js +82 -0
- package/dist/browser/index.js +82 -0
- package/dist/browser/player/demo-player.js +1 -0
- package/dist/browser/player/index.js +1 -0
- package/dist/browser/remotion/Root.js +19 -0
- package/dist/browser/remotion/index.js +19 -0
- package/dist/browser/renderers/config.js +1 -0
- package/dist/browser/renderers/index.js +1 -0
- package/dist/browser/renderers/local.js +1 -0
- package/dist/browser/types.js +1 -0
- package/dist/browser/video-gen.feature.js +1 -0
- package/dist/compositions/api-overview.d.ts +16 -0
- package/dist/compositions/api-overview.js +2 -0
- package/dist/compositions/index.d.ts +7 -0
- package/dist/compositions/index.js +2 -0
- package/dist/compositions/primitives/animated-text.d.ts +22 -0
- package/dist/compositions/primitives/animated-text.js +2 -0
- package/dist/compositions/primitives/brand-frame.d.ts +14 -0
- package/dist/compositions/primitives/brand-frame.js +2 -0
- package/dist/compositions/primitives/code-block.d.ts +18 -0
- package/dist/compositions/primitives/code-block.js +2 -0
- package/dist/compositions/primitives/index.d.ts +12 -0
- package/dist/compositions/primitives/index.js +2 -0
- package/dist/compositions/primitives/progress-bar.d.ts +12 -0
- package/dist/compositions/primitives/progress-bar.js +2 -0
- package/dist/compositions/primitives/terminal.d.ts +24 -0
- package/dist/compositions/primitives/terminal.js +2 -0
- package/dist/compositions/primitives/transition.d.ts +14 -0
- package/dist/compositions/primitives/transition.js +2 -0
- package/dist/compositions/social-clip.d.ts +16 -0
- package/dist/compositions/social-clip.js +2 -0
- package/dist/compositions/terminal-demo.d.ts +17 -0
- package/dist/compositions/terminal-demo.js +2 -0
- package/dist/design/index.d.ts +4 -0
- package/dist/design/index.js +2 -0
- package/dist/design/layouts.d.ts +69 -0
- package/dist/design/layouts.js +2 -0
- package/dist/design/motion.d.ts +72 -0
- package/dist/design/motion.js +2 -0
- package/dist/design/tokens.d.ts +31 -0
- package/dist/design/tokens.js +2 -0
- package/dist/design/typography.d.ts +61 -0
- package/dist/design/typography.js +2 -0
- package/dist/docs/compositions.docblock.d.ts +1 -0
- package/dist/docs/compositions.docblock.js +2 -0
- package/dist/docs/design.docblock.d.ts +1 -0
- package/dist/docs/design.docblock.js +173 -0
- package/dist/docs/generators.docblock.d.ts +1 -0
- package/dist/docs/generators.docblock.js +166 -0
- package/dist/docs/rendering.docblock.d.ts +1 -0
- package/dist/docs/rendering.docblock.js +176 -0
- package/dist/docs/video-gen.docblock.d.ts +1 -0
- package/dist/docs/video-gen.docblock.js +127 -0
- package/dist/generators/index.d.ts +3 -0
- package/dist/generators/index.js +83 -0
- package/dist/generators/scene-planner.d.ts +31 -0
- package/dist/generators/scene-planner.js +83 -0
- package/dist/generators/script-generator.d.ts +57 -0
- package/dist/generators/script-generator.js +83 -0
- package/dist/generators/video-generator.d.ts +21 -0
- package/dist/generators/video-generator.js +83 -0
- package/dist/i18n/catalogs/en.d.ts +8 -0
- package/dist/i18n/catalogs/en.js +29 -0
- package/dist/i18n/catalogs/es.d.ts +6 -0
- package/dist/i18n/catalogs/es.js +29 -0
- package/dist/i18n/catalogs/fr.d.ts +6 -0
- package/dist/i18n/catalogs/fr.js +29 -0
- package/dist/i18n/catalogs/index.d.ts +8 -0
- package/dist/i18n/catalogs/index.js +83 -0
- package/dist/i18n/i18n.test.d.ts +1 -0
- package/dist/i18n/index.d.ts +22 -0
- package/dist/i18n/index.js +83 -0
- package/dist/i18n/keys.d.ts +116 -0
- package/dist/i18n/keys.js +2 -0
- package/dist/i18n/locale.d.ts +8 -0
- package/dist/i18n/locale.js +2 -0
- package/dist/i18n/messages.d.ts +14 -0
- package/dist/i18n/messages.js +83 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +83 -0
- package/dist/node/compositions/api-overview.js +1 -0
- package/dist/node/compositions/index.js +1 -0
- package/dist/node/compositions/primitives/animated-text.js +1 -0
- package/dist/node/compositions/primitives/brand-frame.js +1 -0
- package/dist/node/compositions/primitives/code-block.js +1 -0
- package/dist/node/compositions/primitives/index.js +1 -0
- package/dist/node/compositions/primitives/progress-bar.js +1 -0
- package/dist/node/compositions/primitives/terminal.js +1 -0
- package/dist/node/compositions/primitives/transition.js +1 -0
- package/dist/node/compositions/social-clip.js +1 -0
- package/dist/node/compositions/terminal-demo.js +1 -0
- package/dist/node/design/index.js +1 -0
- package/dist/node/design/layouts.js +1 -0
- package/dist/node/design/motion.js +1 -0
- package/dist/node/design/tokens.js +1 -0
- package/dist/node/design/typography.js +1 -0
- package/dist/node/docs/compositions.docblock.js +1 -0
- package/dist/node/docs/design.docblock.js +172 -0
- package/dist/node/docs/generators.docblock.js +165 -0
- package/dist/node/docs/rendering.docblock.js +175 -0
- package/dist/node/docs/video-gen.docblock.js +126 -0
- package/dist/node/generators/index.js +82 -0
- package/dist/node/generators/scene-planner.js +82 -0
- package/dist/node/generators/script-generator.js +82 -0
- package/dist/node/generators/video-generator.js +82 -0
- package/dist/node/i18n/catalogs/en.js +28 -0
- package/dist/node/i18n/catalogs/es.js +28 -0
- package/dist/node/i18n/catalogs/fr.js +28 -0
- package/dist/node/i18n/catalogs/index.js +82 -0
- package/dist/node/i18n/index.js +82 -0
- package/dist/node/i18n/keys.js +1 -0
- package/dist/node/i18n/locale.js +1 -0
- package/dist/node/i18n/messages.js +82 -0
- package/dist/node/index.js +82 -0
- package/dist/node/player/demo-player.js +1 -0
- package/dist/node/player/index.js +1 -0
- package/dist/node/remotion/Root.js +19 -0
- package/dist/node/remotion/index.js +19 -0
- package/dist/node/renderers/config.js +1 -0
- package/dist/node/renderers/index.js +1 -0
- package/dist/node/renderers/local.js +1 -0
- package/dist/node/types.js +1 -0
- package/dist/node/video-gen.feature.js +1 -0
- package/dist/player/demo-player.d.ts +55 -0
- package/dist/player/demo-player.js +2 -0
- package/dist/player/index.d.ts +2 -0
- package/dist/player/index.js +2 -0
- package/dist/remotion/Root.d.ts +2 -0
- package/dist/remotion/Root.js +20 -0
- package/dist/remotion/index.d.ts +1 -0
- package/dist/remotion/index.js +20 -0
- package/dist/renderers/config.d.ts +28 -0
- package/dist/renderers/config.js +2 -0
- package/dist/renderers/index.d.ts +3 -0
- package/dist/renderers/index.js +2 -0
- package/dist/renderers/local.d.ts +17 -0
- package/dist/renderers/local.js +2 -0
- package/dist/types.d.ts +85 -0
- package/dist/types.js +2 -0
- package/dist/video-gen.feature.d.ts +1 -0
- package/dist/video-gen.feature.js +2 -0
- package/package.json +675 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import{registerDocBlocks as f}from"@contractspec/lib.contracts-spec/docs";var h=[{id:"docs.video-gen.generators",title:"Video Generation Pipeline",summary:"VideoGenerator, ScenePlanner, and ScriptGenerator -- from content brief to video project with optional LLM enhancement.",kind:"reference",visibility:"public",route:"/docs/video-gen/generators",tags:["video","generators","scene-planner","script-generator","llm","content-pipeline"],owners:["@contractspec/lib.video-gen"],body:`# Video Generation Pipeline
|
|
2
|
+
|
|
3
|
+
The generators layer converts a \`VideoBrief\` (content brief + video config) into a fully specified \`VideoProject\` (scene graph ready for rendering). It follows the \`@contractspec/lib.content-gen\` pattern: optional LLM, deterministic fallback.
|
|
4
|
+
|
|
5
|
+
\`\`\`
|
|
6
|
+
VideoBrief
|
|
7
|
+
|
|
|
8
|
+
v
|
|
9
|
+
ScenePlanner.plan(brief) --> ScenePlan (scenes + durations)
|
|
10
|
+
|
|
|
11
|
+
v
|
|
12
|
+
ScriptGenerator.generate(brief) --> NarrationScript (text + segments)
|
|
13
|
+
|
|
|
14
|
+
v
|
|
15
|
+
VoiceProvider.synthesize(text) --> AudioTrack (optional)
|
|
16
|
+
|
|
|
17
|
+
v
|
|
18
|
+
VideoGenerator.generate(brief) --> VideoProject (complete scene graph)
|
|
19
|
+
\`\`\`
|
|
20
|
+
|
|
21
|
+
## VideoGenerator
|
|
22
|
+
|
|
23
|
+
The main orchestrator. Wires ScenePlanner, ScriptGenerator, and optional VoiceProvider into a single pipeline.
|
|
24
|
+
|
|
25
|
+
\`\`\`ts
|
|
26
|
+
import { VideoGenerator } from "@contractspec/lib.video-gen/generators";
|
|
27
|
+
import type { VideoBrief } from "@contractspec/lib.video-gen/types";
|
|
28
|
+
|
|
29
|
+
// Minimal (deterministic, no LLM, no voice)
|
|
30
|
+
const generator = new VideoGenerator({ fps: 30 });
|
|
31
|
+
|
|
32
|
+
// Full (with LLM for richer scenes + voice narration)
|
|
33
|
+
const generator = new VideoGenerator({
|
|
34
|
+
llm: myLLMProvider,
|
|
35
|
+
voice: myVoiceProvider,
|
|
36
|
+
model: "gpt-4o",
|
|
37
|
+
temperature: 0.4,
|
|
38
|
+
defaultVoiceId: "rachel",
|
|
39
|
+
fps: 30,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const project = await generator.generate(brief);
|
|
43
|
+
\`\`\`
|
|
44
|
+
|
|
45
|
+
### Pipeline Steps
|
|
46
|
+
|
|
47
|
+
1. **Scene planning** -- \`ScenePlanner.plan(brief)\` breaks the brief into concrete \`PlannedScene[]\` with composition IDs, props, and durations.
|
|
48
|
+
2. **Script generation** -- If \`brief.narration.enabled\`, \`ScriptGenerator.generate()\` produces a \`NarrationScript\` with per-scene text segments.
|
|
49
|
+
3. **Voice synthesis** -- If a \`VoiceProvider\` is configured and narration is enabled, synthesizes audio via \`voice.synthesize()\`.
|
|
50
|
+
4. **Assembly** -- Combines scenes, audio, and metadata into a \`VideoProject\`.
|
|
51
|
+
|
|
52
|
+
### Constructor Options
|
|
53
|
+
|
|
54
|
+
| Option | Type | Default | Description |
|
|
55
|
+
|--------|------|---------|-------------|
|
|
56
|
+
| \`llm\` | \`LLMProvider\` | -- | Optional LLM for enhanced generation |
|
|
57
|
+
| \`voice\` | \`VoiceProvider\` | -- | Optional voice synthesis provider |
|
|
58
|
+
| \`model\` | \`string\` | -- | LLM model override |
|
|
59
|
+
| \`temperature\` | \`number\` | \`0.4\` | LLM temperature (lower = more deterministic) |
|
|
60
|
+
| \`defaultVoiceId\` | \`string\` | -- | Default voice for narration |
|
|
61
|
+
| \`fps\` | \`number\` | \`30\` | Frames per second |
|
|
62
|
+
|
|
63
|
+
## ScenePlanner
|
|
64
|
+
|
|
65
|
+
Breaks a \`VideoBrief\` into concrete scenes mapped to registered compositions.
|
|
66
|
+
|
|
67
|
+
\`\`\`ts
|
|
68
|
+
import { ScenePlanner } from "@contractspec/lib.video-gen/generators";
|
|
69
|
+
|
|
70
|
+
const planner = new ScenePlanner({ fps: 30 });
|
|
71
|
+
const plan = await planner.plan(brief);
|
|
72
|
+
|
|
73
|
+
plan.scenes; // PlannedScene[]
|
|
74
|
+
plan.estimatedDurationSeconds; // total estimated duration
|
|
75
|
+
plan.narrationScript; // combined narration text
|
|
76
|
+
\`\`\`
|
|
77
|
+
|
|
78
|
+
### Deterministic Path (no LLM)
|
|
79
|
+
|
|
80
|
+
Maps brief sections to \`SocialClip\` compositions:
|
|
81
|
+
|
|
82
|
+
| Brief Section | Scene | Duration |
|
|
83
|
+
|---------------|-------|----------|
|
|
84
|
+
| \`title\` + \`summary\` | Hook / title | 3s |
|
|
85
|
+
| \`problems\` | Problem statement | 4s |
|
|
86
|
+
| \`solutions\` | Solution showcase | 5s |
|
|
87
|
+
| \`metrics\` | Proof / results | 3s |
|
|
88
|
+
| \`callToAction\` | CTA | 2s |
|
|
89
|
+
|
|
90
|
+
If \`brief.targetDurationSeconds\` is set, all scene durations are scaled proportionally.
|
|
91
|
+
|
|
92
|
+
### LLM-Enhanced Path
|
|
93
|
+
|
|
94
|
+
With an \`LLMProvider\`, the planner sends the brief to the LLM and requests a scene breakdown as JSON. The LLM can choose from \`ApiOverview\`, \`SocialClip\`, or \`TerminalDemo\` compositions. Falls back to deterministic on any failure.
|
|
95
|
+
|
|
96
|
+
## ScriptGenerator
|
|
97
|
+
|
|
98
|
+
Produces narration text from a \`ContentBrief\` with style control.
|
|
99
|
+
|
|
100
|
+
\`\`\`ts
|
|
101
|
+
import { ScriptGenerator } from "@contractspec/lib.video-gen/generators";
|
|
102
|
+
|
|
103
|
+
const scriptGen = new ScriptGenerator({ temperature: 0.5 });
|
|
104
|
+
const script = await scriptGen.generate(brief.content, brief.narration);
|
|
105
|
+
|
|
106
|
+
script.fullText; // complete narration
|
|
107
|
+
script.segments; // NarrationSegment[] (per-scene text)
|
|
108
|
+
script.estimatedDurationSeconds; // at ~150 words/min
|
|
109
|
+
script.style; // "professional" | "casual" | "technical"
|
|
110
|
+
\`\`\`
|
|
111
|
+
|
|
112
|
+
### Narration Styles
|
|
113
|
+
|
|
114
|
+
| Style | Tone |
|
|
115
|
+
|-------|------|
|
|
116
|
+
| \`professional\` | Clear, authoritative, concise |
|
|
117
|
+
| \`casual\` | Friendly, conversational, approachable |
|
|
118
|
+
| \`technical\` | Precise, detailed, accurate |
|
|
119
|
+
|
|
120
|
+
### NarrationSegment
|
|
121
|
+
|
|
122
|
+
Each segment maps to a scene and provides timing estimates:
|
|
123
|
+
|
|
124
|
+
\`\`\`ts
|
|
125
|
+
interface NarrationSegment {
|
|
126
|
+
sceneId: string; // "intro", "problems", "solutions", "metrics", "cta"
|
|
127
|
+
text: string; // narration text for this segment
|
|
128
|
+
estimatedDurationSeconds: number; // at ~150 words/min
|
|
129
|
+
}
|
|
130
|
+
\`\`\`
|
|
131
|
+
|
|
132
|
+
## Input Types
|
|
133
|
+
|
|
134
|
+
### VideoBrief
|
|
135
|
+
|
|
136
|
+
\`\`\`ts
|
|
137
|
+
interface VideoBrief {
|
|
138
|
+
content: ContentBrief; // from @contractspec/lib.content-gen
|
|
139
|
+
format: VideoFormat; // landscape, portrait, square, or custom
|
|
140
|
+
targetDurationSeconds?: number; // auto-calculated if omitted
|
|
141
|
+
narration?: NarrationConfig; // { enabled, voiceId, language, style }
|
|
142
|
+
style?: VideoStyleOverrides; // colors, fonts, dark mode
|
|
143
|
+
compositionId?: string; // force a specific composition
|
|
144
|
+
}
|
|
145
|
+
\`\`\`
|
|
146
|
+
|
|
147
|
+
### PlannedScene
|
|
148
|
+
|
|
149
|
+
\`\`\`ts
|
|
150
|
+
interface PlannedScene {
|
|
151
|
+
compositionId: string; // maps to a registered Remotion composition
|
|
152
|
+
props: Record<string, unknown>; // input props for the composition
|
|
153
|
+
durationInFrames: number; // scene duration
|
|
154
|
+
narrationText?: string; // narrator text for this scene
|
|
155
|
+
notes?: string; // planning notes (LLM path only)
|
|
156
|
+
}
|
|
157
|
+
\`\`\`
|
|
158
|
+
|
|
159
|
+
## Guardrails
|
|
160
|
+
|
|
161
|
+
- Generators are **stateless** -- no side effects, no caching. Call \`generate()\` / \`plan()\` for each video.
|
|
162
|
+
- LLM responses are parsed as JSON; any parse failure falls back to deterministic.
|
|
163
|
+
- Temperature defaults are conservative (0.3-0.5) for reproducibility.
|
|
164
|
+
- Duration estimates use 150 words/min speaking rate.
|
|
165
|
+
`}];f(h);
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import{registerDocBlocks as f}from"@contractspec/lib.contracts-spec/docs";var h=[{id:"docs.video-gen.rendering",title:"Video Rendering & Playback",summary:"LocalRenderer for MP4 output, render configuration, quality presets, DemoPlayer for web embedding, and Remotion Studio setup.",kind:"reference",visibility:"public",route:"/docs/video-gen/rendering",tags:["video","rendering","remotion","player","mp4","quality-presets"],owners:["@contractspec/lib.video-gen"],body:`# Video Rendering & Playback
|
|
2
|
+
|
|
3
|
+
The rendering layer wraps \`@remotion/renderer\` for MP4/WebM output and \`@remotion/player\` for interactive web embedding. It implements the \`VideoProvider\` contract from \`@contractspec/lib.contracts-integrations\`.
|
|
4
|
+
|
|
5
|
+
## LocalRenderer
|
|
6
|
+
|
|
7
|
+
Renders a \`VideoProject\` to a video file using the local Remotion renderer. Works with **Node.js** and **Bun** (via \`remotionb\`). Bun caveat: SSR scripts may not auto-quit (see [Remotion Bun docs](https://www.remotion.dev/docs/bun)).
|
|
8
|
+
|
|
9
|
+
\`\`\`ts
|
|
10
|
+
import { LocalRenderer } from "@contractspec/lib.video-gen/renderers/local";
|
|
11
|
+
|
|
12
|
+
const renderer = new LocalRenderer({
|
|
13
|
+
entryPoint: "./src/remotion/index.ts",
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const result = await renderer.render(project, {
|
|
17
|
+
outputPath: "out/video.mp4",
|
|
18
|
+
codec: "h264",
|
|
19
|
+
crf: 18,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
result.outputPath; // "out/video.mp4"
|
|
23
|
+
result.format; // "mp4"
|
|
24
|
+
result.durationSeconds; // total duration
|
|
25
|
+
result.fileSizeBytes; // file size
|
|
26
|
+
result.dimensions; // { width: 1920, height: 1080 }
|
|
27
|
+
\`\`\`
|
|
28
|
+
|
|
29
|
+
> **Important**: Import \`LocalRenderer\` from the \`/renderers/local\` subpath, not from the main entry. It dynamically imports \`@remotion/bundler\` and \`@remotion/renderer\` to avoid bundling them in browser builds.
|
|
30
|
+
|
|
31
|
+
### Auto-Variants
|
|
32
|
+
|
|
33
|
+
Set \`autoVariants: true\` to generate landscape + square + portrait versions:
|
|
34
|
+
|
|
35
|
+
\`\`\`ts
|
|
36
|
+
const result = await renderer.render(project, {
|
|
37
|
+
outputPath: "out/video.mp4",
|
|
38
|
+
autoVariants: true,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
result.variants; // [
|
|
42
|
+
// { outputPath: "out/video-square.mp4", dimensions: { width: 1080, height: 1080 } },
|
|
43
|
+
// { outputPath: "out/video-portrait.mp4", dimensions: { width: 1080, height: 1920 } },
|
|
44
|
+
// ]
|
|
45
|
+
\`\`\`
|
|
46
|
+
|
|
47
|
+
## Render Configuration
|
|
48
|
+
|
|
49
|
+
### Defaults
|
|
50
|
+
|
|
51
|
+
\`\`\`ts
|
|
52
|
+
import {
|
|
53
|
+
defaultRenderConfig,
|
|
54
|
+
resolveRenderConfig,
|
|
55
|
+
qualityPresets,
|
|
56
|
+
codecFormatMap,
|
|
57
|
+
} from "@contractspec/lib.video-gen/renderers/config";
|
|
58
|
+
|
|
59
|
+
defaultRenderConfig.codec; // "h264"
|
|
60
|
+
defaultRenderConfig.outputFormat; // "mp4"
|
|
61
|
+
defaultRenderConfig.crf; // 18
|
|
62
|
+
defaultRenderConfig.pixelFormat; // "yuv420p"
|
|
63
|
+
\`\`\`
|
|
64
|
+
|
|
65
|
+
### RenderConfig Options
|
|
66
|
+
|
|
67
|
+
| Option | Type | Default | Description |
|
|
68
|
+
|--------|------|---------|-------------|
|
|
69
|
+
| \`outputPath\` | \`string\` | -- | **Required**. Output file path |
|
|
70
|
+
| \`codec\` | \`"h264" \\| "h265" \\| "vp8" \\| "vp9"\` | \`"h264"\` | Video codec |
|
|
71
|
+
| \`outputFormat\` | \`"mp4" \\| "webm" \\| "gif"\` | \`"mp4"\` | Container format |
|
|
72
|
+
| \`crf\` | \`number\` | \`18\` | Constant Rate Factor (lower = better quality) |
|
|
73
|
+
| \`pixelFormat\` | \`string\` | \`"yuv420p"\` | Pixel format |
|
|
74
|
+
| \`concurrency\` | \`number\` | CPU count | Rendering threads |
|
|
75
|
+
| \`autoVariants\` | \`boolean\` | \`false\` | Generate format variants |
|
|
76
|
+
|
|
77
|
+
### Quality Presets
|
|
78
|
+
|
|
79
|
+
\`\`\`ts
|
|
80
|
+
import { resolveRenderConfig } from "@contractspec/lib.video-gen/renderers/config";
|
|
81
|
+
|
|
82
|
+
// Draft (fastest, for previews)
|
|
83
|
+
resolveRenderConfig({ outputPath: "out/preview.mp4" }, "draft");
|
|
84
|
+
// -> crf: 28, concurrency: 1
|
|
85
|
+
|
|
86
|
+
// Standard (balanced)
|
|
87
|
+
resolveRenderConfig({ outputPath: "out/video.mp4" }, "standard");
|
|
88
|
+
// -> crf: 18
|
|
89
|
+
|
|
90
|
+
// High (best quality, for final output)
|
|
91
|
+
resolveRenderConfig({ outputPath: "out/final.mp4" }, "high");
|
|
92
|
+
// -> crf: 12
|
|
93
|
+
\`\`\`
|
|
94
|
+
|
|
95
|
+
### Codec-to-Format Mapping
|
|
96
|
+
|
|
97
|
+
| Codec | Format |
|
|
98
|
+
|-------|--------|
|
|
99
|
+
| \`h264\` | \`mp4\` |
|
|
100
|
+
| \`h265\` | \`mp4\` |
|
|
101
|
+
| \`vp8\` | \`webm\` |
|
|
102
|
+
| \`vp9\` | \`webm\` |
|
|
103
|
+
|
|
104
|
+
## DemoPlayer (Web Embedding)
|
|
105
|
+
|
|
106
|
+
Embeddable Remotion Player for interactive video demos in React apps. Wraps \`@remotion/player\` with ContractSpec compositions.
|
|
107
|
+
|
|
108
|
+
\`\`\`tsx
|
|
109
|
+
import { DemoPlayer } from "@contractspec/lib.video-gen/player";
|
|
110
|
+
|
|
111
|
+
<DemoPlayer
|
|
112
|
+
compositionId="ApiOverview"
|
|
113
|
+
inputProps={{
|
|
114
|
+
specName: "CreateUser",
|
|
115
|
+
specCode: "export const createUser = defineCommand({...})",
|
|
116
|
+
}}
|
|
117
|
+
controls
|
|
118
|
+
autoPlay
|
|
119
|
+
loop
|
|
120
|
+
width="100%"
|
|
121
|
+
clickToPlay
|
|
122
|
+
doubleClickToFullscreen
|
|
123
|
+
/>
|
|
124
|
+
\`\`\`
|
|
125
|
+
|
|
126
|
+
### DemoPlayer Props
|
|
127
|
+
|
|
128
|
+
| Prop | Type | Default | Description |
|
|
129
|
+
|------|------|---------|-------------|
|
|
130
|
+
| \`compositionId\` | \`"ApiOverview" \\| "SocialClip" \\| "TerminalDemo"\` | -- | Composition to play |
|
|
131
|
+
| \`inputProps\` | composition props type | -- | Props for the selected composition |
|
|
132
|
+
| \`controls\` | \`boolean\` | \`true\` | Show playback controls |
|
|
133
|
+
| \`autoPlay\` | \`boolean\` | \`false\` | Auto-play on mount |
|
|
134
|
+
| \`loop\` | \`boolean\` | \`false\` | Loop playback |
|
|
135
|
+
| \`width\` | \`string \\| number\` | \`"100%"\` | Player width |
|
|
136
|
+
| \`height\` | \`string \\| number\` | \`"auto"\` | Player height |
|
|
137
|
+
| \`clickToPlay\` | \`boolean\` | \`true\` | Click to toggle playback |
|
|
138
|
+
| \`doubleClickToFullscreen\` | \`boolean\` | \`true\` | Double-click for fullscreen |
|
|
139
|
+
|
|
140
|
+
> \`@remotion/player\` is a peer dependency. Install it in your app if you use \`DemoPlayer\`.
|
|
141
|
+
|
|
142
|
+
## Remotion Studio
|
|
143
|
+
|
|
144
|
+
The \`@contractspec/app.video-studio\` package provides a Remotion Studio entry point for previewing compositions interactively.
|
|
145
|
+
|
|
146
|
+
\`\`\`bash
|
|
147
|
+
# Start Remotion Studio
|
|
148
|
+
bun run dev:video
|
|
149
|
+
|
|
150
|
+
# Render a specific composition
|
|
151
|
+
bunx remotionb render src/index.ts ApiOverview out/api-overview.mp4
|
|
152
|
+
|
|
153
|
+
# Render all compositions
|
|
154
|
+
bun run render:all
|
|
155
|
+
\`\`\`
|
|
156
|
+
|
|
157
|
+
### Registered Compositions
|
|
158
|
+
|
|
159
|
+
| ID | Component | Dimensions | Duration | Description |
|
|
160
|
+
|----|-----------|------------|----------|-------------|
|
|
161
|
+
| \`ApiOverview\` | \`ApiOverview\` | 1920x1080 | 450 frames (15s) | Homepage API demo |
|
|
162
|
+
| \`SocialClip\` | \`SocialClip\` | 1920x1080 | 300 frames (10s) | Landscape social clip |
|
|
163
|
+
| \`SocialClipSquare\` | \`SocialClip\` | 1080x1080 | 300 frames (10s) | Square social clip |
|
|
164
|
+
| \`SocialClipPortrait\` | \`SocialClip\` | 1080x1920 | 300 frames (10s) | Portrait social clip |
|
|
165
|
+
| \`TerminalDemo\` | \`TerminalDemo\` | 1920x1080 | 600 frames (20s) | CLI walkthrough |
|
|
166
|
+
|
|
167
|
+
All compositions run at 30fps.
|
|
168
|
+
|
|
169
|
+
## Guardrails
|
|
170
|
+
|
|
171
|
+
- \`LocalRenderer\` requires Node.js or Bun -- do not attempt to use it in browser environments. On Bun, SSR scripts may not auto-quit (see [Remotion Bun docs](https://www.remotion.dev/docs/bun)).
|
|
172
|
+
- Import \`LocalRenderer\` from the \`/renderers/local\` subpath to avoid bundling \`@remotion/renderer\` in browser builds.
|
|
173
|
+
- The \`remotion\` entry point (\`@contractspec/lib.video-gen/remotion\`) is a **side-effect module** that calls \`registerRoot()\`. Only import it from Remotion Studio or render scripts.
|
|
174
|
+
- Use quality presets for consistency: \`draft\` for development, \`standard\` for CI, \`high\` for releases.
|
|
175
|
+
`}];f(h);
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import{registerDocBlocks as f}from"@contractspec/lib.contracts-spec/docs";var h=[{id:"docs.video-gen.overview",title:"Video Generation Library",summary:"Programmatic video generation with Remotion -- from content brief to rendered MP4 in a single pipeline.",kind:"reference",visibility:"public",route:"/docs/video-gen/overview",tags:["video","remotion","generation","content-pipeline"],owners:["@contractspec/lib.video-gen"],body:`# Video Generation Library
|
|
2
|
+
|
|
3
|
+
\`@contractspec/lib.video-gen\` provides **programmatic video generation** using [Remotion](https://remotion.dev). It follows the same generator pattern as \`@contractspec/lib.content-gen\` and consumes provider contracts from \`@contractspec/lib.contracts-integrations/integrations/providers/video\`.
|
|
4
|
+
|
|
5
|
+
## Architecture
|
|
6
|
+
|
|
7
|
+
The library is organized into five layers, each buildable and testable independently:
|
|
8
|
+
|
|
9
|
+
\`\`\`
|
|
10
|
+
Content Brief
|
|
11
|
+
|
|
|
12
|
+
v
|
|
13
|
+
Generators -----> ScenePlanner (brief -> scenes)
|
|
14
|
+
| ScriptGenerator (brief -> narration)
|
|
15
|
+
| VideoGenerator (orchestrator)
|
|
16
|
+
v
|
|
17
|
+
Compositions ---> Primitives (AnimatedText, CodeBlock, Terminal, ...)
|
|
18
|
+
| Full Compositions (ApiOverview, SocialClip, TerminalDemo)
|
|
19
|
+
v
|
|
20
|
+
Design ---------> Tokens, Motion, Typography, Layouts
|
|
21
|
+
|
|
|
22
|
+
v
|
|
23
|
+
Renderers ------> LocalRenderer (@remotion/renderer)
|
|
24
|
+
DemoPlayer (@remotion/player, web embedding)
|
|
25
|
+
\`\`\`
|
|
26
|
+
|
|
27
|
+
### Layer Responsibilities
|
|
28
|
+
|
|
29
|
+
| Layer | Import Path | Purpose |
|
|
30
|
+
|-------|-------------|---------|
|
|
31
|
+
| **Types** | \`@contractspec/lib.video-gen/types\` | VideoBrief, ScenePlan, GeneratedVideo, re-exported contract types |
|
|
32
|
+
| **Design** | \`@contractspec/lib.video-gen/design\` | Video-optimized tokens, motion primitives, typography, layouts |
|
|
33
|
+
| **Compositions** | \`@contractspec/lib.video-gen/compositions\` | Remotion components (primitives + full compositions) |
|
|
34
|
+
| **Generators** | \`@contractspec/lib.video-gen/generators\` | VideoGenerator, ScenePlanner, ScriptGenerator |
|
|
35
|
+
| **Renderers** | \`@contractspec/lib.video-gen/renderers\` | LocalRenderer, render config, quality presets |
|
|
36
|
+
| **Player** | \`@contractspec/lib.video-gen/player\` | Embeddable DemoPlayer for web apps |
|
|
37
|
+
| **Remotion** | \`@contractspec/lib.video-gen/remotion\` | Remotion Studio entry point (registerRoot) |
|
|
38
|
+
|
|
39
|
+
## Getting Started
|
|
40
|
+
|
|
41
|
+
### 1. Generate a video project from a content brief
|
|
42
|
+
|
|
43
|
+
\`\`\`ts
|
|
44
|
+
import { VideoGenerator } from "@contractspec/lib.video-gen/generators";
|
|
45
|
+
import { VIDEO_FORMATS } from "@contractspec/lib.video-gen/types";
|
|
46
|
+
import type { VideoBrief } from "@contractspec/lib.video-gen/types";
|
|
47
|
+
|
|
48
|
+
const generator = new VideoGenerator({ fps: 30 });
|
|
49
|
+
|
|
50
|
+
const brief: VideoBrief = {
|
|
51
|
+
content: {
|
|
52
|
+
title: "Ship APIs 10x Faster",
|
|
53
|
+
summary: "ContractSpec generates everything from a single spec.",
|
|
54
|
+
problems: ["Manual API maintenance", "Inconsistent surfaces"],
|
|
55
|
+
solutions: ["One spec, every surface", "Safe regeneration"],
|
|
56
|
+
callToAction: "Try ContractSpec",
|
|
57
|
+
},
|
|
58
|
+
format: VIDEO_FORMATS.landscape,
|
|
59
|
+
targetDurationSeconds: 30,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const project = await generator.generate(brief);
|
|
63
|
+
\`\`\`
|
|
64
|
+
|
|
65
|
+
### 2. Render to MP4
|
|
66
|
+
|
|
67
|
+
\`\`\`ts
|
|
68
|
+
import { LocalRenderer } from "@contractspec/lib.video-gen/renderers/local";
|
|
69
|
+
|
|
70
|
+
const renderer = new LocalRenderer({
|
|
71
|
+
entryPoint: "./src/remotion/index.ts",
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const result = await renderer.render(project, {
|
|
75
|
+
outputPath: "out/video.mp4",
|
|
76
|
+
});
|
|
77
|
+
\`\`\`
|
|
78
|
+
|
|
79
|
+
### 3. Embed in a web app
|
|
80
|
+
|
|
81
|
+
\`\`\`tsx
|
|
82
|
+
import { DemoPlayer } from "@contractspec/lib.video-gen/player";
|
|
83
|
+
|
|
84
|
+
<DemoPlayer
|
|
85
|
+
compositionId="ApiOverview"
|
|
86
|
+
inputProps={{ specName: "CreateUser", specCode: "..." }}
|
|
87
|
+
controls
|
|
88
|
+
autoPlay
|
|
89
|
+
loop
|
|
90
|
+
/>
|
|
91
|
+
\`\`\`
|
|
92
|
+
|
|
93
|
+
## Contract Bridge
|
|
94
|
+
|
|
95
|
+
The library consumes provider contracts defined in \`@contractspec/lib.contracts-integrations\`:
|
|
96
|
+
|
|
97
|
+
| Contract | Purpose |
|
|
98
|
+
|----------|---------|
|
|
99
|
+
| \`VideoProvider\` | Renderer abstraction (local, Lambda, Cloud Run) |
|
|
100
|
+
| \`VideoProject\` | Scene graph with format, fps, audio tracks |
|
|
101
|
+
| \`RenderConfig\` / \`RenderResult\` | Codec, quality, output path, dimensions |
|
|
102
|
+
| \`CompositionRegistry\` | Metadata for registered Remotion compositions |
|
|
103
|
+
| \`VideoFormat\` | Landscape / portrait / square / custom dimensions |
|
|
104
|
+
|
|
105
|
+
Types are re-exported from the main entry for convenience:
|
|
106
|
+
|
|
107
|
+
\`\`\`ts
|
|
108
|
+
import type { VideoProject, RenderConfig } from "@contractspec/lib.video-gen";
|
|
109
|
+
\`\`\`
|
|
110
|
+
|
|
111
|
+
## Deterministic by Default
|
|
112
|
+
|
|
113
|
+
All generators support two modes:
|
|
114
|
+
|
|
115
|
+
- **Without LLM**: Fully deterministic, template-based output. Same brief always produces the same video project.
|
|
116
|
+
- **With LLM**: Richer scene planning and narration scripts via an optional \`LLMProvider\`. Falls back to deterministic on any failure.
|
|
117
|
+
|
|
118
|
+
This matches the content-gen pattern: \`constructor({ llm? })\` -> \`generate(brief)\`.
|
|
119
|
+
|
|
120
|
+
## Guardrails
|
|
121
|
+
|
|
122
|
+
- Compositions must be **deterministic**: same props = same visual output.
|
|
123
|
+
- Design tokens bridge from \`@contractspec/lib.design-system\` -- do not duplicate brand values.
|
|
124
|
+
- \`LocalRenderer\` works with Node.js and Bun. On Bun, SSR scripts may not auto-quit (see [Remotion Bun docs](https://www.remotion.dev/docs/bun)).
|
|
125
|
+
- The \`remotion\` entry point is a side-effect module (calls \`registerRoot\`) -- import it only from Remotion Studio or render scripts.
|
|
126
|
+
`}];f(h);
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
var d=((x)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(x,{get:(G,K)=>(typeof require<"u"?require:G)[K]}):x)(function(x){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+x+'" is not supported')});import{VIDEO_FORMATS as W}from"@contractspec/lib.contracts-integrations/integrations/providers/video";var Q=30,J={horizontal:120,vertical:80,contentWidth:1680,contentHeight:920};function b(x){let G=x.width/1920,K=x.height/1080;return{horizontal:Math.round(J.horizontal*G),vertical:Math.round(J.vertical*K),contentWidth:Math.round(J.contentWidth*G),contentHeight:Math.round(J.contentHeight*K)}}var p={center:{x:960,y:540},topLeft:{x:120,y:80},topRight:{x:1800,y:80},bottomLeft:{x:120,y:1000},bottomRight:{x:1800,y:1000},bottomCenter:{x:960,y:960}};function r(){return[W.landscape,W.square,W.portrait]}import{defineTranslation as M}from"@contractspec/lib.contracts-spec/translations";var $=M({meta:{key:"video-gen.messages",version:"1.0.0",domain:"video-gen",description:"All user-facing, LLM-facing, and developer-facing strings for the video-gen package",owners:["platform"],stability:"experimental"},locale:"en",fallback:"en",messages:{"prompt.script.system":{value:`You are a video narration script writer.
|
|
2
|
+
Write a narration script for a short video (30-60 seconds).
|
|
3
|
+
{styleGuide}
|
|
4
|
+
|
|
5
|
+
Return JSON with shape:
|
|
6
|
+
{
|
|
7
|
+
"segments": [{ "sceneId": string, "text": string }],
|
|
8
|
+
"fullText": string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
Scene IDs should be: "intro", "problems", "solutions", "metrics", "cta".
|
|
12
|
+
Only include segments that are relevant to the brief content.`,description:"Script generator LLM system prompt",placeholders:[{name:"styleGuide",type:"string"}]},"prompt.scenePlanner.system":{value:`You are a video scene planner for ContractSpec marketing/documentation videos.
|
|
13
|
+
Given a content brief, break it into video scenes.
|
|
14
|
+
|
|
15
|
+
Each scene must have:
|
|
16
|
+
- compositionId: one of "ApiOverview", "SocialClip", "TerminalDemo"
|
|
17
|
+
- props: the input props for that composition (see type definitions)
|
|
18
|
+
- durationInFrames: duration at {fps}fps
|
|
19
|
+
- narrationText: what the narrator says during this scene
|
|
20
|
+
|
|
21
|
+
Return a JSON object with shape:
|
|
22
|
+
{
|
|
23
|
+
"scenes": [{ "compositionId": string, "props": object, "durationInFrames": number, "narrationText": string }],
|
|
24
|
+
"narrationScript": string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
Keep the total duration around {targetSeconds} seconds.
|
|
28
|
+
Prioritize clarity and pacing. Each scene should communicate one idea.`,description:"Scene planner LLM system prompt",placeholders:[{name:"fps",type:"number"},{name:"targetSeconds",type:"number"}]},"prompt.style.professional":{value:"Use a clear, authoritative, professional tone. Be concise and direct.",description:"Style guide for professional narration"},"prompt.style.casual":{value:"Use a friendly, conversational tone. Be approachable and relatable.",description:"Style guide for casual narration"},"prompt.style.technical":{value:"Use precise technical language. Be detailed and accurate.",description:"Style guide for technical narration"},"script.segment.challenge":{value:"The challenge: {content}",description:"Narration segment prefix for problems",placeholders:[{name:"content",type:"string"}]},"script.segment.solution":{value:"The solution: {content}",description:"Narration segment prefix for solutions",placeholders:[{name:"content",type:"string"}]},"script.segment.results":{value:"The results: {content}",description:"Narration segment prefix for metrics",placeholders:[{name:"content",type:"string"}]},"scene.cta.default":{value:"Learn more",description:"Default call-to-action text for scenes"},"scene.hook.problem":{value:"The Problem",description:"Scene hook label for problem statement"},"scene.narration.problem":{value:"The problem: {content}",description:"Scene narration for problem statement",placeholders:[{name:"content",type:"string"}]},"scene.hook.solution":{value:"The Solution",description:"Scene hook label for solution"},"scene.narration.solution":{value:"The solution: {content}",description:"Scene narration for solution",placeholders:[{name:"content",type:"string"}]},"scene.hook.results":{value:"Results",description:"Scene hook label for results/metrics"},"composition.apiOverview.generates":{value:"Generates:",description:"ApiOverview heading for generated outputs"},"composition.apiOverview.tagline":{value:"One spec. Every surface.",description:"ApiOverview default tagline"},"composition.apiOverview.output.rest":{value:"REST Endpoint",description:"Generated output label: REST"},"composition.apiOverview.output.graphql":{value:"GraphQL Mutation",description:"Generated output label: GraphQL"},"composition.apiOverview.output.prisma":{value:"Prisma Model",description:"Generated output label: Prisma"},"composition.apiOverview.output.typescript":{value:"TypeScript SDK",description:"Generated output label: TypeScript SDK"},"composition.apiOverview.output.mcp":{value:"MCP Tool",description:"Generated output label: MCP Tool"},"composition.apiOverview.output.openapi":{value:"OpenAPI Spec",description:"Generated output label: OpenAPI"},"composition.socialClip.cta":{value:"Learn more",description:"SocialClip default CTA"},"composition.terminal.title":{value:"Terminal",description:"TerminalDemo default window title"}}});import{defineTranslation as O}from"@contractspec/lib.contracts-spec/translations";var I=O({meta:{key:"video-gen.messages",version:"1.0.0",domain:"video-gen",description:"Spanish translations for the video-gen package",owners:["platform"],stability:"experimental"},locale:"es",fallback:"en",messages:{"prompt.script.system":{value:`Eres un redactor de guiones de narración para vídeo.
|
|
29
|
+
Escribe un guión de narración para un vídeo corto (30-60 segundos).
|
|
30
|
+
{styleGuide}
|
|
31
|
+
|
|
32
|
+
Devuelve JSON con la forma:
|
|
33
|
+
{
|
|
34
|
+
"segments": [{ "sceneId": string, "text": string }],
|
|
35
|
+
"fullText": string
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
Los identificadores de escena deben ser: "intro", "problems", "solutions", "metrics", "cta".
|
|
39
|
+
Incluye solo los segmentos relevantes para el brief.`,description:"Script generator LLM system prompt",placeholders:[{name:"styleGuide",type:"string"}]},"prompt.scenePlanner.system":{value:`Eres un planificador de escenas de vídeo para vídeos de marketing/documentación de ContractSpec.
|
|
40
|
+
Dado un brief de contenido, divídelo en escenas de vídeo.
|
|
41
|
+
|
|
42
|
+
Cada escena debe tener:
|
|
43
|
+
- compositionId: uno de "ApiOverview", "SocialClip", "TerminalDemo"
|
|
44
|
+
- props: las propiedades de entrada de esa composición
|
|
45
|
+
- durationInFrames: duración a {fps} fps
|
|
46
|
+
- narrationText: lo que dice el narrador durante esta escena
|
|
47
|
+
|
|
48
|
+
Devuelve un objeto JSON con la forma:
|
|
49
|
+
{
|
|
50
|
+
"scenes": [{ "compositionId": string, "props": object, "durationInFrames": number, "narrationText": string }],
|
|
51
|
+
"narrationScript": string
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
Mantén la duración total alrededor de {targetSeconds} segundos.
|
|
55
|
+
Prioriza la claridad y el ritmo. Cada escena debe comunicar una idea.`,description:"Scene planner LLM system prompt",placeholders:[{name:"fps",type:"number"},{name:"targetSeconds",type:"number"}]},"prompt.style.professional":{value:"Usa un tono claro, autoritario y profesional. Sé conciso y directo.",description:"Style guide for professional narration"},"prompt.style.casual":{value:"Usa un tono amigable y conversacional. Sé accesible y cercano.",description:"Style guide for casual narration"},"prompt.style.technical":{value:"Usa un lenguaje técnico preciso. Sé detallado y exacto.",description:"Style guide for technical narration"},"script.segment.challenge":{value:"El desafío: {content}",description:"Narration segment prefix for problems",placeholders:[{name:"content",type:"string"}]},"script.segment.solution":{value:"La solución: {content}",description:"Narration segment prefix for solutions",placeholders:[{name:"content",type:"string"}]},"script.segment.results":{value:"Los resultados: {content}",description:"Narration segment prefix for metrics",placeholders:[{name:"content",type:"string"}]},"scene.cta.default":{value:"Más información",description:"Default call-to-action text for scenes"},"scene.hook.problem":{value:"El problema",description:"Scene hook label for problem statement"},"scene.narration.problem":{value:"El problema: {content}",description:"Scene narration for problem statement",placeholders:[{name:"content",type:"string"}]},"scene.hook.solution":{value:"La solución",description:"Scene hook label for solution"},"scene.narration.solution":{value:"La solución: {content}",description:"Scene narration for solution",placeholders:[{name:"content",type:"string"}]},"scene.hook.results":{value:"Resultados",description:"Scene hook label for results/metrics"},"composition.apiOverview.generates":{value:"Genera:",description:"ApiOverview heading for generated outputs"},"composition.apiOverview.tagline":{value:"Una spec. Todas las superficies.",description:"ApiOverview default tagline"},"composition.apiOverview.output.rest":{value:"Endpoint REST",description:"Generated output label: REST"},"composition.apiOverview.output.graphql":{value:"Mutación GraphQL",description:"Generated output label: GraphQL"},"composition.apiOverview.output.prisma":{value:"Modelo Prisma",description:"Generated output label: Prisma"},"composition.apiOverview.output.typescript":{value:"SDK TypeScript",description:"Generated output label: TypeScript SDK"},"composition.apiOverview.output.mcp":{value:"Herramienta MCP",description:"Generated output label: MCP Tool"},"composition.apiOverview.output.openapi":{value:"Spec OpenAPI",description:"Generated output label: OpenAPI"},"composition.socialClip.cta":{value:"Más información",description:"SocialClip default CTA"},"composition.terminal.title":{value:"Terminal",description:"TerminalDemo default window title"}}});import{defineTranslation as S}from"@contractspec/lib.contracts-spec/translations";var Y=S({meta:{key:"video-gen.messages",version:"1.0.0",domain:"video-gen",description:"French translations for the video-gen package",owners:["platform"],stability:"experimental"},locale:"fr",fallback:"en",messages:{"prompt.script.system":{value:`Vous êtes un rédacteur de scripts de narration vidéo.
|
|
56
|
+
Écrivez un script de narration pour une courte vidéo (30-60 secondes).
|
|
57
|
+
{styleGuide}
|
|
58
|
+
|
|
59
|
+
Retournez du JSON avec la forme :
|
|
60
|
+
{
|
|
61
|
+
"segments": [{ "sceneId": string, "text": string }],
|
|
62
|
+
"fullText": string
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
Les identifiants de scène doivent être : "intro", "problems", "solutions", "metrics", "cta".
|
|
66
|
+
N'incluez que les segments pertinents au brief.`,description:"Script generator LLM system prompt",placeholders:[{name:"styleGuide",type:"string"}]},"prompt.scenePlanner.system":{value:`Vous êtes un planificateur de scènes vidéo pour les vidéos marketing/documentation de ContractSpec.
|
|
67
|
+
À partir d'un brief, décomposez-le en scènes vidéo.
|
|
68
|
+
|
|
69
|
+
Chaque scène doit avoir :
|
|
70
|
+
- compositionId : un parmi "ApiOverview", "SocialClip", "TerminalDemo"
|
|
71
|
+
- props : les propriétés d'entrée de cette composition
|
|
72
|
+
- durationInFrames : durée à {fps} fps
|
|
73
|
+
- narrationText : ce que le narrateur dit pendant cette scène
|
|
74
|
+
|
|
75
|
+
Retournez un objet JSON avec la forme :
|
|
76
|
+
{
|
|
77
|
+
"scenes": [{ "compositionId": string, "props": object, "durationInFrames": number, "narrationText": string }],
|
|
78
|
+
"narrationScript": string
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
Gardez la durée totale autour de {targetSeconds} secondes.
|
|
82
|
+
Privilégiez la clarté et le rythme. Chaque scène doit communiquer une idée.`,description:"Scene planner LLM system prompt",placeholders:[{name:"fps",type:"number"},{name:"targetSeconds",type:"number"}]},"prompt.style.professional":{value:"Utilisez un ton clair, autoritaire et professionnel. Soyez concis et direct.",description:"Style guide for professional narration"},"prompt.style.casual":{value:"Utilisez un ton amical et conversationnel. Soyez accessible et proche.",description:"Style guide for casual narration"},"prompt.style.technical":{value:"Utilisez un langage technique précis. Soyez détaillé et exact.",description:"Style guide for technical narration"},"script.segment.challenge":{value:"Le défi : {content}",description:"Narration segment prefix for problems",placeholders:[{name:"content",type:"string"}]},"script.segment.solution":{value:"La solution : {content}",description:"Narration segment prefix for solutions",placeholders:[{name:"content",type:"string"}]},"script.segment.results":{value:"Les résultats : {content}",description:"Narration segment prefix for metrics",placeholders:[{name:"content",type:"string"}]},"scene.cta.default":{value:"En savoir plus",description:"Default call-to-action text for scenes"},"scene.hook.problem":{value:"Le problème",description:"Scene hook label for problem statement"},"scene.narration.problem":{value:"Le problème : {content}",description:"Scene narration for problem statement",placeholders:[{name:"content",type:"string"}]},"scene.hook.solution":{value:"La solution",description:"Scene hook label for solution"},"scene.narration.solution":{value:"La solution : {content}",description:"Scene narration for solution",placeholders:[{name:"content",type:"string"}]},"scene.hook.results":{value:"Résultats",description:"Scene hook label for results/metrics"},"composition.apiOverview.generates":{value:"Génère :",description:"ApiOverview heading for generated outputs"},"composition.apiOverview.tagline":{value:"Un spec. Toutes les surfaces.",description:"ApiOverview default tagline"},"composition.apiOverview.output.rest":{value:"Endpoint REST",description:"Generated output label: REST"},"composition.apiOverview.output.graphql":{value:"Mutation GraphQL",description:"Generated output label: GraphQL"},"composition.apiOverview.output.prisma":{value:"Modèle Prisma",description:"Generated output label: Prisma"},"composition.apiOverview.output.typescript":{value:"SDK TypeScript",description:"Generated output label: TypeScript SDK"},"composition.apiOverview.output.mcp":{value:"Outil MCP",description:"Generated output label: MCP Tool"},"composition.apiOverview.output.openapi":{value:"Spec OpenAPI",description:"Generated output label: OpenAPI"},"composition.socialClip.cta":{value:"En savoir plus",description:"SocialClip default CTA"},"composition.terminal.title":{value:"Terminal",description:"TerminalDemo default window title"}}});var X={"prompt.script.system":"prompt.script.system","prompt.scenePlanner.system":"prompt.scenePlanner.system","prompt.style.professional":"prompt.style.professional","prompt.style.casual":"prompt.style.casual","prompt.style.technical":"prompt.style.technical"},h={"script.segment.challenge":"script.segment.challenge","script.segment.solution":"script.segment.solution","script.segment.results":"script.segment.results"},R={"scene.cta.default":"scene.cta.default","scene.hook.problem":"scene.hook.problem","scene.narration.problem":"scene.narration.problem","scene.hook.solution":"scene.hook.solution","scene.narration.solution":"scene.narration.solution","scene.hook.results":"scene.hook.results"},U={"composition.apiOverview.generates":"composition.apiOverview.generates","composition.apiOverview.tagline":"composition.apiOverview.tagline","composition.apiOverview.output.rest":"composition.apiOverview.output.rest","composition.apiOverview.output.graphql":"composition.apiOverview.output.graphql","composition.apiOverview.output.prisma":"composition.apiOverview.output.prisma","composition.apiOverview.output.typescript":"composition.apiOverview.output.typescript","composition.apiOverview.output.mcp":"composition.apiOverview.output.mcp","composition.apiOverview.output.openapi":"composition.apiOverview.output.openapi","composition.socialClip.cta":"composition.socialClip.cta","composition.terminal.title":"composition.terminal.title"},v={...X,...h,...R,...U};import{DEFAULT_LOCALE as A,isSupportedLocale as D,resolveLocale as m,SUPPORTED_LOCALES as T}from"@contractspec/lib.contracts-spec/translations";import{createI18nFactory as g}from"@contractspec/lib.contracts-spec/translations";var y=g({specKey:"video-gen.messages",catalogs:[$,Y,I]}),E=y.create,j=y.getDefault,F=y.resetRegistry;class V{llm;model;temperature;fps;i18n;modelSelector;selectionContext;constructor(x){this.llm=x?.llm,this.model=x?.model,this.temperature=x?.temperature??0.3,this.fps=x?.fps??Q,this.i18n=E(x?.locale),this.modelSelector=x?.modelSelector,this.selectionContext=x?.selectionContext}async plan(x){if(this.llm)return this.planWithLlm(x);return this.planDeterministic(x)}planDeterministic(x){let{content:G}=x,{t:K}=this.i18n,L=[],z=this.fps;if(L.push({compositionId:"SocialClip",props:{hook:G.title,message:G.summary,points:G.solutions.slice(0,3),cta:G.callToAction??K("scene.cta.default")},durationInFrames:3*z,narrationText:`${G.title}. ${G.summary}`}),G.problems.length>0)L.push({compositionId:"SocialClip",props:{hook:K("scene.hook.problem"),message:G.problems[0]??"",points:G.problems.slice(1,4)},durationInFrames:4*z,narrationText:K("scene.narration.problem",{content:G.problems.join(". ")})});if(G.solutions.length>0)L.push({compositionId:"SocialClip",props:{hook:K("scene.hook.solution"),message:G.solutions[0]??"",points:G.solutions.slice(1,4)},durationInFrames:5*z,narrationText:K("scene.narration.solution",{content:G.solutions.join(". ")})});if(G.metrics&&G.metrics.length>0)L.push({compositionId:"SocialClip",props:{hook:K("scene.hook.results"),message:G.metrics[0]??"",points:G.metrics.slice(1,3)},durationInFrames:3*z,narrationText:G.metrics.join(". ")});if(G.callToAction)L.push({compositionId:"SocialClip",props:{hook:G.callToAction,message:"",cta:G.callToAction},durationInFrames:2*z,narrationText:G.callToAction});if(x.targetDurationSeconds){let N=x.targetDurationSeconds*z,q=L.reduce((C,k)=>C+k.durationInFrames,0),H=N/q;for(let C of L)C.durationInFrames=Math.round(C.durationInFrames*H)}let w=L.reduce((N,q)=>N+q.durationInFrames,0),B=L.filter((N)=>N.narrationText).map((N)=>N.narrationText).join(" ");return{scenes:L,estimatedDurationSeconds:w/z,narrationScript:B}}async resolveModel(){if(this.model)return this.model;if(this.modelSelector){let x=this.selectionContext??{taskDimension:"reasoning"};return(await this.modelSelector.select(x)).modelId}return}async planWithLlm(x){let{t:G}=this.i18n,K=[{role:"system",content:[{type:"text",text:G("prompt.scenePlanner.system",{fps:this.fps,targetSeconds:x.targetDurationSeconds??30})}]},{role:"user",content:[{type:"text",text:JSON.stringify(x.content)}]}];if(!this.llm)return this.planDeterministic(x);try{let L=await this.resolveModel(),w=(await this.llm.chat(K,{model:L,temperature:this.temperature,responseFormat:"json"})).message.content.find((q)=>q.type==="text");if(!w||w.type!=="text")return this.planDeterministic(x);let B=JSON.parse(w.text),N=B.scenes.reduce((q,H)=>q+H.durationInFrames,0);return{scenes:B.scenes,estimatedDurationSeconds:N/this.fps,narrationScript:B.narrationScript}}catch{return this.planDeterministic(x)}}}import{VIDEO_FORMATS as P}from"@contractspec/lib.contracts-integrations/integrations/providers/video";class Z{scenePlanner;voice;transcriber;image;fps;constructor(x){this.fps=x?.fps??Q,this.voice=x?.voice,this.transcriber=x?.transcriber,this.image=x?.image,this.scenePlanner=new V({llm:x?.llm,model:x?.model,temperature:x?.temperature,fps:this.fps,locale:x?.locale,modelSelector:x?.modelSelector,selectionContext:x?.selectionContext})}async generate(x){let G=await this.scenePlanner.plan(x),K=G.scenes.map((C,k)=>({id:`scene-${k}`,compositionId:C.compositionId,props:C.props,durationInFrames:C.durationInFrames,narrationText:C.narrationText})),L,z;if(x.narration?.enabled&&this.voice)try{if(L=await this.voice.synthesizeForVideo({content:x.content,scenePlan:{scenes:K.map((C)=>({id:C.id,compositionId:C.compositionId,durationInFrames:C.durationInFrames,narrationText:C.narrationText})),estimatedDurationSeconds:G.estimatedDurationSeconds},voice:{voiceId:x.narration.voiceId??""},pacing:{strategy:"scene-matched"},fps:this.fps}),L.timingMap)for(let C of L.timingMap.segments){let k=K.find((_)=>_.id===C.sceneId);if(k)k.durationInFrames=C.recommendedSceneDurationInFrames}if(L.assembledAudio)z={data:L.assembledAudio.data,format:L.assembledAudio.format==="wav"?"wav":"mp3",durationSeconds:(L.assembledAudio.durationMs??0)/1000,volume:1}}catch{}let w;if(this.transcriber&&L?.assembledAudio)try{w=(await this.transcriber.transcribe({audio:L.assembledAudio,subtitleFormat:"vtt"})).subtitles}catch{}let B;if(this.image)try{let C=await this.image.generate({content:x.content,purpose:"video-thumbnail",format:"png",style:"photorealistic"}),k=C.results?.images[0]?.url;B={prompt:C.prompt.text,...k?{imageUrl:k}:{}}}catch{}let N=x.format??P.landscape,q=K.reduce((C,k)=>C+k.durationInFrames,0);return{id:u(),scenes:K,totalDurationInFrames:q,fps:this.fps,format:N,audio:z?{narration:z}:void 0,subtitles:w,voiceTimingMap:L?.timingMap,thumbnail:B}}}function u(){let x=Date.now().toString(36),G=Math.random().toString(36).slice(2,8);return`vp_${x}_${G}`}export{Z as VideoGenerator,V as ScenePlanner};
|