呈现所有作品
在某些情况下,你可能会发现渲染所有合成是有用的。
🌐 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.shcompositions=($(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.shnote
这仅适用于基于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.mjsimport {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`, }); }
Executenode render-all.mjs
另请参阅
🌐 See also