Skip to content

🎥 Make videos programmatically with React

ssr legacy

Jonny Burgere4386e87f139
diff --git a/packages/docs/docs/artifacts.mdx b/packages/docs/docs/artifacts.mdx
index 014c7f92dd..26ddfc9c14 100644
--- a/packages/docs/docs/artifacts.mdx
+++ b/packages/docs/docs/artifacts.mdx
@@ -52,8 +52,8 @@ export const MyComp: React.FC = () => {
Otherwise, the asset will get emitted multiple times. <br />
<Step>2</Step> It is possible to emit multiple assets, but they may not have the
-same filename.
-<br />
+same filename.<br/>
+
<Step>3</Step> For the <code>content</code> prop it is possible to pass a <code>string</code>, or a <code>Uint8Array</code> for binary data. Passing an <code>
Uint8Array
</code> should not be considered faster due to it having to be serialized.
@@ -86,5 +86,104 @@ const composition: VideoConfig = {
};
const serveUrl = 'http://localhost:8080';
const inputProps = {};
+import fs from 'fs';
+// ---cut---
+import {renderMedia, OnArtifact} from '@remotion/renderer';
+
+const onArtifact: OnArtifact = (artifact) => {
+ console.log(artifact.filename); // string
+ console.log(artifact.content); // string | Uint8Array
+ console.log(artifact.frame); // number, frame in the composition which emitted this
+
+ // Example action: Write the artifact to disk
+ fs.writeFileSync(artifact.filename, artifact.content);
+};
+
+await renderMedia({
+ composition,
+ serveUrl,
+ onArtifact,
+ codec: 'h264',
+ inputProps,
+});
+```
+### Using the Remotion Lambda CLI
+
+When using [`npx remotion lambda render`](/docs/lambda/cli/render) or [`npx remotion lambda still`](/docs/lambda/cli/still), artifacts get saved to the S3 bucket under the key `renders/[render-id]/artifacts/[filename]`.
+
+They will get logged to the console and you can click them to download them.
+The `--privacy` option also applies to artifacts.
+
+### Using `renderMediaOnLambda()`
+
+When using [`renderMediaOnLambda()`](/docs/lambda/rendermediaonlambda), artifacts get saved to the S3 bucket under the key `renders/[render-id]/artifacts/[filename]`.
+
+You can obtain a list of currently received assets from [`getRenderProgress()`](/docs/lambda/getrenderprogress#artifacts).
+
+```tsx twoslash title="progress.ts"
+// @module: es2022
+// @target: es2017
+import {getRenderProgress} from '@remotion/lambda/client';
+
+const renderProgress = await getRenderProgress({
+ renderId: 'hi',
+ functionName: 'hi',
+ bucketName: 'hi',
+ region: 'eu-central-1',
+});
+
+for (const artifact of renderProgress.artifacts) {
+ console.log(artifact.filename); // "hello-world.txt"
+ console.log(artifact.sizeInBytes); // 12
+ console.log(artifact.s3Url); // "https://s3.eu-central-1.amazonaws.com/remotion-lambda-abcdef/renders/abcdef/artifacts/hello-world.txt"
+ console.log(artifact.s3Key); // "renders/abcdef/artifacts/hello-world.txt"
+}
```
+
+### Using `renderStillOnLambda()`
+
+When using [`renderStillOnLambda()`](/docs/lambda/renderstillonlambda), artifacts get saved to the S3 bucket under the key `renders/[render-id]/artifacts/[filename]`.
+
+You can obtain a list of received assets from [`artifacts`](/docs/lambda/renderstillonlambda#artifacts) field of `renderStillOnLambda()`.
+
+```tsx twoslash title="still.ts"
+const serveUrl = 'http://localhost:8080';
+const inputProps = {};
+const functionName = 'hi';
+const composition = 'hi';
+const privacy = 'public' as const;
+const imageFormat = 'png' as const;
+const region = 'eu-central-1' as const;
+
+// ---cut---
+// @module: es2022
+// @target: es2017
+import {renderStillOnLambda} from '@remotion/lambda/client';
+
+const stillResponse = await renderStillOnLambda({
+ functionName,
+ region,
+ serveUrl,
+ composition,
+ inputProps,
+ imageFormat,
+ privacy,
+});
+
+for (const artifact of stillResponse.artifacts) {
+ console.log(artifact.filename); // "hello-world.txt"
+ console.log(artifact.sizeInBytes); // 12
+ console.log(artifact.s3Url); // "https://s3.eu-central-1.amazonaws.com/remotion-lambda-abcdef/renders/abcdef/artifacts/hello-world.txt"
+ console.log(artifact.s3Key); // "renders/abcdef/artifacts/hello-world.txt"
+}
+```
+
+### Using Cloud Run
+
+In the Cloud Run Alpha, emitting artifacts is not supported and will throw an error.
+We plan on revising Cloud Run to use the same runtime as Lambda in the future and will bring this feature along.
+
+## See also
+
+- [`<Artifact>`](/docs/artifact)
diff --git a/packages/docs/docs/ssr-legacy.mdx b/packages/docs/docs/ssr-legacy.mdx
index df85942ed7..fcaa83eec0 100644
--- a/packages/docs/docs/ssr-legacy.mdx
+++ b/packages/docs/docs/ssr-legacy.mdx
@@ -118,47 +118,6 @@ const start = async () => {
start();
```
-## Render using a HTTP server
-
-In the [template](/docs#installation), we added a minimal example of an HTTP server that dynamically returns a video whenever you call the URL.
-
-The server is located under `server.tsx`, and you can run it using `npm run server`. Call the default URL with parameters, and it will return a video after some time! Try it out in the browser or using cURL:
-
-```bash
-curl "http://localhost:8000?titleText=Hello,+World!&titleColor=red" > output.mp4
-```
-
-Note that we only added a minimal example. For production, you should consider adding a queueing system and rate limiting.
-
-## Render using a HTTP server (Dockerized)
-
-We added a Dockerfile that includes FFMPEG and added it to the template. That means you can also run the server described in the section above using Docker.
-
-```bash
-docker build -t my-video .
-docker run -p 8000:8000 --privileged my-video
-```
-
-## Render using GitHub Actions
-
-The template includes a GitHub Actions workflow file
-under `.github/workflows/render-video.yml`. All you have to do is to adjust the props that your root component accepts in the workflow file and you can render a video right on GitHub.
-
-1. Commit the template to a GitHub repository
-2. On GitHub, click the 'Actions' tab.
-3. Select the 'Render video' workflow on the left.
-4. A 'Run workflow' button should appear. Click it
-5. Fill in the props of the root component and click 'Run workflow'.
-6. After the rendering is finished, you can download the video under 'Artifacts'.
-
-Note that running the workflow may incur costs. However, the workflow will only run if you actively trigger it.
-
-[See also: Passing props in GitHub Actions](/docs/passing-props#passing-input-props-in-github-actions)
-
-## Rendering a video using serverless
-
-We are working on a library which will help you render videos using AWS Lambda. Contact us if you are interested in testing an early version or read the `#lambda` channel on our Discord server.
-
## API reference
- [bundle()](/docs/bundle)