🎥 Make videos programmatically with React
Docs: Separate page for the SSR example
Jonny Burger4bb0ce9ff017
diff --git a/packages/docs/docs/ssr-node.mdx b/packages/docs/docs/ssr-node.mdxnew file mode 100644index 0000000000..5368ee8bd5--- /dev/null+++ b/packages/docs/docs/ssr-node.mdx@@ -0,0 +1,84 @@+---+image: /generated/articles-docs-ssr-node.png+id: ssr-node+title: Rendering using SSR APIs+crumb: "Server-side rendering"+sidebar_label: Example+---++The NPM package [`@remotion/renderer`](/docs/renderer) provides you with an API for rendering media programmatically.+These functions can be used in Node.js and Bun.++Rendering a video takes three steps:++<Step>1</Step> Creating a <a href="/docs/terminology#bundle">Remotion Bundle</a>+<br />+<Step>2</Step> Select the composition to render and calculate its metadata+<br />+<Step>3</Step> Render the video, audio, still or image sequence.+<br />+<br />++Follow this commented example to see how to render a video:++```tsx twoslash title="render.mjs"+// @module: ESNext+// @target: ESNext+import { bundle } from "@remotion/bundler";+import { renderMedia, selectComposition } from "@remotion/renderer";+import path from "path";++// The composition you want to render+const compositionId = "HelloWorld";++// You only have to create a bundle once, and you may reuse it+const bundleLocation = await bundle({+ entryPoint: path.resolve("./src/index"),+ // If you have a Webpack override, make sure to add it here+ webpackOverride: (config) => config,+});++// Parametrize the video by passing props to your component.+const inputProps = {+ foo: "bar",+};++// Get the composition you want to render. Pass `inputProps` if you+// want to customize the duration or other metadata.+const composition = await selectComposition({+ serveUrl: bundleLocation,+ id: compositionId,+ inputProps,+});++// Render the video. Pass the same `inputProps` again+// if your video is parametrized with data.+await renderMedia({+ composition,+ serveUrl: bundleLocation,+ codec: "h264",+ outputLocation: `out/${compositionId}.mp4`,+ inputProps,+});++console.log("Render done!");+```++This flow is customizable. Click on one of the SSR APIs to read about its options:++- [`getCompositions()`](/docs/renderer/get-compositions) - Get a list of available compositions from a Remotion project.+- [`selectComposition()`](/docs/renderer/select-composition) - Get a list of available compositions from a Remotion project.+- [`renderMedia()`](/docs/renderer/render-media) - Render a video or audio.+- [`renderFrames()`](/docs/renderer/render-frames) - Render an image sequence.+- [`renderStill()`](/docs/renderer/render-still) - Render a still image.+- [`stitchFramesToVideo()`](/docs/renderer/stitch-frames-to-video) - Encode a video based on an image sequence+- [`openBrowser()`](/docs/renderer/open-browser) - Share a browser instance across function calls for improved performance.++## SSR APIs in Next.js++If you are using Next.js, you will not be able to use `@remotion/bundler` because of the limitations explained in [Can I render videos in Next.js?](https://www.remotion.dev/docs/miscellaneous/vercel-functions#can-i-render-videos-in-nextjs) Refer to the page for possible alternatives.+We recommend [Lambda](/docs/lambda) for use in Next.js.++## See also++- [Server-side rendering](/docs/ssr)diff --git a/packages/docs/docs/ssr.md b/packages/docs/docs/ssr.mdindex f003a1a790..d9e0def20d 100644--- a/packages/docs/docs/ssr.md+++ b/packages/docs/docs/ssr.md@@ -14,71 +14,10 @@ Remotion's rendering engine is built with Node.JS, which makes it easy to renderThe easiest and fastest way to render videos in the cloud is to use [`@remotion/lambda`](/docs/lambda).-## Render a video using Node.JS APIs--The NPM package `@remotion/renderer` provides you with an API for rendering media programmatically. You can make a video in three steps:--<Step>1</Step> Creating a <a href="/docs/terminology#bundle">Remotion Bundle</a><br/>-<Step>2</Step> Select the composition to render and calculate its metadata<br/>-<Step>3</Step> Rendering frames and stitching them together to an MP4.<br/><br/>--Follow this commented example to see how to render a video:--```tsx twoslash title="render.mjs"-// @module: ESNext-// @target: ESNext-import { bundle } from "@remotion/bundler";-import { renderMedia, selectComposition } from "@remotion/renderer";-import path from "path";--// The composition you want to render-const compositionId = "HelloWorld";--// You only have to create a bundle once, and you may reuse it-const bundleLocation = await bundle({- entryPoint: path.resolve("./src/index"),- // If you have a Webpack override, make sure to add it here- webpackOverride: (config) => config,-});--// Parametrize the video by passing arbitrary props to your component.-const inputProps = {- foo: "bar",-};--// Get the composition you want to render. Pass inputProps if you want to customize the-// duration or other metadata.-const composition = await selectComposition({- serveUrl: bundleLocation,- id: compositionId,- inputProps,-});--// Render the video-await renderMedia({- composition,- serveUrl: bundleLocation,- codec: "h264",- outputLocation: `out/${compositionId}.mp4`,- inputProps,-});--console.log("Render done!");-```--This flow is highly customizable. Click on one of the SSR APIs to read about it's options:--- [`getCompositions()`](/docs/renderer/get-compositions) - Get a list of available compositions from a Remotion project.-- [`selectComposition()`](/docs/renderer/select-composition) - Get a list of available compositions from a Remotion project.-- [`renderMedia()`](/docs/renderer/render-media) - Render a video or audio.-- [`renderFrames()`](/docs/renderer/render-frames) - Render an image sequence.-- [`renderStill()`](/docs/renderer/render-still) - Render a still image.-- [`stitchFramesToVideo()`](/docs/renderer/stitch-frames-to-video) - Encode a video based on an image sequence-- [`openBrowser()`](/docs/renderer/open-browser) - Share a browser instance across function calls for improved performance.--:::note-If you are using Next.js, you will not be able to use `@remotion/bundler` because of the limitations explained in [Can I render videos in Next.js?](https://www.remotion.dev/docs/miscellaneous/vercel-functions#can-i-render-videos-in-nextjs) Refer to the page for possible alternatives.-:::+## Render a video using Node.js APIs++We provide a set of APIs to render videos using Node.js and Bun.+See an [example](/docs/ssr-node) or the [API reference](/docs/renderer) for more information.## Render using GitHub Actionsdiff --git a/packages/docs/docs/studio.mdx b/packages/docs/docs/studio.mdxindex 6fd056bf4b..8889b8ba55 100644--- a/packages/docs/docs/studio.mdx+++ b/packages/docs/docs/studio.mdx@@ -1,5 +1,5 @@----image: /generated/articles-docs-timeline.png+image: /generated/articles-docs-studio.pngsidebar_label: Preview your videotitle: Remotion Studioid: studiodiff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.jsindex 22cd4149de..5d8933eaaa 100644--- a/packages/docs/sidebars.js+++ b/packages/docs/sidebars.js@@ -517,11 +517,7 @@ module.exports = {},items: ["ssr",- {- type: "link",- href: "/docs/renderer",- label: "@remotion/renderer API",- },+ "ssr-node","docker","deploy-studio","miscellaneous/linux-single-process",diff --git a/packages/docs/src/data/articles.ts b/packages/docs/src/data/articles.tsindex bd8df25538..3e2ef06b73 100644--- a/packages/docs/src/data/articles.ts+++ b/packages/docs/src/data/articles.ts@@ -2012,7 +2012,7 @@ export const articles = [},{id: "render-as-gif",- title: "Render as GIF",+ title: "Rendering GIFs",relativePath: "docs/render-as-gif.md",compId: "articles-docs-render-as-gif",crumb: "Techniques",@@ -2325,6 +2325,13 @@ export const articles = [compId: "articles-docs-ssr-legacy",crumb: "Legacy docs",},+ {+ id: "ssr-node",+ title: "Rendering using SSR APIs",+ relativePath: "docs/ssr-node.mdx",+ compId: "articles-docs-ssr-node",+ crumb: "Server-side rendering",+ },{id: "ssr",title: "Server-Side Rendering",@@ -2367,6 +2374,13 @@ export const articles = [compId: "articles-docs-stills",crumb: "How to generate",},+ {+ id: "studio",+ title: "Remotion Studio",+ relativePath: "docs/studio.mdx",+ compId: "articles-docs-studio",+ crumb: "Timeline basics",+ },{id: "support",title: "Support Policy",@@ -2444,13 +2458,6 @@ export const articles = [compId: "articles-docs-three",crumb: null,},- {- id: "timeline",- title: "Preview your video",- relativePath: "docs/timeline.md",- compId: "articles-docs-timeline",- crumb: "Timeline basics",- },{id: "timeout",title: "Debugging timeouts",@@ -2468,77 +2475,77 @@ export const articles = [{id: "transitions/index",title: "@remotion/transitions",- relativePath: "docs/transitions/index.md",+ relativePath: "docs/transitions/index.mdx",compId: "articles-docs-transitions-index",crumb: null,},{id: "transitions/presentations/custom",title: "Custom presentations",- relativePath: "docs/transitions/presentations/custom.md",+ relativePath: "docs/transitions/presentations/custom.mdx",compId: "articles-docs-transitions-presentations-custom",crumb: "@remotion/transitions",},{id: "transitions/presentations/fade",title: "fade()",- relativePath: "docs/transitions/presentations/fade.md",+ relativePath: "docs/transitions/presentations/fade.mdx",compId: "articles-docs-transitions-presentations-fade",crumb: "@remotion/transitions - Presentations",},{id: "transitions/presentations/index",title: "Presentations",- relativePath: "docs/transitions/presentations/index.md",+ relativePath: "docs/transitions/presentations/index.mdx",compId: "articles-docs-transitions-presentations-index",crumb: "@remotion/transitions",},{id: "transitions/presentations/slide",title: "slide()",- relativePath: "docs/transitions/presentations/slide.md",+ relativePath: "docs/transitions/presentations/slide.mdx",compId: "articles-docs-transitions-presentations-slide",crumb: "@remotion/transitions - Presentations",},{id: "transitions/presentations/wipe",title: "wipe()",- relativePath: "docs/transitions/presentations/wipe.md",+ relativePath: "docs/transitions/presentations/wipe.mdx",compId: "articles-docs-transitions-presentations-wipe",crumb: "@remotion/transitions - Presentations",},{id: "transitions/timings/custom",title: "Custom timings",- relativePath: "docs/transitions/timings/custom.md",+ relativePath: "docs/transitions/timings/custom.mdx",compId: "articles-docs-transitions-timings-custom",crumb: "@remotion/transitions",},{id: "transitions/timings/index",title: "Timings",- relativePath: "docs/transitions/timings/index.md",+ relativePath: "docs/transitions/timings/index.mdx",compId: "articles-docs-transitions-timings-index",crumb: "@remotion/transitions",},{id: "transitions/timings/lineartiming",title: "linearTiming()",- relativePath: "docs/transitions/timings/lineartiming.md",+ relativePath: "docs/transitions/timings/lineartiming.mdx",compId: "articles-docs-transitions-timings-lineartiming",crumb: "@remotion/transitions - Timings",},{id: "transitions/timings/springtiming",title: "springTiming()",- relativePath: "docs/transitions/timings/springtiming.md",+ relativePath: "docs/transitions/timings/springtiming.mdx",compId: "articles-docs-transitions-timings-springtiming",crumb: "@remotion/transitions - Timings",},{id: "transitions/transitionseries",title: "<TransitionSeries>",- relativePath: "docs/transitions/transitionseries.md",+ relativePath: "docs/transitions/transitionseries.mdx",compId: "articles-docs-transitions-transitionseries",crumb: "@remotion/transitions",},diff --git a/packages/docs/static/generated/articles-docs-ssr-node.png b/packages/docs/static/generated/articles-docs-ssr-node.pngnew file mode 100644index 0000000000..c1eef8142cBinary files /dev/null and b/packages/docs/static/generated/articles-docs-ssr-node.png differdiff --git a/packages/docs/static/generated/articles-docs-studio.png b/packages/docs/static/generated/articles-docs-studio.pngnew file mode 100644index 0000000000..ba9a7927c0Binary files /dev/null and b/packages/docs/static/generated/articles-docs-studio.png differ