Skip to content

🎥 Make videos programmatically with React

docuement renderStillOnLambda()

Jonny Burger00e2877013b0
diff --git a/packages/core/src/config/image-format.ts b/packages/core/src/config/image-format.ts
index 6d6af95617..761f7553c2 100644
--- a/packages/core/src/config/image-format.ts
+++ b/packages/core/src/config/image-format.ts
@@ -3,6 +3,7 @@ import {PixelFormat} from './pixel-format';
const validOptions = ['png', 'jpeg', 'none'] as const;
export type ImageFormat = typeof validOptions[number];
+export type StillImageFormat = 'png' | 'jpeg';
let currentImageFormat: ImageFormat | undefined;
diff --git a/packages/core/src/config/index.ts b/packages/core/src/config/index.ts
index dcfb4bc0ba..33a14662b3 100644
--- a/packages/core/src/config/index.ts
+++ b/packages/core/src/config/index.ts
@@ -5,7 +5,7 @@ import {Concurrency, setConcurrency} from './concurrency';
import {setCrf} from './crf';
import {setDotEnvLocation} from './env-file';
import {FrameRange, setFrameRange} from './frame-range';
-import {ImageFormat, setImageFormat} from './image-format';
+import {ImageFormat, setImageFormat, StillImageFormat} from './image-format';
import {setImageSequence} from './image-sequence';
import {LogLevel, setLogLevel} from './log';
import {setMaxTimelineTracks} from './max-timeline-tracks';
@@ -149,4 +149,5 @@ export type {
Browser,
FrameRange,
LogLevel,
+ StillImageFormat,
};
diff --git a/packages/docs/docs/render-frames.md b/packages/docs/docs/render-frames.md
index e626c2b7d7..19e0879550 100644
--- a/packages/docs/docs/render-frames.md
+++ b/packages/docs/docs/render-frames.md
@@ -19,7 +19,7 @@ const renderFrames: (options: {
}) => void;
outputDir: string;
inputProps: unknown;
- webpackBundle: string;
+ serveUrl: string;
imageFormat: "png" | "jpeg" | "none";
envVariables?: Record<string, string>;
parallelism?: number | null;
@@ -75,9 +75,9 @@ A `string` specifying the directory (absolute path) to which frames should be sa
[Custom props which will be passed to the component.](/docs/parametrized-rendering) Useful for rendering videos with dynamic content. Can be an object of any shape.
-### `webpackBundle`
+### `serveUrl`
-A `string` specifying the location of the bundled Remotion project.
+TODO: Update API for serveUrl
### `imageFormat`
diff --git a/packages/docs/docs/render-still.md b/packages/docs/docs/render-still.md
index d419b8b7b3..ca8310131e 100644
--- a/packages/docs/docs/render-still.md
+++ b/packages/docs/docs/render-still.md
@@ -42,7 +42,7 @@ if (!composition) {
await renderStill({
composition,
- webpackBundle: bundleLocation,
+ serveUrl: bundleLocation,
output: '/tmp/still.png',
inputProps: {
custom: 'data'
@@ -58,9 +58,9 @@ Takes an object with the following properties:
A video composition object, consisting of `id`, `height`, `width`, `durationInFrames` and `fps`. Use [`getCompositions()`](/docs/get-compositions) to get a list of available video configs.
-### `webpackBundle`
+### `serveUrl`
-The absolute location of your webpack bundle. Use [`bundle()`](/docs/bundle) to bundle your project programmatically.
+TODO: Document serveUrl behavior
### `output`
diff --git a/packages/docs/docs/renderstillonlambda.md b/packages/docs/docs/renderstillonlambda.md
index 19bf3cc6f2..70e33429c7 100644
--- a/packages/docs/docs/renderstillonlambda.md
+++ b/packages/docs/docs/renderstillonlambda.md
@@ -4,4 +4,65 @@ title: renderStillOnLambda()
slug: /lambda/renderstillonlambda
---
-TODO
+Renders a still image inside a lambda function and writes it to the specified output location.
+
+If you want to render a video instead, use [`renderVideoOnLamda()`](/docs/lambda/rendervideoonlambda) instead.
+
+If you want to render a still locally instead, use [`renderStill()`](/docs/renderstill) instead.
+
+## Example
+
+```tsx twoslash
+// @module: esnext
+// @target: es2017
+import {renderStillOnLambda} from '@remotion/lambda';
+// ---cut---
+
+const {
+ estimatedPrice,
+ url,
+ size
+} = await renderStillOnLambda({
+ region: 'us-east-1',
+ functionName: 'remotion-render-bds9aab',
+ serveUrl: 'https://remotionlambda-qg35eyp1s1.s3.eu-central-1.amazonaws.com/sites/bf2jrbfkw',
+ composition: 'MyVideo',
+ inputProps: {},
+ imageFormat: 'png',
+ maxRetries: 3,
+ privacy: 'public',
+ envVariables: {},
+ frame: 10
+})
+```
+
+## Arguments
+
+An object with the following properties:
+
+### `region`
+
+In which region your Lambda function is deployed. It's highly recommended that your Remotion site is also in the same region.
+
+### `functionName`
+
+The name of the deployed Lambda function.
+Use [`deployFunction()`](/docs/lambda/deployfunction) to create a new function and [`getFunctions()`](/docs/lambda/getfunctions) to obtain currently deployed Lambdas.
+
+### `serveUrl`
+
+A URL pointing to a Remotion project. Use [`deployProject()`](/docs/lambda/deployproject) to deploy a Remotion project.
+
+### `composition`
+
+The name of the [composition](/docs/composition) you want to render..
+
+### `inputProps`
+
+React props that are passed to your composition. You define the shape of the props that the component accepts.
+
+### `imageFormat?`
+
+_optional - default _
+
+The image format that you want
diff --git a/packages/docs/docs/rendervideoonlambda.md b/packages/docs/docs/rendervideoonlambda.md
index a087d09020..9cca960059 100644
--- a/packages/docs/docs/rendervideoonlambda.md
+++ b/packages/docs/docs/rendervideoonlambda.md
@@ -45,7 +45,7 @@ A URL pointing to a Remotion project. Use [`deployProject()`](/docs/lambda/deplo
### `composition`
-The name of the [composition](/docs/composition) you want to render..
+The name of the [composition](/docs/composition) you want to render.
### `inputProps`
diff --git a/packages/lambda/src/api/render-still-on-lambda.ts b/packages/lambda/src/api/render-still-on-lambda.ts
index c6a144e40f..ddc0d30cfe 100644
--- a/packages/lambda/src/api/render-still-on-lambda.ts
+++ b/packages/lambda/src/api/render-still-on-lambda.ts
@@ -1,4 +1,4 @@
-import {ImageFormat} from 'remotion';
+import {StillImageFormat} from 'remotion';
import {AwsRegion} from '../pricing/aws-regions';
import {callLambda} from '../shared/call-lambda';
import {LambdaRoutines} from '../shared/constants';
@@ -37,7 +37,7 @@ export const renderStillOnLambda = async ({
serveUrl: string;
composition: string;
inputProps: unknown;
- imageFormat: ImageFormat;
+ imageFormat: StillImageFormat;
maxRetries: number;
privacy: 'private' | 'public';
envVariables?: Record<string, string>;
diff --git a/packages/lambda/src/index.ts b/packages/lambda/src/index.ts
index f0edd9b4b4..e88dfc9e8b 100644
--- a/packages/lambda/src/index.ts
+++ b/packages/lambda/src/index.ts
@@ -11,6 +11,7 @@ import {
getRolePolicy,
getUserPolicy,
} from './api/iam-validation/suggested-policy';
+import {renderStillOnLambda} from './api/render-still-on-lambda';
import {renderVideoOnLambda} from './api/render-video-on-lambda';
import {LambdaInternals} from './internals';
import {AwsRegion} from './pricing/aws-regions';
@@ -31,5 +32,6 @@ export {
getFunctionInfo,
estimatePrice,
LambdaInternals,
+ renderStillOnLambda,
};
export type {AwsRegion};
diff --git a/packages/lambda/src/shared/constants.ts b/packages/lambda/src/shared/constants.ts
index 78a4404038..bcf38004d6 100644
--- a/packages/lambda/src/shared/constants.ts
+++ b/packages/lambda/src/shared/constants.ts
@@ -211,12 +211,13 @@ export type RenderMetadata = {
};
export type LambdaVersions =
+ | '2021-08-06'
| '2021-07-14'
| '2021-07-05'
| '2021-07-02'
| '2021-06-23'
| 'n/a';
-export const CURRENT_VERSION: LambdaVersions = '2021-07-14';
+export const CURRENT_VERSION: LambdaVersions = '2021-08-06';
export type PostRenderData = {
cost: {
diff --git a/packages/renderer/src/puppeteer-screenshot.ts b/packages/renderer/src/puppeteer-screenshot.ts
index b69ff8b2a9..86344516d3 100644
--- a/packages/renderer/src/puppeteer-screenshot.ts
+++ b/packages/renderer/src/puppeteer-screenshot.ts
@@ -1,5 +1,6 @@
import * as assert from 'assert';
import {Page, ScreenshotOptions} from 'puppeteer-core';
+import {StillImageFormat} from 'remotion';
import {_screenshotTask} from './screenshot-task';
export const screenshot = async (
@@ -92,6 +93,6 @@ export const screenshot = async (
// @ts-expect-error
return (page as Page)._screenshotTaskQueue.postTask(() =>
- _screenshotTask(page, screenshotType as 'png' | 'jpeg', options)
+ _screenshotTask(page, screenshotType as StillImageFormat, options)
);
};
diff --git a/packages/renderer/src/render-still.ts b/packages/renderer/src/render-still.ts
index 5e3283ac25..18be195784 100644
--- a/packages/renderer/src/render-still.ts
+++ b/packages/renderer/src/render-still.ts
@@ -1,7 +1,7 @@
import fs, {mkdirSync, statSync} from 'fs';
import path from 'path';
import {Browser as PuppeteerBrowser} from 'puppeteer-core';
-import {Browser, Internals, TCompMetadata} from 'remotion';
+import {Browser, Internals, StillImageFormat, TCompMetadata} from 'remotion';
import {openBrowser} from './open-browser';
import {provideScreenshot} from './provide-screenshot';
import {seekToFrame} from './seek-to-frame';
@@ -30,7 +30,7 @@ export const renderStill = async ({
serveUrl: string;
frame?: number;
inputProps?: unknown;
- imageFormat?: 'png' | 'jpeg';
+ imageFormat?: StillImageFormat;
quality?: number;
browser?: Browser;
puppeteerInstance?: PuppeteerBrowser;
diff --git a/packages/renderer/src/screenshot-task.ts b/packages/renderer/src/screenshot-task.ts
index c2ee674541..680e744c8d 100644
--- a/packages/renderer/src/screenshot-task.ts
+++ b/packages/renderer/src/screenshot-task.ts
@@ -1,10 +1,10 @@
import fs from 'fs';
import {Page, ScreenshotOptions} from 'puppeteer-core';
-import {Internals} from 'remotion';
+import {Internals, StillImageFormat} from 'remotion';
export const _screenshotTask = async (
page: Page,
- format: 'png' | 'jpeg',
+ format: StillImageFormat,
options: ScreenshotOptions
): Promise<Buffer | string> => {
const client = (page as any)._client;