Skip to content

🎥 Make videos programmatically with React

making compositionId optional to start

Logan Arnett9c54d8b4b83e
diff --git a/packages/core/src/use-unsafe-video-config.ts b/packages/core/src/use-unsafe-video-config.ts
index e3aa8f7504..a9477e2991 100644
--- a/packages/core/src/use-unsafe-video-config.ts
+++ b/packages/core/src/use-unsafe-video-config.ts
@@ -13,9 +13,10 @@ export const useUnsafeVideoConfig = (): VideoConfig | null => {
return null;
}
- const {durationInFrames, fps, height, width} = video;
+ const {id, durationInFrames, fps, height, width} = video;
return {
+ id,
width,
height,
fps,
diff --git a/packages/core/src/video-config.ts b/packages/core/src/video-config.ts
index f59682395f..0bf69b8286 100644
--- a/packages/core/src/video-config.ts
+++ b/packages/core/src/video-config.ts
@@ -3,4 +3,5 @@ export type VideoConfig = {
height: number;
fps: number;
durationInFrames: number;
+ id: string;
};
diff --git a/packages/docs/docs/render-frames.md b/packages/docs/docs/render-frames.md
index 84b8cc4fb9..e42408f0ef 100644
--- a/packages/docs/docs/render-frames.md
+++ b/packages/docs/docs/render-frames.md
@@ -12,7 +12,7 @@ If you want to render only a still image, use [renderStill()](/docs/render-still
```ts
const renderFrames: (options: {
config: VideoConfig;
- compositionId: string;
+ compositionId?: string;
onFrameUpdate: (frame: number) => void;
onStart: (data: {
frameCount: number;
@@ -41,7 +41,7 @@ Takes an object with the following keys:
### `config`
-A video config, consisting out of `width`, `height`, `durationInFrames` and `fps`. See: [Defining compositions](/docs/the-fundamentals#defining-compositions) and [useVideoConfig()](/docs/use-video-config).
+A video config, consisting out of `id`, `width`, `height`, `durationInFrames` and `fps`, where `id` is the compositions ID. See: [Defining compositions](/docs/the-fundamentals#defining-compositions) and [useVideoConfig()](/docs/use-video-config).
### `compositionId`
diff --git a/packages/renderer/src/render.ts b/packages/renderer/src/render.ts
index 919235c1b0..c487c72b9d 100644
--- a/packages/renderer/src/render.ts
+++ b/packages/renderer/src/render.ts
@@ -41,7 +41,7 @@ export const renderFrames = async ({
browserExecutable,
}: {
config: VideoConfig;
- compositionId: string;
+ compositionId?: string;
onStart: (data: OnStartData) => void;
onFrameUpdate: (f: number) => void;
outputDir: string;
@@ -122,7 +122,7 @@ export const renderFrames = async ({
initialFrame,
});
- const site = `http://localhost:${port}/index.html?composition=${compositionId}`;
+ const site = `http://localhost:${port}/index.html?composition=${compositionId ?? config.id}`;
await page.goto(site);
page.off('pageerror', errorCallback);
return page;