Render all compositions
In some scenarios, you might find it useful to render all compositions.
Via CLI
You can combine the npx remotion compositions
command with a bash loop:
render-all.shsh
compositions=($(npx remotion compositions src/index.ts -q))for composition in "${compositions[@]}"donpx remotion render src/index.ts $composition $composition.mp4done
render-all.shsh
compositions=($(npx remotion compositions src/index.ts -q))for composition in "${compositions[@]}"donpx remotion render src/index.ts $composition $composition.mp4done
You can execute it using:
sh
sh ./render-all.sh
sh
sh ./render-all.sh
note
This only works on UNIX-based systems (Linux, macOS) and on WSL in Windows.
Via Node.JS script
You can create a script that fits you using the Node.JS APIs. Below is an example
render-all.mjsts
import {bundle } from "@remotion/bundler";import {getCompositions ,renderMedia } from "@remotion/renderer";import {createRequire } from "module";constrequire =createRequire (import.meta .url );constbundled = awaitbundle ({entryPoint :require .resolve ("./src/index.ts"),// If you have a Webpack override, make sure to add it herewebpackOverride : (config ) =>config ,});constcompositions = awaitgetCompositions (bundled );for (constcomposition ofcompositions ) {console .log (`Rendering ${composition .id }...`);awaitrenderMedia ({codec : "h264",composition ,serveUrl :bundled ,outputLocation : `out/${composition .id }.mp4`,});}
render-all.mjsts
import {bundle } from "@remotion/bundler";import {getCompositions ,renderMedia } from "@remotion/renderer";import {createRequire } from "module";constrequire =createRequire (import.meta .url );constbundled = awaitbundle ({entryPoint :require .resolve ("./src/index.ts"),// If you have a Webpack override, make sure to add it herewebpackOverride : (config ) =>config ,});constcompositions = awaitgetCompositions (bundled );for (constcomposition ofcompositions ) {console .log (`Rendering ${composition .id }...`);awaitrenderMedia ({codec : "h264",composition ,serveUrl :bundled ,outputLocation : `out/${composition .id }.mp4`,});}
Executebash
node render-all.mjs
Executebash
node render-all.mjs