🎥 Make videos programmatically with React
nice works in preview
Jonny Burger0d63c38e8cb6
diff --git a/packages/core/src/CompositionManager.tsx b/packages/core/src/CompositionManager.tsxindex c511715d36..2ac37cf632 100644--- a/packages/core/src/CompositionManager.tsx+++ b/packages/core/src/CompositionManager.tsx@@ -14,7 +14,7 @@ import {SharedAudioContextProvider} from './audio/shared-audio-tags.js';import type {CalculateMetadataFunction} from './Composition.js';import type {TFolder} from './Folder.js';import type {PropsIfHasProps} from './props-if-has-props.js';-import {resolveVideoConfig} from './use-unsafe-video-config.js';+import {resolveVideoConfig} from './resolve-video-config.js';import type {VideoConfig} from './video-config.js';export type TComposition<Schema extends z.ZodTypeAny, Props> = {diff --git a/packages/core/src/resolve-video-config.ts b/packages/core/src/resolve-video-config.tsindex 7c1b88843a..17c27e3506 100644--- a/packages/core/src/resolve-video-config.ts+++ b/packages/core/src/resolve-video-config.ts@@ -1,4 +1,6 @@import type {AnyComposition} from './CompositionManager.js';+import {validateDimension} from './validation/validate-dimensions.js';+import {validateDurationInFrames} from './validation/validate-duration-in-frames.js';import type {VideoConfig} from './video-config.js';export const resolveVideoConfig = async (@@ -15,6 +17,8 @@ export const resolveVideoConfig = async ();}+ validateDimension(width, 'width', 'calculated by calculateMetadata()');+const height = calculated?.height ?? comp.height ?? null;if (!height) {throw new TypeError(@@ -22,6 +26,8 @@ export const resolveVideoConfig = async ();}+ validateDimension(width, 'height', 'calculated by calculateMetadata()');+const fps = calculated?.fps ?? comp.fps ?? null;if (!fps) {throw new TypeError(@@ -37,6 +43,12 @@ export const resolveVideoConfig = async ();}+ validateDurationInFrames({+ durationInFrames,+ component: 'calculated by calculateMetadata()',+ allowFloats: false,+ });+return {width,height,diff --git a/packages/example/src/Video.tsx b/packages/example/src/Video.tsxindex aa14bd74e8..aa8ed07fc4 100644--- a/packages/example/src/Video.tsx+++ b/packages/example/src/Video.tsx@@ -832,10 +832,13 @@ export const Index: React.FC = () => {height={1080}fps={30}durationInFrames={100}- calculateStuff={() => {- return Promise.resolve({- durationInFrames: Math.random() * 100,- });+ calculateStuff={async () => {+ return {+ durationInFrames: Math.round(Math.random() * 100),+ fps: 30,+ height: Math.round(Math.random() * 2 * 500),+ width: Math.round(Math.random() * 2 * 500),+ };}}/></Folder>