@contractspec/example.video-marketing-clip 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +35 -0
- package/.turbo/turbo-prebuild.log +1 -0
- package/CHANGELOG.md +14 -0
- package/dist/briefs.d.ts +13 -0
- package/dist/briefs.js +75 -0
- package/dist/browser/briefs.js +74 -0
- package/dist/browser/docs/index.js +67 -0
- package/dist/browser/docs/video-marketing-clip.docblock.js +67 -0
- package/dist/browser/example.js +33 -0
- package/dist/browser/generate-clip.js +29 -0
- package/dist/browser/index.js +201 -0
- package/dist/docs/index.d.ts +1 -0
- package/dist/docs/index.js +68 -0
- package/dist/docs/video-marketing-clip.docblock.d.ts +1 -0
- package/dist/docs/video-marketing-clip.docblock.js +68 -0
- package/dist/example.d.ts +2 -0
- package/dist/example.js +34 -0
- package/dist/generate-clip.d.ts +35 -0
- package/dist/generate-clip.js +30 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +202 -0
- package/dist/node/briefs.js +74 -0
- package/dist/node/docs/index.js +67 -0
- package/dist/node/docs/video-marketing-clip.docblock.js +67 -0
- package/dist/node/example.js +33 -0
- package/dist/node/generate-clip.js +29 -0
- package/dist/node/index.js +201 -0
- package/package.json +145 -0
- package/src/briefs.ts +88 -0
- package/src/docs/index.ts +1 -0
- package/src/docs/video-marketing-clip.docblock.ts +70 -0
- package/src/example.ts +32 -0
- package/src/generate-clip.ts +79 -0
- package/src/index.ts +6 -0
- package/tsconfig.json +9 -0
- package/tsdown.config.js +3 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// Generate Marketing Clip -- End-to-end video generation from a content brief
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
|
|
5
|
+
import type { ContentBrief } from '@contractspec/lib.content-gen/types';
|
|
6
|
+
import { VideoGenerator } from '@contractspec/lib.video-gen/generators';
|
|
7
|
+
import { VIDEO_FORMATS } from '@contractspec/lib.video-gen/design/layouts';
|
|
8
|
+
import type {
|
|
9
|
+
VideoBrief,
|
|
10
|
+
VideoFormat,
|
|
11
|
+
} from '@contractspec/lib.video-gen/types';
|
|
12
|
+
import type { VideoProject } from '@contractspec/lib.video-gen/types';
|
|
13
|
+
|
|
14
|
+
/** Supported social format keys. */
|
|
15
|
+
export type SocialFormat = 'landscape' | 'square' | 'portrait';
|
|
16
|
+
|
|
17
|
+
const FORMAT_MAP: Record<SocialFormat, VideoFormat> = {
|
|
18
|
+
landscape: VIDEO_FORMATS.landscape,
|
|
19
|
+
square: VIDEO_FORMATS.square,
|
|
20
|
+
portrait: VIDEO_FORMATS.portrait,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Generate a marketing video project from a content brief.
|
|
25
|
+
*
|
|
26
|
+
* This is the main handler demonstrating the deterministic video-gen pipeline:
|
|
27
|
+
* 1. Wrap the ContentBrief in a VideoBrief with format + duration config
|
|
28
|
+
* 2. Use VideoGenerator (no LLM) to plan scenes and assemble the project
|
|
29
|
+
* 3. Return the VideoProject (scene graph ready for rendering)
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* import { generateMarketingClip } from "@contractspec/example.video-marketing-clip/generate-clip";
|
|
34
|
+
* import { productLaunchBrief } from "@contractspec/example.video-marketing-clip/briefs";
|
|
35
|
+
*
|
|
36
|
+
* const project = await generateMarketingClip(productLaunchBrief, "landscape");
|
|
37
|
+
* console.log(project.scenes.length); // 5
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export async function generateMarketingClip(
|
|
41
|
+
brief: ContentBrief,
|
|
42
|
+
format: SocialFormat = 'landscape',
|
|
43
|
+
targetDurationSeconds?: number
|
|
44
|
+
): Promise<VideoProject> {
|
|
45
|
+
const generator = new VideoGenerator({ fps: 30 });
|
|
46
|
+
|
|
47
|
+
const videoBrief: VideoBrief = {
|
|
48
|
+
content: brief,
|
|
49
|
+
format: FORMAT_MAP[format],
|
|
50
|
+
targetDurationSeconds,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
return generator.generate(videoBrief);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Generate video projects for all three social formats from a single brief.
|
|
58
|
+
*
|
|
59
|
+
* Returns landscape, square, and portrait variants -- useful for
|
|
60
|
+
* cross-platform social media campaigns.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* const variants = await generateAllFormats(productLaunchBrief, 30);
|
|
65
|
+
* // variants.landscape, variants.square, variants.portrait
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export async function generateAllFormats(
|
|
69
|
+
brief: ContentBrief,
|
|
70
|
+
targetDurationSeconds?: number
|
|
71
|
+
): Promise<Record<SocialFormat, VideoProject>> {
|
|
72
|
+
const [landscape, square, portrait] = await Promise.all([
|
|
73
|
+
generateMarketingClip(brief, 'landscape', targetDurationSeconds),
|
|
74
|
+
generateMarketingClip(brief, 'square', targetDurationSeconds),
|
|
75
|
+
generateMarketingClip(brief, 'portrait', targetDurationSeconds),
|
|
76
|
+
]);
|
|
77
|
+
|
|
78
|
+
return { landscape, square, portrait };
|
|
79
|
+
}
|
package/src/index.ts
ADDED
package/tsconfig.json
ADDED
package/tsdown.config.js
ADDED