Skip to main content

呈现所有作品

在某些情况下,你可能会发现渲染所有合成是有用的。

🌐 In some scenarios, you might find it useful to render all compositions.

通过命令行接口

🌐 Via CLI

你可以将 npx remotion compositions 命令与 bash 循环结合使用:

🌐 You can combine the npx remotion compositions command with a bash loop:

render-all.sh
compositions=($(npx remotion compositions src/index.ts -q)) for composition in "${compositions[@]}" do npx remotion render src/index.ts $composition $composition.mp4 done

你可以使用以下方式执行它:

🌐 You can execute it using:

sh ./render-all.sh
note

这仅适用于基于UNIX的系统(Linux、macOS)以及Windows中的WSL。

通过 Node.JS 脚本

🌐 Via Node.JS script

你可以使用 Node.JS APIs 创建一个适合你的脚本。下面是一个示例

🌐 You can create a script that fits you using the Node.JS APIs. Below is an example

render-all.mjs
import {bundle} from '@remotion/bundler'; import {getCompositions, renderMedia} from '@remotion/renderer'; import {createRequire} from 'module'; const require = createRequire(import.meta.url); const bundled = await bundle({ entryPoint: require.resolve('./src/index.ts'), // If you have a Webpack override, make sure to add it here webpackOverride: (config) => config, }); const compositions = await getCompositions(bundled); for (const composition of compositions) { console.log(`Rendering ${composition.id}...`); await renderMedia({ codec: 'h264', composition, serveUrl: bundled, outputLocation: `out/${composition.id}.mp4`, }); }
Execute
node render-all.mjs

另请参阅

🌐 See also