Skip to content

🎥 Make videos programmatically with React

update docs

Jonny Burgerd5bb2247b967
diff --git a/packages/cli/src/determine-image-format.ts b/packages/cli/src/determine-image-format.ts
index 56bf2a5184..680327ea37 100644
--- a/packages/cli/src/determine-image-format.ts
+++ b/packages/cli/src/determine-image-format.ts
@@ -15,6 +15,10 @@ const deriveExtensionFromFilename = (
return 'jpeg';
}
+ if (filename?.endsWith('.pdf')) {
+ return 'pdf';
+ }
+
return null;
};
diff --git a/packages/cli/src/print-help.ts b/packages/cli/src/print-help.ts
index 2543679409..ad26f59cf6 100644
--- a/packages/cli/src/print-help.ts
+++ b/packages/cli/src/print-help.ts
@@ -28,7 +28,7 @@ export const printHelp = () => {
printFlags([
['--props', 'Pass input props as filename or as JSON'],
['--concurrency', 'How many frames to render in parallel'],
- ['--image-format', 'Format to render the frames in, "jpeg" or "png"'],
+ ['--image-format', 'Format to render the video/still in'],
['--pixel-format', 'Custom pixel format, see docs for available values'],
['--config', 'Custom location for a Remotion config file'],
['--quality', 'Quality for rendered frames, JPEG only, 0-100'],
@@ -50,7 +50,7 @@ export const printHelp = () => {
Log.info(chalk.gray('Render a still frame and save it as an image.'));
printFlags([
['--frame', 'Which frame to render (default 0)'],
- ['--image-format', 'Format to render the frames in, "jpeg" or "png"'],
+ ['--image-format', 'Format to render the video/still in'],
['--props', 'Pass input props as filename or as JSON'],
['--config', 'Custom location for a Remotion config file'],
['--quality', 'Quality for rendered frames, JPEG only, 0-100'],
diff --git a/packages/docs/docs/cli/render.md b/packages/docs/docs/cli/render.md
index a34f7e2d71..15838f8db0 100644
--- a/packages/docs/docs/cli/render.md
+++ b/packages/docs/docs/cli/render.md
@@ -52,7 +52,7 @@ Inline JSON string isn't supported on Windows because it removes the `"` charact
### `--image-format` <AvailableFrom v="1.4.0" />
-[`jpeg` or `png` - JPEG is faster, but doesn't support transparency.](/docs/config#setimageformat) The default image format is `jpeg` since v1.1.
+[`jpeg` or `png` - JPEG is faster, but doesn't support transparency.](/docs/config#setvideoimageformat) The default image format is `jpeg` since v1.1.
### `--config` <AvailableFrom v="1.2.0" />
diff --git a/packages/docs/docs/cli/still.md b/packages/docs/docs/cli/still.md
index 85f201efb9..0520a7cdca 100644
--- a/packages/docs/docs/cli/still.md
+++ b/packages/docs/docs/cli/still.md
@@ -30,7 +30,7 @@ Inline JSON string isn't supported on Windows because it removes the `"` charact
### `--image-format`
-[`jpeg` or `png` - JPEG is faster, but doesn't support transparency.](/docs/config#setimageformat) The default is `jpeg`.
+`jpeg`, `png` or `pdf`. The default is `png`.
### `--config`
diff --git a/packages/docs/docs/config.md b/packages/docs/docs/config.md
index dc86e51441..be1f2fe21f 100644
--- a/packages/docs/docs/config.md
+++ b/packages/docs/docs/config.md
@@ -279,7 +279,39 @@ The [command line flag](/docs/cli/render#--concurrency) `--concurrency` will tak
Try to set your concurrency to `os.cpus().length` to all the threads available on your CPU for faster rendering. The drawback is that other parts of your system might slow down.
:::
-## setImageFormat() <AvailableFrom v="1.4.0" />
+## setVideoImageFormat() <AvailableFrom v="4.0.0" />
+
+Determines which in which image format to render the frames. Either:
+
+- `jpeg` - the fastest option (default)
+- `png` - slower, but supports transparency
+- `none` - don't render images, just calculate audio information
+
+```ts twoslash title="remotion.config.ts"
+import { Config } from "@remotion/cli/config";
+// ---cut---
+Config.setVideoImageFormat("png");
+```
+
+## setStillImageFormat() <AvailableFrom v="4.0.0" />
+
+Determines which in which image format to render the frames. Either:
+
+- `png` (default)
+- `jpeg`
+- `pdf`
+
+```ts twoslash title="remotion.config.ts"
+import { Config } from "@remotion/cli/config";
+// ---cut---
+Config.setStillImageFormat("pdf");
+```
+
+## ~~setImageFormat()~~ <AvailableFrom v="1.4.0" />
+
+_Removed in v4.0_
+
+Replaced in v4.0 with `setVideoImageFormat()` and `setStillImageFormat()`
Determines which in which image format to render the frames. Either:
@@ -287,7 +319,7 @@ Determines which in which image format to render the frames. Either:
- `png` - slower, but supports transparency
- `none` - don't render images, just calculate audio information (available from v2.0)
-```ts twoslash title="remotion.config.ts"
+```ts title="remotion.config.ts"
import { Config } from "@remotion/cli/config";
// ---cut---
Config.setImageFormat("png");
diff --git a/packages/docs/docs/lambda/cli/render.md b/packages/docs/docs/lambda/cli/render.md
index b5192fa287..94775eceb4 100644
--- a/packages/docs/docs/lambda/cli/render.md
+++ b/packages/docs/docs/lambda/cli/render.md
@@ -152,7 +152,7 @@ Example values: `512K` for 512 kbps, `1M` for 1 Mbps.
### `--image-format`
-[`jpeg` or `png` - JPEG is faster, but doesn't support transparency.](/docs/config#setimageformat) The default image format is `jpeg`.
+[`jpeg` or `png` - JPEG is faster, but doesn't support transparency.](/docs/config#setvideoimageformat) The default image format is `jpeg`.
### `--scale`
diff --git a/packages/docs/docs/overlay.md b/packages/docs/docs/overlay.md
index eb49498535..4bc2f42933 100644
--- a/packages/docs/docs/overlay.md
+++ b/packages/docs/docs/overlay.md
@@ -15,7 +15,7 @@ If you want to export a Remotion video to use it as an overlay or transition in
```tsx twoslash title="remotion.config.ts"
import { Config } from "@remotion/cli/config";
-Config.setImageFormat("png");
+Config.setVideoImageFormat("png");
Config.setPixelFormat("yuva444p10le");
Config.setCodec("prores");
Config.setProResProfile("4444");
diff --git a/packages/docs/docs/performance.md b/packages/docs/docs/performance.md
index e84c78aa19..07d12312e9 100644
--- a/packages/docs/docs/performance.md
+++ b/packages/docs/docs/performance.md
@@ -29,7 +29,7 @@ Generally, lower resolution frames result in faster renders. You can make the di
## Choose the right image format and codec
-[JPEG rendering is faster](/docs/config#setimageformat) than PNG rendering. [H264 is the fastest way](/docs/encoding) to encode frames into a video. If you have deviated from the defaults, consider them again if you see slow rendering.
+[JPEG rendering is faster](/docs/config#setvideoimageformat) than PNG rendering. [H264 is the fastest way](/docs/encoding) to encode frames into a video. If you have deviated from the defaults, consider them again if you see slow rendering.
## Enable GPU acceleration
diff --git a/packages/docs/docs/transparent-videos.md b/packages/docs/docs/transparent-videos.md
index c9a22725ce..10060d5d10 100644
--- a/packages/docs/docs/transparent-videos.md
+++ b/packages/docs/docs/transparent-videos.md
@@ -39,7 +39,7 @@ If you want to set these options and persist them, add this to your `remotion.co
```tsx twoslash
import { Config } from "@remotion/cli/config";
-Config.setImageFormat("png");
+Config.setVideoImageFormat("png");
Config.setPixelFormat("yuva420p");
Config.setCodec("vp8");
```
@@ -60,7 +60,7 @@ Supported since v2.1.7, you can set the codec to `prores` and choose a ProRes pr
```tsx twoslash
import { Config } from "@remotion/cli/config";
-Config.setImageFormat("png");
+Config.setVideoImageFormat("png");
Config.setPixelFormat("yuva444p10le");
Config.setCodec("prores");
Config.setProResProfile("4444");
diff --git a/packages/renderer/src/render-media.ts b/packages/renderer/src/render-media.ts
index 3883884a1d..7300e3528c 100644
--- a/packages/renderer/src/render-media.ts
+++ b/packages/renderer/src/render-media.ts
@@ -73,7 +73,7 @@ export type RenderMediaOptions = {
composition: SmallTCompMetadata;
inputProps?: unknown;
crf?: number | null;
- imageFormat?: 'png' | 'jpeg' | 'none';
+ imageFormat?: VideoImageFormat;
pixelFormat?: PixelFormat;
envVariables?: Record<string, string>;
quality?: number;
diff --git a/packages/renderer/src/take-frame-and-compose.ts b/packages/renderer/src/take-frame-and-compose.ts
index 79578f6146..5d22829d45 100644
--- a/packages/renderer/src/take-frame-and-compose.ts
+++ b/packages/renderer/src/take-frame-and-compose.ts
@@ -59,10 +59,6 @@ export const takeFrameAndCompose = async ({
return {buffer: null, collectedAssets};
}
- if (imageFormat === 'pdf' && clipRegion !== null) {
- throw new Error("You cannot use `<Clipper>` if `imageFormat` is 'pdf'.");
- }
-
const needsComposing =
clipRegion === null
? null
@@ -101,6 +97,12 @@ export const takeFrameAndCompose = async ({
}
if (needsComposing) {
+ if (imageFormat === 'pdf') {
+ throw new Error(
+ "You cannot use compositor APIs (like <Clipper>) if `imageFormat` is 'pdf'."
+ );
+ }
+
await compose({
height: height * scale,
width: width * scale,