@lssm-tech/lib.video-gen 3.0.10 → 5.0.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/README.md +8 -8
- package/package.json +240 -328
- package/dist/browser/compositions/api-overview.js +0 -1
- package/dist/browser/compositions/index.js +0 -1
- package/dist/browser/compositions/primitives/animated-text.js +0 -1
- package/dist/browser/compositions/primitives/brand-frame.js +0 -1
- package/dist/browser/compositions/primitives/code-block.js +0 -1
- package/dist/browser/compositions/primitives/index.js +0 -1
- package/dist/browser/compositions/primitives/progress-bar.js +0 -1
- package/dist/browser/compositions/primitives/terminal.js +0 -1
- package/dist/browser/compositions/primitives/transition.js +0 -1
- package/dist/browser/compositions/social-clip.js +0 -1
- package/dist/browser/compositions/terminal-demo.js +0 -1
- package/dist/browser/design/index.js +0 -1
- package/dist/browser/design/layouts.js +0 -1
- package/dist/browser/design/motion.js +0 -1
- package/dist/browser/design/tokens.js +0 -1
- package/dist/browser/design/typography.js +0 -1
- package/dist/browser/docs/compositions.docblock.js +0 -1
- package/dist/browser/docs/design.docblock.js +0 -172
- package/dist/browser/docs/generators.docblock.js +0 -165
- package/dist/browser/docs/rendering.docblock.js +0 -175
- package/dist/browser/docs/video-gen.docblock.js +0 -126
- package/dist/browser/generators/index.js +0 -82
- package/dist/browser/generators/scene-planner.js +0 -82
- package/dist/browser/generators/script-generator.js +0 -82
- package/dist/browser/generators/video-generator.js +0 -82
- package/dist/browser/i18n/catalogs/en.js +0 -28
- package/dist/browser/i18n/catalogs/es.js +0 -28
- package/dist/browser/i18n/catalogs/fr.js +0 -28
- package/dist/browser/i18n/catalogs/index.js +0 -82
- package/dist/browser/i18n/index.js +0 -82
- package/dist/browser/i18n/keys.js +0 -1
- package/dist/browser/i18n/locale.js +0 -1
- package/dist/browser/i18n/messages.js +0 -82
- package/dist/browser/index.js +0 -82
- package/dist/browser/player/demo-player.js +0 -1
- package/dist/browser/player/index.js +0 -1
- package/dist/browser/remotion/Root.js +0 -19
- package/dist/browser/remotion/index.js +0 -19
- package/dist/browser/renderers/config.js +0 -1
- package/dist/browser/renderers/index.js +0 -1
- package/dist/browser/renderers/local.js +0 -1
- package/dist/browser/types.js +0 -1
- package/dist/browser/video-gen.feature.js +0 -1
- package/dist/compositions/api-overview.d.ts +0 -16
- package/dist/compositions/api-overview.js +0 -2
- package/dist/compositions/index.d.ts +0 -7
- package/dist/compositions/index.js +0 -2
- package/dist/compositions/primitives/animated-text.d.ts +0 -22
- package/dist/compositions/primitives/animated-text.js +0 -2
- package/dist/compositions/primitives/brand-frame.d.ts +0 -14
- package/dist/compositions/primitives/brand-frame.js +0 -2
- package/dist/compositions/primitives/code-block.d.ts +0 -18
- package/dist/compositions/primitives/code-block.js +0 -2
- package/dist/compositions/primitives/index.d.ts +0 -12
- package/dist/compositions/primitives/index.js +0 -2
- package/dist/compositions/primitives/progress-bar.d.ts +0 -12
- package/dist/compositions/primitives/progress-bar.js +0 -2
- package/dist/compositions/primitives/terminal.d.ts +0 -24
- package/dist/compositions/primitives/terminal.js +0 -2
- package/dist/compositions/primitives/transition.d.ts +0 -14
- package/dist/compositions/primitives/transition.js +0 -2
- package/dist/compositions/social-clip.d.ts +0 -16
- package/dist/compositions/social-clip.js +0 -2
- package/dist/compositions/terminal-demo.d.ts +0 -17
- package/dist/compositions/terminal-demo.js +0 -2
- package/dist/design/index.d.ts +0 -4
- package/dist/design/index.js +0 -2
- package/dist/design/layouts.d.ts +0 -69
- package/dist/design/layouts.js +0 -2
- package/dist/design/motion.d.ts +0 -72
- package/dist/design/motion.js +0 -2
- package/dist/design/tokens.d.ts +0 -31
- package/dist/design/tokens.js +0 -2
- package/dist/design/typography.d.ts +0 -61
- package/dist/design/typography.js +0 -2
- package/dist/docs/compositions.docblock.d.ts +0 -1
- package/dist/docs/compositions.docblock.js +0 -2
- package/dist/docs/design.docblock.d.ts +0 -1
- package/dist/docs/design.docblock.js +0 -173
- package/dist/docs/generators.docblock.d.ts +0 -1
- package/dist/docs/generators.docblock.js +0 -166
- package/dist/docs/rendering.docblock.d.ts +0 -1
- package/dist/docs/rendering.docblock.js +0 -176
- package/dist/docs/video-gen.docblock.d.ts +0 -1
- package/dist/docs/video-gen.docblock.js +0 -127
- package/dist/generators/index.d.ts +0 -3
- package/dist/generators/index.js +0 -83
- package/dist/generators/scene-planner.d.ts +0 -31
- package/dist/generators/scene-planner.js +0 -83
- package/dist/generators/script-generator.d.ts +0 -57
- package/dist/generators/script-generator.js +0 -83
- package/dist/generators/video-generator.d.ts +0 -21
- package/dist/generators/video-generator.js +0 -83
- package/dist/i18n/catalogs/en.d.ts +0 -8
- package/dist/i18n/catalogs/en.js +0 -29
- package/dist/i18n/catalogs/es.d.ts +0 -6
- package/dist/i18n/catalogs/es.js +0 -29
- package/dist/i18n/catalogs/fr.d.ts +0 -6
- package/dist/i18n/catalogs/fr.js +0 -29
- package/dist/i18n/catalogs/index.d.ts +0 -8
- package/dist/i18n/catalogs/index.js +0 -83
- package/dist/i18n/i18n.test.d.ts +0 -1
- package/dist/i18n/index.d.ts +0 -22
- package/dist/i18n/index.js +0 -83
- package/dist/i18n/keys.d.ts +0 -116
- package/dist/i18n/keys.js +0 -2
- package/dist/i18n/locale.d.ts +0 -8
- package/dist/i18n/locale.js +0 -2
- package/dist/i18n/messages.d.ts +0 -14
- package/dist/i18n/messages.js +0 -83
- package/dist/index.d.ts +0 -7
- package/dist/index.js +0 -83
- package/dist/node/compositions/api-overview.js +0 -1
- package/dist/node/compositions/index.js +0 -1
- package/dist/node/compositions/primitives/animated-text.js +0 -1
- package/dist/node/compositions/primitives/brand-frame.js +0 -1
- package/dist/node/compositions/primitives/code-block.js +0 -1
- package/dist/node/compositions/primitives/index.js +0 -1
- package/dist/node/compositions/primitives/progress-bar.js +0 -1
- package/dist/node/compositions/primitives/terminal.js +0 -1
- package/dist/node/compositions/primitives/transition.js +0 -1
- package/dist/node/compositions/social-clip.js +0 -1
- package/dist/node/compositions/terminal-demo.js +0 -1
- package/dist/node/design/index.js +0 -1
- package/dist/node/design/layouts.js +0 -1
- package/dist/node/design/motion.js +0 -1
- package/dist/node/design/tokens.js +0 -1
- package/dist/node/design/typography.js +0 -1
- package/dist/node/docs/compositions.docblock.js +0 -1
- package/dist/node/docs/design.docblock.js +0 -172
- package/dist/node/docs/generators.docblock.js +0 -165
- package/dist/node/docs/rendering.docblock.js +0 -175
- package/dist/node/docs/video-gen.docblock.js +0 -126
- package/dist/node/generators/index.js +0 -82
- package/dist/node/generators/scene-planner.js +0 -82
- package/dist/node/generators/script-generator.js +0 -82
- package/dist/node/generators/video-generator.js +0 -82
- package/dist/node/i18n/catalogs/en.js +0 -28
- package/dist/node/i18n/catalogs/es.js +0 -28
- package/dist/node/i18n/catalogs/fr.js +0 -28
- package/dist/node/i18n/catalogs/index.js +0 -82
- package/dist/node/i18n/index.js +0 -82
- package/dist/node/i18n/keys.js +0 -1
- package/dist/node/i18n/locale.js +0 -1
- package/dist/node/i18n/messages.js +0 -82
- package/dist/node/index.js +0 -82
- package/dist/node/player/demo-player.js +0 -1
- package/dist/node/player/index.js +0 -1
- package/dist/node/remotion/Root.js +0 -19
- package/dist/node/remotion/index.js +0 -19
- package/dist/node/renderers/config.js +0 -1
- package/dist/node/renderers/index.js +0 -1
- package/dist/node/renderers/local.js +0 -1
- package/dist/node/types.js +0 -1
- package/dist/node/video-gen.feature.js +0 -1
- package/dist/player/demo-player.d.ts +0 -55
- package/dist/player/demo-player.js +0 -2
- package/dist/player/index.d.ts +0 -2
- package/dist/player/index.js +0 -2
- package/dist/remotion/Root.d.ts +0 -2
- package/dist/remotion/Root.js +0 -20
- package/dist/remotion/index.d.ts +0 -1
- package/dist/remotion/index.js +0 -20
- package/dist/renderers/config.d.ts +0 -28
- package/dist/renderers/config.js +0 -2
- package/dist/renderers/index.d.ts +0 -3
- package/dist/renderers/index.js +0 -2
- package/dist/renderers/local.d.ts +0 -17
- package/dist/renderers/local.js +0 -2
- package/dist/types.d.ts +0 -85
- package/dist/types.js +0 -2
- package/dist/video-gen.feature.d.ts +0 -1
- package/dist/video-gen.feature.js +0 -2
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{registerDocBlocks as f}from"@contractspec/lib.contracts-spec/docs";var h=[{id:"docs.video-gen.compositions",title:"Video Compositions & Primitives",summary:"Remotion composition components and reusable primitives for building programmatic videos.",kind:"reference",visibility:"public",route:"/docs/video-gen/compositions",tags:["video","remotion","compositions","primitives","react"],owners:["@contractspec/lib.video-gen"],body:'# Video Compositions & Primitives\n\nCompositions are React components rendered by Remotion. They use `useCurrentFrame()`, `useVideoConfig()`, and `interpolate()` to produce frame-accurate animations. All compositions must be **deterministic**: same props = same visual output.\n\n## Primitive Components\n\nPrimitives are reusable building blocks for constructing full compositions.\n\n```ts\nimport {\n AnimatedText,\n CodeBlock,\n Terminal,\n BrandFrame,\n ProgressBar,\n SceneTransitionWrapper,\n} from "@contractspec/lib.video-gen/compositions/primitives";\n```\n\n### AnimatedText\n\nText with entrance/exit slide + fade animations.\n\n| Prop | Type | Default | Description |\n|------|------|---------|-------------|\n| `text` | `string` | -- | Text content |\n| `variant` | `keyof videoTypography` | `"body"` | Typography preset (title, heading, subheading, body, code, caption, label) |\n| `enterAt` | `number` | `0` | Frame at which text enters |\n| `exitAt` | `number` | -- | Frame at which text exits (omit to keep visible) |\n| `color` | `string` | `"#ffffff"` | Text color |\n| `align` | `"left" \\| "center" \\| "right"` | `"left"` | Text alignment |\n\n### CodeBlock\n\nSyntax-aware code display with typing animation and macOS-style title bar.\n\n| Prop | Type | Default | Description |\n|------|------|---------|-------------|\n| `code` | `string` | -- | Code string to display |\n| `language` | `string` | `"typescript"` | Language label in the title bar |\n| `startAt` | `number` | `0` | Frame at which typing starts |\n| `typeAnimation` | `boolean` | `true` | Animate character-by-character typing |\n| `filename` | `string` | -- | Filename in the title bar (overrides language) |\n\n### Terminal\n\nCLI simulator with command typing, output lines, and cursor animation.\n\n| Prop | Type | Default | Description |\n|------|------|---------|-------------|\n| `lines` | `TerminalLine[]` | -- | Lines to display in sequence |\n| `startAt` | `number` | `0` | Frame at which terminal appears |\n| `prompt` | `string` | `"$ "` | Prompt string before commands |\n| `title` | `string` | `"Terminal"` | Title bar text |\n| `typingSpeed` | `number` | `2` | Frames per character for commands |\n\n`TerminalLine` types: `command` (typed), `output` (faded in), `error` (red), `success` (green), `comment` (dimmed with `#` prefix).\n\n### BrandFrame\n\nBranded container with safe-zone padding, gradient/solid/dark backgrounds, and optional watermark.\n\n| Prop | Type | Default | Description |\n|------|------|---------|-------------|\n| `variant` | `"solid" \\| "gradient" \\| "dark"` | `"gradient"` | Background style |\n| `showBranding` | `boolean` | `true` | Show "ContractSpec" watermark |\n| `animateEntrance` | `boolean` | `true` | Fade-in on first frames |\n| `styleOverrides` | `VideoStyleOverrides` | -- | Override colors, fonts, dark mode |\n\n### ProgressBar\n\nThin progress indicator at the top or bottom of the frame.\n\n| Prop | Type | Default | Description |\n|------|------|---------|-------------|\n| `height` | `number` | `4` | Bar height in pixels |\n| `color` | `string` | primary color | Bar fill color |\n| `position` | `"top" \\| "bottom"` | `"bottom"` | Placement |\n\n### SceneTransitionWrapper\n\nWraps children with entrance/exit transitions (fade, slide-left, slide-right, wipe).\n\n| Prop | Type | Default | Description |\n|------|------|---------|-------------|\n| `type` | `SceneTransitionType` | -- | Transition type |\n| `durationInFrames` | `number` | -- | Transition duration |\n| `direction` | `"in" \\| "out"` | -- | Entering or exiting |\n\n## Full Compositions\n\nFull compositions combine primitives into complete video templates. They are registered in Remotion Studio via `RemotionRoot`.\n\n### ApiOverview\n\nVisualizes a ContractSpec definition generating a full API surface. Used for homepage demos and documentation.\n\n```tsx\nimport { ApiOverview } from "@contractspec/lib.video-gen/compositions/api-overview";\n\n<ApiOverview\n specName="CreateUser"\n method="POST"\n endpoint="/api/users"\n specCode={`export const createUser = defineCommand({...})`}\n generatedOutputs={["REST Endpoint", "GraphQL Mutation", "Prisma Model"]}\n tagline="One spec. Every surface."\n/>\n```\n\n**Scenes**: Title + method badge -> Code typing animation -> Generated outputs fan-out -> Tagline.\n\n### SocialClip\n\nShort-form marketing content for LinkedIn, X, YouTube Shorts. Adapts layout for landscape (16:9), square (1:1), and portrait (9:16).\n\n```tsx\nimport { SocialClip } from "@contractspec/lib.video-gen/compositions/social-clip";\n\n<SocialClip\n hook="Stop rewriting the same API logic."\n message="Generate REST, GraphQL, DB, SDK from a single spec."\n points={["Deterministic output", "Fully ejectable", "No lock-in"]}\n cta="Try ContractSpec"\n ctaUrl="contractspec.dev"\n/>\n```\n\n**Scenes**: Hook (attention grabber) -> Main message -> Supporting points -> CTA button.\n\n### TerminalDemo\n\nCLI command walkthrough with animated terminal. Used in documentation and tutorial videos.\n\n```tsx\nimport { TerminalDemo } from "@contractspec/lib.video-gen/compositions/terminal-demo";\n\n<TerminalDemo\n title="Getting Started with ContractSpec"\n subtitle="Define once, generate everything."\n lines={[\n { type: "command", text: "npx contractspec init my-api" },\n { type: "output", text: "Created my-api/ with 3 sample contracts" },\n { type: "command", text: "npx contractspec build" },\n { type: "success", text: "Built 3 contracts -> 18 generated files" },\n ]}\n summary="Ship faster. Stay coherent."\n/>\n```\n\n**Scenes**: Title + subtitle -> Terminal typing animation -> Summary.\n\n## Creating New Compositions\n\n1. Create a new `.tsx` file in `src/compositions/`.\n2. Use primitives from `./primitives/` and design tokens from `../design/`.\n3. Use `useCurrentFrame()` and `interpolate()` for frame-based animations.\n4. Register in `src/remotion/Root.tsx` with a `<Composition>` entry.\n5. Export from `src/compositions/index.ts`.\n6. Add the export path to `package.json` (both workspace and publishConfig).\n\n### Guardrails\n\n- Keep compositions **pure**: no side effects, no network calls, no randomness.\n- Use `scaleSafeZone()` and `scaleTypography()` to support multiple formats.\n- All timing should be frame-based (not time-based) for deterministic output.\n'}];f(h);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{registerDocBlocks as f}from"@contractspec/lib.contracts-spec/docs";var h=[{id:"docs.video-gen.design",title:"Video Design System",summary:"Design tokens, motion primitives, typography scale, and layout system optimized for programmatic video.",kind:"reference",visibility:"public",route:"/docs/video-gen/design",tags:["video","design-tokens","motion","typography","layout"],owners:["@contractspec/lib.video-gen"],body:`# Video Design System
|
|
3
|
-
|
|
4
|
-
The design layer bridges \`@contractspec/lib.design-system\` brand tokens with video-specific extensions for motion, typography, and spatial layout. All values are optimized for 1920x1080 (landscape) and scale proportionally for other formats.
|
|
5
|
-
|
|
6
|
-
\`\`\`ts
|
|
7
|
-
import {
|
|
8
|
-
defaultVideoTheme,
|
|
9
|
-
videoEasing,
|
|
10
|
-
videoDurations,
|
|
11
|
-
videoTypography,
|
|
12
|
-
videoSafeZone,
|
|
13
|
-
scaleSafeZone,
|
|
14
|
-
} from "@contractspec/lib.video-gen/design";
|
|
15
|
-
\`\`\`
|
|
16
|
-
|
|
17
|
-
## Tokens
|
|
18
|
-
|
|
19
|
-
### Brand Bridge
|
|
20
|
-
|
|
21
|
-
\`VideoThemeTokens\` extends the design-system \`ThemeTokens\` with a \`video\` namespace for video-specific colors:
|
|
22
|
-
|
|
23
|
-
\`\`\`ts
|
|
24
|
-
import { defaultVideoTheme } from "@contractspec/lib.video-gen/design/tokens";
|
|
25
|
-
|
|
26
|
-
// Brand tokens (from @contractspec/lib.design-system)
|
|
27
|
-
defaultVideoTheme.colors.primary; // brand primary
|
|
28
|
-
defaultVideoTheme.colors.accent; // brand accent
|
|
29
|
-
|
|
30
|
-
// Video-specific extensions
|
|
31
|
-
defaultVideoTheme.video.canvasBackground; // frame background
|
|
32
|
-
defaultVideoTheme.video.codeBackground; // "#1e1e2e"
|
|
33
|
-
defaultVideoTheme.video.terminalBackground; // "#0d1117"
|
|
34
|
-
defaultVideoTheme.video.terminalForeground; // "#c9d1d9"
|
|
35
|
-
defaultVideoTheme.video.highlight; // accent color
|
|
36
|
-
defaultVideoTheme.video.gradientStart; // primary
|
|
37
|
-
defaultVideoTheme.video.gradientEnd; // accent
|
|
38
|
-
\`\`\`
|
|
39
|
-
|
|
40
|
-
> Do not duplicate brand color values. Import and extend from \`@contractspec/lib.design-system\`.
|
|
41
|
-
|
|
42
|
-
## Motion
|
|
43
|
-
|
|
44
|
-
### Easing Functions
|
|
45
|
-
|
|
46
|
-
Pre-configured easing curves for use with Remotion's \`interpolate()\`:
|
|
47
|
-
|
|
48
|
-
| Key | Easing | Use Case |
|
|
49
|
-
|-----|--------|----------|
|
|
50
|
-
| \`entrance\` | \`Easing.out(Easing.exp)\` | Objects appearing |
|
|
51
|
-
| \`exit\` | \`Easing.in(Easing.exp)\` | Objects disappearing |
|
|
52
|
-
| \`emphasis\` | \`Easing.out(Easing.back(1.4))\` | Drawing attention, bounce |
|
|
53
|
-
| \`linear\` | \`Easing.linear\` | Progress bars, typing |
|
|
54
|
-
| \`gentle\` | \`Easing.bezier(0.25, 0.1, 0.25, 1)\` | Subtle movements |
|
|
55
|
-
| \`spring\` | \`Easing.out(Easing.back(1.7))\` | Playful movements |
|
|
56
|
-
|
|
57
|
-
\`\`\`ts
|
|
58
|
-
import { interpolate } from "remotion";
|
|
59
|
-
import { videoEasing } from "@contractspec/lib.video-gen/design/motion";
|
|
60
|
-
|
|
61
|
-
const opacity = interpolate(frame, [0, 15], [0, 1], {
|
|
62
|
-
easing: videoEasing.entrance,
|
|
63
|
-
extrapolateLeft: "clamp",
|
|
64
|
-
extrapolateRight: "clamp",
|
|
65
|
-
});
|
|
66
|
-
\`\`\`
|
|
67
|
-
|
|
68
|
-
### Durations (frames at 30fps)
|
|
69
|
-
|
|
70
|
-
| Key | Frames | Seconds | Use Case |
|
|
71
|
-
|-----|--------|---------|----------|
|
|
72
|
-
| \`sceneTransition\` | 20 | 0.67s | Between scenes |
|
|
73
|
-
| \`textEntrance\` | 15 | 0.5s | Text slide-in |
|
|
74
|
-
| \`textExit\` | 12 | 0.4s | Text slide-out |
|
|
75
|
-
| \`codeTypingPerChar\` | 2 | 0.07s | Code typing speed |
|
|
76
|
-
| \`sectionPause\` | 30 | 1.0s | Pause after concept |
|
|
77
|
-
| \`emphasisPause\` | 15 | 0.5s | Brief emphasis |
|
|
78
|
-
| \`brandReveal\` | 25 | 0.83s | Logo/watermark |
|
|
79
|
-
| \`minScene\` | 60 | 2.0s | Minimum scene length |
|
|
80
|
-
| \`shortScene\` | 60 | 2.0s | Short scene |
|
|
81
|
-
| \`mediumScene\` | 120 | 4.0s | Medium scene |
|
|
82
|
-
| \`longScene\` | 240 | 8.0s | Long scene |
|
|
83
|
-
|
|
84
|
-
### Transition Presets
|
|
85
|
-
|
|
86
|
-
\`\`\`ts
|
|
87
|
-
import { videoTransitions } from "@contractspec/lib.video-gen/design/motion";
|
|
88
|
-
|
|
89
|
-
// { type: "fade", durationInFrames: 20 }
|
|
90
|
-
videoTransitions.fade;
|
|
91
|
-
|
|
92
|
-
// { type: "slide-left", durationInFrames: 20 }
|
|
93
|
-
videoTransitions.slideLeft;
|
|
94
|
-
\`\`\`
|
|
95
|
-
|
|
96
|
-
## Typography
|
|
97
|
-
|
|
98
|
-
### Type Scale (1920x1080 baseline)
|
|
99
|
-
|
|
100
|
-
| Key | Size | Weight | Use Case |
|
|
101
|
-
|-----|------|--------|----------|
|
|
102
|
-
| \`title\` | 72px | 700 | Main title |
|
|
103
|
-
| \`heading\` | 56px | 600 | Section heading |
|
|
104
|
-
| \`subheading\` | 40px | 500 | Subheading |
|
|
105
|
-
| \`body\` | 32px | 400 | Body text |
|
|
106
|
-
| \`code\` | 28px | 400 | Monospace code |
|
|
107
|
-
| \`caption\` | 24px | 400 | Small caption |
|
|
108
|
-
| \`label\` | 20px | 600 | Badge / label |
|
|
109
|
-
|
|
110
|
-
### Scaling for Other Formats
|
|
111
|
-
|
|
112
|
-
Use \`scaleTypography()\` to proportionally scale for non-landscape formats:
|
|
113
|
-
|
|
114
|
-
\`\`\`ts
|
|
115
|
-
import {
|
|
116
|
-
videoTypography,
|
|
117
|
-
scaleTypography,
|
|
118
|
-
} from "@contractspec/lib.video-gen/design/typography";
|
|
119
|
-
|
|
120
|
-
// Scale heading for 1080x1080 (square)
|
|
121
|
-
const squareHeading = scaleTypography(videoTypography.heading, 1080);
|
|
122
|
-
// -> fontSize: 32, lineHeight: 1.2, fontWeight: 600
|
|
123
|
-
\`\`\`
|
|
124
|
-
|
|
125
|
-
## Layouts
|
|
126
|
-
|
|
127
|
-
### Safe Zones
|
|
128
|
-
|
|
129
|
-
Content-safe padding for text within video frames (1920x1080 baseline):
|
|
130
|
-
|
|
131
|
-
\`\`\`ts
|
|
132
|
-
import {
|
|
133
|
-
videoSafeZone,
|
|
134
|
-
scaleSafeZone,
|
|
135
|
-
} from "@contractspec/lib.video-gen/design/layouts";
|
|
136
|
-
|
|
137
|
-
videoSafeZone.horizontal; // 120px
|
|
138
|
-
videoSafeZone.vertical; // 80px
|
|
139
|
-
videoSafeZone.contentWidth; // 1680px
|
|
140
|
-
videoSafeZone.contentHeight; // 920px
|
|
141
|
-
|
|
142
|
-
// Scale for portrait (1080x1920)
|
|
143
|
-
const portrait = scaleSafeZone({ type: "portrait", width: 1080, height: 1920 });
|
|
144
|
-
\`\`\`
|
|
145
|
-
|
|
146
|
-
### Standard Positions
|
|
147
|
-
|
|
148
|
-
\`\`\`ts
|
|
149
|
-
import { videoPositions } from "@contractspec/lib.video-gen/design/layouts";
|
|
150
|
-
|
|
151
|
-
videoPositions.center; // { x: 960, y: 540 }
|
|
152
|
-
videoPositions.topLeft; // { x: 120, y: 80 }
|
|
153
|
-
videoPositions.bottomRight; // { x: 1800, y: 1000 } -- logos, watermarks
|
|
154
|
-
videoPositions.bottomCenter; // { x: 960, y: 960 } -- captions
|
|
155
|
-
\`\`\`
|
|
156
|
-
|
|
157
|
-
### Format Variants
|
|
158
|
-
|
|
159
|
-
\`\`\`ts
|
|
160
|
-
import {
|
|
161
|
-
VIDEO_FORMATS,
|
|
162
|
-
getAllFormatVariants,
|
|
163
|
-
DEFAULT_FPS,
|
|
164
|
-
} from "@contractspec/lib.video-gen/design/layouts";
|
|
165
|
-
|
|
166
|
-
VIDEO_FORMATS.landscape; // { type: "landscape", width: 1920, height: 1080 }
|
|
167
|
-
VIDEO_FORMATS.portrait; // { type: "portrait", width: 1080, height: 1920 }
|
|
168
|
-
VIDEO_FORMATS.square; // { type: "square", width: 1080, height: 1080 }
|
|
169
|
-
|
|
170
|
-
getAllFormatVariants(); // [landscape, square, portrait]
|
|
171
|
-
DEFAULT_FPS; // 30
|
|
172
|
-
\`\`\`
|
|
173
|
-
`}];f(h);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
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
|
|
3
|
-
|
|
4
|
-
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.
|
|
5
|
-
|
|
6
|
-
\`\`\`
|
|
7
|
-
VideoBrief
|
|
8
|
-
|
|
|
9
|
-
v
|
|
10
|
-
ScenePlanner.plan(brief) --> ScenePlan (scenes + durations)
|
|
11
|
-
|
|
|
12
|
-
v
|
|
13
|
-
ScriptGenerator.generate(brief) --> NarrationScript (text + segments)
|
|
14
|
-
|
|
|
15
|
-
v
|
|
16
|
-
VoiceProvider.synthesize(text) --> AudioTrack (optional)
|
|
17
|
-
|
|
|
18
|
-
v
|
|
19
|
-
VideoGenerator.generate(brief) --> VideoProject (complete scene graph)
|
|
20
|
-
\`\`\`
|
|
21
|
-
|
|
22
|
-
## VideoGenerator
|
|
23
|
-
|
|
24
|
-
The main orchestrator. Wires ScenePlanner, ScriptGenerator, and optional VoiceProvider into a single pipeline.
|
|
25
|
-
|
|
26
|
-
\`\`\`ts
|
|
27
|
-
import { VideoGenerator } from "@contractspec/lib.video-gen/generators";
|
|
28
|
-
import type { VideoBrief } from "@contractspec/lib.video-gen/types";
|
|
29
|
-
|
|
30
|
-
// Minimal (deterministic, no LLM, no voice)
|
|
31
|
-
const generator = new VideoGenerator({ fps: 30 });
|
|
32
|
-
|
|
33
|
-
// Full (with LLM for richer scenes + voice narration)
|
|
34
|
-
const generator = new VideoGenerator({
|
|
35
|
-
llm: myLLMProvider,
|
|
36
|
-
voice: myVoiceProvider,
|
|
37
|
-
model: "gpt-4o",
|
|
38
|
-
temperature: 0.4,
|
|
39
|
-
defaultVoiceId: "rachel",
|
|
40
|
-
fps: 30,
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
const project = await generator.generate(brief);
|
|
44
|
-
\`\`\`
|
|
45
|
-
|
|
46
|
-
### Pipeline Steps
|
|
47
|
-
|
|
48
|
-
1. **Scene planning** -- \`ScenePlanner.plan(brief)\` breaks the brief into concrete \`PlannedScene[]\` with composition IDs, props, and durations.
|
|
49
|
-
2. **Script generation** -- If \`brief.narration.enabled\`, \`ScriptGenerator.generate()\` produces a \`NarrationScript\` with per-scene text segments.
|
|
50
|
-
3. **Voice synthesis** -- If a \`VoiceProvider\` is configured and narration is enabled, synthesizes audio via \`voice.synthesize()\`.
|
|
51
|
-
4. **Assembly** -- Combines scenes, audio, and metadata into a \`VideoProject\`.
|
|
52
|
-
|
|
53
|
-
### Constructor Options
|
|
54
|
-
|
|
55
|
-
| Option | Type | Default | Description |
|
|
56
|
-
|--------|------|---------|-------------|
|
|
57
|
-
| \`llm\` | \`LLMProvider\` | -- | Optional LLM for enhanced generation |
|
|
58
|
-
| \`voice\` | \`VoiceProvider\` | -- | Optional voice synthesis provider |
|
|
59
|
-
| \`model\` | \`string\` | -- | LLM model override |
|
|
60
|
-
| \`temperature\` | \`number\` | \`0.4\` | LLM temperature (lower = more deterministic) |
|
|
61
|
-
| \`defaultVoiceId\` | \`string\` | -- | Default voice for narration |
|
|
62
|
-
| \`fps\` | \`number\` | \`30\` | Frames per second |
|
|
63
|
-
|
|
64
|
-
## ScenePlanner
|
|
65
|
-
|
|
66
|
-
Breaks a \`VideoBrief\` into concrete scenes mapped to registered compositions.
|
|
67
|
-
|
|
68
|
-
\`\`\`ts
|
|
69
|
-
import { ScenePlanner } from "@contractspec/lib.video-gen/generators";
|
|
70
|
-
|
|
71
|
-
const planner = new ScenePlanner({ fps: 30 });
|
|
72
|
-
const plan = await planner.plan(brief);
|
|
73
|
-
|
|
74
|
-
plan.scenes; // PlannedScene[]
|
|
75
|
-
plan.estimatedDurationSeconds; // total estimated duration
|
|
76
|
-
plan.narrationScript; // combined narration text
|
|
77
|
-
\`\`\`
|
|
78
|
-
|
|
79
|
-
### Deterministic Path (no LLM)
|
|
80
|
-
|
|
81
|
-
Maps brief sections to \`SocialClip\` compositions:
|
|
82
|
-
|
|
83
|
-
| Brief Section | Scene | Duration |
|
|
84
|
-
|---------------|-------|----------|
|
|
85
|
-
| \`title\` + \`summary\` | Hook / title | 3s |
|
|
86
|
-
| \`problems\` | Problem statement | 4s |
|
|
87
|
-
| \`solutions\` | Solution showcase | 5s |
|
|
88
|
-
| \`metrics\` | Proof / results | 3s |
|
|
89
|
-
| \`callToAction\` | CTA | 2s |
|
|
90
|
-
|
|
91
|
-
If \`brief.targetDurationSeconds\` is set, all scene durations are scaled proportionally.
|
|
92
|
-
|
|
93
|
-
### LLM-Enhanced Path
|
|
94
|
-
|
|
95
|
-
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.
|
|
96
|
-
|
|
97
|
-
## ScriptGenerator
|
|
98
|
-
|
|
99
|
-
Produces narration text from a \`ContentBrief\` with style control.
|
|
100
|
-
|
|
101
|
-
\`\`\`ts
|
|
102
|
-
import { ScriptGenerator } from "@contractspec/lib.video-gen/generators";
|
|
103
|
-
|
|
104
|
-
const scriptGen = new ScriptGenerator({ temperature: 0.5 });
|
|
105
|
-
const script = await scriptGen.generate(brief.content, brief.narration);
|
|
106
|
-
|
|
107
|
-
script.fullText; // complete narration
|
|
108
|
-
script.segments; // NarrationSegment[] (per-scene text)
|
|
109
|
-
script.estimatedDurationSeconds; // at ~150 words/min
|
|
110
|
-
script.style; // "professional" | "casual" | "technical"
|
|
111
|
-
\`\`\`
|
|
112
|
-
|
|
113
|
-
### Narration Styles
|
|
114
|
-
|
|
115
|
-
| Style | Tone |
|
|
116
|
-
|-------|------|
|
|
117
|
-
| \`professional\` | Clear, authoritative, concise |
|
|
118
|
-
| \`casual\` | Friendly, conversational, approachable |
|
|
119
|
-
| \`technical\` | Precise, detailed, accurate |
|
|
120
|
-
|
|
121
|
-
### NarrationSegment
|
|
122
|
-
|
|
123
|
-
Each segment maps to a scene and provides timing estimates:
|
|
124
|
-
|
|
125
|
-
\`\`\`ts
|
|
126
|
-
interface NarrationSegment {
|
|
127
|
-
sceneId: string; // "intro", "problems", "solutions", "metrics", "cta"
|
|
128
|
-
text: string; // narration text for this segment
|
|
129
|
-
estimatedDurationSeconds: number; // at ~150 words/min
|
|
130
|
-
}
|
|
131
|
-
\`\`\`
|
|
132
|
-
|
|
133
|
-
## Input Types
|
|
134
|
-
|
|
135
|
-
### VideoBrief
|
|
136
|
-
|
|
137
|
-
\`\`\`ts
|
|
138
|
-
interface VideoBrief {
|
|
139
|
-
content: ContentBrief; // from @contractspec/lib.content-gen
|
|
140
|
-
format: VideoFormat; // landscape, portrait, square, or custom
|
|
141
|
-
targetDurationSeconds?: number; // auto-calculated if omitted
|
|
142
|
-
narration?: NarrationConfig; // { enabled, voiceId, language, style }
|
|
143
|
-
style?: VideoStyleOverrides; // colors, fonts, dark mode
|
|
144
|
-
compositionId?: string; // force a specific composition
|
|
145
|
-
}
|
|
146
|
-
\`\`\`
|
|
147
|
-
|
|
148
|
-
### PlannedScene
|
|
149
|
-
|
|
150
|
-
\`\`\`ts
|
|
151
|
-
interface PlannedScene {
|
|
152
|
-
compositionId: string; // maps to a registered Remotion composition
|
|
153
|
-
props: Record<string, unknown>; // input props for the composition
|
|
154
|
-
durationInFrames: number; // scene duration
|
|
155
|
-
narrationText?: string; // narrator text for this scene
|
|
156
|
-
notes?: string; // planning notes (LLM path only)
|
|
157
|
-
}
|
|
158
|
-
\`\`\`
|
|
159
|
-
|
|
160
|
-
## Guardrails
|
|
161
|
-
|
|
162
|
-
- Generators are **stateless** -- no side effects, no caching. Call \`generate()\` / \`plan()\` for each video.
|
|
163
|
-
- LLM responses are parsed as JSON; any parse failure falls back to deterministic.
|
|
164
|
-
- Temperature defaults are conservative (0.3-0.5) for reproducibility.
|
|
165
|
-
- Duration estimates use 150 words/min speaking rate.
|
|
166
|
-
`}];f(h);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
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
|
|
3
|
-
|
|
4
|
-
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\`.
|
|
5
|
-
|
|
6
|
-
## LocalRenderer
|
|
7
|
-
|
|
8
|
-
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)).
|
|
9
|
-
|
|
10
|
-
\`\`\`ts
|
|
11
|
-
import { LocalRenderer } from "@contractspec/lib.video-gen/renderers/local";
|
|
12
|
-
|
|
13
|
-
const renderer = new LocalRenderer({
|
|
14
|
-
entryPoint: "./src/remotion/index.ts",
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
const result = await renderer.render(project, {
|
|
18
|
-
outputPath: "out/video.mp4",
|
|
19
|
-
codec: "h264",
|
|
20
|
-
crf: 18,
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
result.outputPath; // "out/video.mp4"
|
|
24
|
-
result.format; // "mp4"
|
|
25
|
-
result.durationSeconds; // total duration
|
|
26
|
-
result.fileSizeBytes; // file size
|
|
27
|
-
result.dimensions; // { width: 1920, height: 1080 }
|
|
28
|
-
\`\`\`
|
|
29
|
-
|
|
30
|
-
> **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.
|
|
31
|
-
|
|
32
|
-
### Auto-Variants
|
|
33
|
-
|
|
34
|
-
Set \`autoVariants: true\` to generate landscape + square + portrait versions:
|
|
35
|
-
|
|
36
|
-
\`\`\`ts
|
|
37
|
-
const result = await renderer.render(project, {
|
|
38
|
-
outputPath: "out/video.mp4",
|
|
39
|
-
autoVariants: true,
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
result.variants; // [
|
|
43
|
-
// { outputPath: "out/video-square.mp4", dimensions: { width: 1080, height: 1080 } },
|
|
44
|
-
// { outputPath: "out/video-portrait.mp4", dimensions: { width: 1080, height: 1920 } },
|
|
45
|
-
// ]
|
|
46
|
-
\`\`\`
|
|
47
|
-
|
|
48
|
-
## Render Configuration
|
|
49
|
-
|
|
50
|
-
### Defaults
|
|
51
|
-
|
|
52
|
-
\`\`\`ts
|
|
53
|
-
import {
|
|
54
|
-
defaultRenderConfig,
|
|
55
|
-
resolveRenderConfig,
|
|
56
|
-
qualityPresets,
|
|
57
|
-
codecFormatMap,
|
|
58
|
-
} from "@contractspec/lib.video-gen/renderers/config";
|
|
59
|
-
|
|
60
|
-
defaultRenderConfig.codec; // "h264"
|
|
61
|
-
defaultRenderConfig.outputFormat; // "mp4"
|
|
62
|
-
defaultRenderConfig.crf; // 18
|
|
63
|
-
defaultRenderConfig.pixelFormat; // "yuv420p"
|
|
64
|
-
\`\`\`
|
|
65
|
-
|
|
66
|
-
### RenderConfig Options
|
|
67
|
-
|
|
68
|
-
| Option | Type | Default | Description |
|
|
69
|
-
|--------|------|---------|-------------|
|
|
70
|
-
| \`outputPath\` | \`string\` | -- | **Required**. Output file path |
|
|
71
|
-
| \`codec\` | \`"h264" \\| "h265" \\| "vp8" \\| "vp9"\` | \`"h264"\` | Video codec |
|
|
72
|
-
| \`outputFormat\` | \`"mp4" \\| "webm" \\| "gif"\` | \`"mp4"\` | Container format |
|
|
73
|
-
| \`crf\` | \`number\` | \`18\` | Constant Rate Factor (lower = better quality) |
|
|
74
|
-
| \`pixelFormat\` | \`string\` | \`"yuv420p"\` | Pixel format |
|
|
75
|
-
| \`concurrency\` | \`number\` | CPU count | Rendering threads |
|
|
76
|
-
| \`autoVariants\` | \`boolean\` | \`false\` | Generate format variants |
|
|
77
|
-
|
|
78
|
-
### Quality Presets
|
|
79
|
-
|
|
80
|
-
\`\`\`ts
|
|
81
|
-
import { resolveRenderConfig } from "@contractspec/lib.video-gen/renderers/config";
|
|
82
|
-
|
|
83
|
-
// Draft (fastest, for previews)
|
|
84
|
-
resolveRenderConfig({ outputPath: "out/preview.mp4" }, "draft");
|
|
85
|
-
// -> crf: 28, concurrency: 1
|
|
86
|
-
|
|
87
|
-
// Standard (balanced)
|
|
88
|
-
resolveRenderConfig({ outputPath: "out/video.mp4" }, "standard");
|
|
89
|
-
// -> crf: 18
|
|
90
|
-
|
|
91
|
-
// High (best quality, for final output)
|
|
92
|
-
resolveRenderConfig({ outputPath: "out/final.mp4" }, "high");
|
|
93
|
-
// -> crf: 12
|
|
94
|
-
\`\`\`
|
|
95
|
-
|
|
96
|
-
### Codec-to-Format Mapping
|
|
97
|
-
|
|
98
|
-
| Codec | Format |
|
|
99
|
-
|-------|--------|
|
|
100
|
-
| \`h264\` | \`mp4\` |
|
|
101
|
-
| \`h265\` | \`mp4\` |
|
|
102
|
-
| \`vp8\` | \`webm\` |
|
|
103
|
-
| \`vp9\` | \`webm\` |
|
|
104
|
-
|
|
105
|
-
## DemoPlayer (Web Embedding)
|
|
106
|
-
|
|
107
|
-
Embeddable Remotion Player for interactive video demos in React apps. Wraps \`@remotion/player\` with ContractSpec compositions.
|
|
108
|
-
|
|
109
|
-
\`\`\`tsx
|
|
110
|
-
import { DemoPlayer } from "@contractspec/lib.video-gen/player";
|
|
111
|
-
|
|
112
|
-
<DemoPlayer
|
|
113
|
-
compositionId="ApiOverview"
|
|
114
|
-
inputProps={{
|
|
115
|
-
specName: "CreateUser",
|
|
116
|
-
specCode: "export const createUser = defineCommand({...})",
|
|
117
|
-
}}
|
|
118
|
-
controls
|
|
119
|
-
autoPlay
|
|
120
|
-
loop
|
|
121
|
-
width="100%"
|
|
122
|
-
clickToPlay
|
|
123
|
-
doubleClickToFullscreen
|
|
124
|
-
/>
|
|
125
|
-
\`\`\`
|
|
126
|
-
|
|
127
|
-
### DemoPlayer Props
|
|
128
|
-
|
|
129
|
-
| Prop | Type | Default | Description |
|
|
130
|
-
|------|------|---------|-------------|
|
|
131
|
-
| \`compositionId\` | \`"ApiOverview" \\| "SocialClip" \\| "TerminalDemo"\` | -- | Composition to play |
|
|
132
|
-
| \`inputProps\` | composition props type | -- | Props for the selected composition |
|
|
133
|
-
| \`controls\` | \`boolean\` | \`true\` | Show playback controls |
|
|
134
|
-
| \`autoPlay\` | \`boolean\` | \`false\` | Auto-play on mount |
|
|
135
|
-
| \`loop\` | \`boolean\` | \`false\` | Loop playback |
|
|
136
|
-
| \`width\` | \`string \\| number\` | \`"100%"\` | Player width |
|
|
137
|
-
| \`height\` | \`string \\| number\` | \`"auto"\` | Player height |
|
|
138
|
-
| \`clickToPlay\` | \`boolean\` | \`true\` | Click to toggle playback |
|
|
139
|
-
| \`doubleClickToFullscreen\` | \`boolean\` | \`true\` | Double-click for fullscreen |
|
|
140
|
-
|
|
141
|
-
> \`@remotion/player\` is a peer dependency. Install it in your app if you use \`DemoPlayer\`.
|
|
142
|
-
|
|
143
|
-
## Remotion Studio
|
|
144
|
-
|
|
145
|
-
The \`@contractspec/app.video-studio\` package provides a Remotion Studio entry point for previewing compositions interactively.
|
|
146
|
-
|
|
147
|
-
\`\`\`bash
|
|
148
|
-
# Start Remotion Studio
|
|
149
|
-
bun run dev:video
|
|
150
|
-
|
|
151
|
-
# Render a specific composition
|
|
152
|
-
bunx remotionb render src/index.ts ApiOverview out/api-overview.mp4
|
|
153
|
-
|
|
154
|
-
# Render all compositions
|
|
155
|
-
bun run render:all
|
|
156
|
-
\`\`\`
|
|
157
|
-
|
|
158
|
-
### Registered Compositions
|
|
159
|
-
|
|
160
|
-
| ID | Component | Dimensions | Duration | Description |
|
|
161
|
-
|----|-----------|------------|----------|-------------|
|
|
162
|
-
| \`ApiOverview\` | \`ApiOverview\` | 1920x1080 | 450 frames (15s) | Homepage API demo |
|
|
163
|
-
| \`SocialClip\` | \`SocialClip\` | 1920x1080 | 300 frames (10s) | Landscape social clip |
|
|
164
|
-
| \`SocialClipSquare\` | \`SocialClip\` | 1080x1080 | 300 frames (10s) | Square social clip |
|
|
165
|
-
| \`SocialClipPortrait\` | \`SocialClip\` | 1080x1920 | 300 frames (10s) | Portrait social clip |
|
|
166
|
-
| \`TerminalDemo\` | \`TerminalDemo\` | 1920x1080 | 600 frames (20s) | CLI walkthrough |
|
|
167
|
-
|
|
168
|
-
All compositions run at 30fps.
|
|
169
|
-
|
|
170
|
-
## Guardrails
|
|
171
|
-
|
|
172
|
-
- \`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)).
|
|
173
|
-
- Import \`LocalRenderer\` from the \`/renderers/local\` subpath to avoid bundling \`@remotion/renderer\` in browser builds.
|
|
174
|
-
- 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.
|
|
175
|
-
- Use quality presets for consistency: \`draft\` for development, \`standard\` for CI, \`high\` for releases.
|
|
176
|
-
`}];f(h);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
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
|
|
3
|
-
|
|
4
|
-
\`@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\`.
|
|
5
|
-
|
|
6
|
-
## Architecture
|
|
7
|
-
|
|
8
|
-
The library is organized into five layers, each buildable and testable independently:
|
|
9
|
-
|
|
10
|
-
\`\`\`
|
|
11
|
-
Content Brief
|
|
12
|
-
|
|
|
13
|
-
v
|
|
14
|
-
Generators -----> ScenePlanner (brief -> scenes)
|
|
15
|
-
| ScriptGenerator (brief -> narration)
|
|
16
|
-
| VideoGenerator (orchestrator)
|
|
17
|
-
v
|
|
18
|
-
Compositions ---> Primitives (AnimatedText, CodeBlock, Terminal, ...)
|
|
19
|
-
| Full Compositions (ApiOverview, SocialClip, TerminalDemo)
|
|
20
|
-
v
|
|
21
|
-
Design ---------> Tokens, Motion, Typography, Layouts
|
|
22
|
-
|
|
|
23
|
-
v
|
|
24
|
-
Renderers ------> LocalRenderer (@remotion/renderer)
|
|
25
|
-
DemoPlayer (@remotion/player, web embedding)
|
|
26
|
-
\`\`\`
|
|
27
|
-
|
|
28
|
-
### Layer Responsibilities
|
|
29
|
-
|
|
30
|
-
| Layer | Import Path | Purpose |
|
|
31
|
-
|-------|-------------|---------|
|
|
32
|
-
| **Types** | \`@contractspec/lib.video-gen/types\` | VideoBrief, ScenePlan, GeneratedVideo, re-exported contract types |
|
|
33
|
-
| **Design** | \`@contractspec/lib.video-gen/design\` | Video-optimized tokens, motion primitives, typography, layouts |
|
|
34
|
-
| **Compositions** | \`@contractspec/lib.video-gen/compositions\` | Remotion components (primitives + full compositions) |
|
|
35
|
-
| **Generators** | \`@contractspec/lib.video-gen/generators\` | VideoGenerator, ScenePlanner, ScriptGenerator |
|
|
36
|
-
| **Renderers** | \`@contractspec/lib.video-gen/renderers\` | LocalRenderer, render config, quality presets |
|
|
37
|
-
| **Player** | \`@contractspec/lib.video-gen/player\` | Embeddable DemoPlayer for web apps |
|
|
38
|
-
| **Remotion** | \`@contractspec/lib.video-gen/remotion\` | Remotion Studio entry point (registerRoot) |
|
|
39
|
-
|
|
40
|
-
## Getting Started
|
|
41
|
-
|
|
42
|
-
### 1. Generate a video project from a content brief
|
|
43
|
-
|
|
44
|
-
\`\`\`ts
|
|
45
|
-
import { VideoGenerator } from "@contractspec/lib.video-gen/generators";
|
|
46
|
-
import { VIDEO_FORMATS } from "@contractspec/lib.video-gen/types";
|
|
47
|
-
import type { VideoBrief } from "@contractspec/lib.video-gen/types";
|
|
48
|
-
|
|
49
|
-
const generator = new VideoGenerator({ fps: 30 });
|
|
50
|
-
|
|
51
|
-
const brief: VideoBrief = {
|
|
52
|
-
content: {
|
|
53
|
-
title: "Ship APIs 10x Faster",
|
|
54
|
-
summary: "ContractSpec generates everything from a single spec.",
|
|
55
|
-
problems: ["Manual API maintenance", "Inconsistent surfaces"],
|
|
56
|
-
solutions: ["One spec, every surface", "Safe regeneration"],
|
|
57
|
-
callToAction: "Try ContractSpec",
|
|
58
|
-
},
|
|
59
|
-
format: VIDEO_FORMATS.landscape,
|
|
60
|
-
targetDurationSeconds: 30,
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const project = await generator.generate(brief);
|
|
64
|
-
\`\`\`
|
|
65
|
-
|
|
66
|
-
### 2. Render to MP4
|
|
67
|
-
|
|
68
|
-
\`\`\`ts
|
|
69
|
-
import { LocalRenderer } from "@contractspec/lib.video-gen/renderers/local";
|
|
70
|
-
|
|
71
|
-
const renderer = new LocalRenderer({
|
|
72
|
-
entryPoint: "./src/remotion/index.ts",
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
const result = await renderer.render(project, {
|
|
76
|
-
outputPath: "out/video.mp4",
|
|
77
|
-
});
|
|
78
|
-
\`\`\`
|
|
79
|
-
|
|
80
|
-
### 3. Embed in a web app
|
|
81
|
-
|
|
82
|
-
\`\`\`tsx
|
|
83
|
-
import { DemoPlayer } from "@contractspec/lib.video-gen/player";
|
|
84
|
-
|
|
85
|
-
<DemoPlayer
|
|
86
|
-
compositionId="ApiOverview"
|
|
87
|
-
inputProps={{ specName: "CreateUser", specCode: "..." }}
|
|
88
|
-
controls
|
|
89
|
-
autoPlay
|
|
90
|
-
loop
|
|
91
|
-
/>
|
|
92
|
-
\`\`\`
|
|
93
|
-
|
|
94
|
-
## Contract Bridge
|
|
95
|
-
|
|
96
|
-
The library consumes provider contracts defined in \`@contractspec/lib.contracts-integrations\`:
|
|
97
|
-
|
|
98
|
-
| Contract | Purpose |
|
|
99
|
-
|----------|---------|
|
|
100
|
-
| \`VideoProvider\` | Renderer abstraction (local, Lambda, Cloud Run) |
|
|
101
|
-
| \`VideoProject\` | Scene graph with format, fps, audio tracks |
|
|
102
|
-
| \`RenderConfig\` / \`RenderResult\` | Codec, quality, output path, dimensions |
|
|
103
|
-
| \`CompositionRegistry\` | Metadata for registered Remotion compositions |
|
|
104
|
-
| \`VideoFormat\` | Landscape / portrait / square / custom dimensions |
|
|
105
|
-
|
|
106
|
-
Types are re-exported from the main entry for convenience:
|
|
107
|
-
|
|
108
|
-
\`\`\`ts
|
|
109
|
-
import type { VideoProject, RenderConfig } from "@contractspec/lib.video-gen";
|
|
110
|
-
\`\`\`
|
|
111
|
-
|
|
112
|
-
## Deterministic by Default
|
|
113
|
-
|
|
114
|
-
All generators support two modes:
|
|
115
|
-
|
|
116
|
-
- **Without LLM**: Fully deterministic, template-based output. Same brief always produces the same video project.
|
|
117
|
-
- **With LLM**: Richer scene planning and narration scripts via an optional \`LLMProvider\`. Falls back to deterministic on any failure.
|
|
118
|
-
|
|
119
|
-
This matches the content-gen pattern: \`constructor({ llm? })\` -> \`generate(brief)\`.
|
|
120
|
-
|
|
121
|
-
## Guardrails
|
|
122
|
-
|
|
123
|
-
- Compositions must be **deterministic**: same props = same visual output.
|
|
124
|
-
- Design tokens bridge from \`@contractspec/lib.design-system\` -- do not duplicate brand values.
|
|
125
|
-
- \`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)).
|
|
126
|
-
- The \`remotion\` entry point is a side-effect module (calls \`registerRoot\`) -- import it only from Remotion Studio or render scripts.
|
|
127
|
-
`}];f(h);
|