| 1 | import {bundle} from '@remotion/bundler'; |
| 2 | import {renderMedia, selectComposition} from '@remotion/renderer'; |
| 3 | import path from 'node:path'; |
| 4 | import os from 'node:os'; |
| 5 | |
| 6 | const format = process.argv[2]; |
| 7 | if (!format || !['mp4', 'webm'].includes(format)) { |
| 8 | console.error('Usage: node scripts/render.mjs <mp4|webm>'); |
| 9 | process.exit(1); |
| 10 | } |
| 11 | |
| 12 | const root = path.resolve(process.cwd()); |
| 13 | const entry = path.join(root, 'src', 'index.ts'); |
| 14 | const outDir = path.resolve(root, '..', '..', 'docs', 'assets', 'hero'); |
| 15 | const outPath = path.join(outDir, `customer-provisioning-walkthrough.${format}`); |
| 16 | const tmpDir = path.join(os.tmpdir(), 'copilot-remotion-customer-bundle'); |
| 17 | |
| 18 | const serveUrl = await bundle({ |
| 19 | entryPoint: entry, |
| 20 | outDir: tmpDir, |
| 21 | webpackOverride: (config) => config, |
| 22 | }); |
| 23 | |
| 24 | const composition = await selectComposition({ |
| 25 | serveUrl, |
| 26 | id: 'customer-provisioning-walkthrough', |
| 27 | inputProps: {}, |
| 28 | }); |
| 29 | |
| 30 | await renderMedia({ |
| 31 | composition, |
| 32 | serveUrl, |
| 33 | codec: format === 'webm' ? 'vp9' : 'h264', |
| 34 | outputLocation: outPath, |
| 35 | inputProps: {}, |
| 36 | crf: format === 'webm' ? 36 : 22, |
| 37 | pixelFormat: 'yuv420p', |
| 38 | mute: true, |
| 39 | }); |
| 40 | |
| 41 | console.log(`Rendered ${outPath}`); |