Spaces:
Running
Running
Download source/render.mjs from Ethscriptions/truth-or-dare: direct link, hf CLI and curl.
- Browser
- Download file 1.46 kB
-
https://huggingface.co/spaces/Ethscriptions/truth-or-dare/resolve/main/source/render.mjs
- Command line
-
hf download hf://spaces/Ethscriptions/truth-or-dare/source/render.mjs
-
curl -L -o render.mjs https://huggingface.co/spaces/Ethscriptions/truth-or-dare/resolve/main/source/render.mjs
1.46 kB
| import fs from 'node:fs/promises'; | |
| import path from 'node:path'; | |
| import {bundle} from '@remotion/bundler'; | |
| import {selectComposition, renderMedia, renderStill} from '@remotion/renderer'; | |
| const hands = process.argv.slice(2).filter((a) => !a.startsWith('--')); | |
| const want = hands.length ? hands : ['rock', 'scissors', 'paper']; | |
| const coverFrame = 6; | |
| const serveUrl = await bundle({entryPoint: path.resolve('src/index.tsx'), publicDir: path.resolve('public')}); | |
| for (const hand of want) { | |
| const out = path.resolve('out', hand); | |
| await fs.mkdir(out, {recursive: true}); | |
| const composition = await selectComposition({serveUrl, id: `tod-${hand}`}); | |
| const common = {composition, serveUrl}; | |
| await renderMedia({...common, codec: 'h264', pixelFormat: 'yuv420p', crf: 17, audioCodec: 'aac', outputLocation: path.join(out, 'motion.mp4'), concurrency: 2}); | |
| await renderStill({...common, frame: coverFrame, imageFormat: 'jpeg', jpegQuality: 96, output: path.join(out, 'cover.jpg')}); | |
| for (const frame of [0, 16, 24, 34, 44, 50, 56, 70, 89]) await renderStill({...common, frame, imageFormat: 'jpeg', jpegQuality: 80, output: path.join(out, `frame-${frame}.jpg`)}); | |
| await fs.writeFile(path.join(out, 'render.json'), JSON.stringify({hand, fps: composition.fps, durationInFrames: composition.durationInFrames, width: composition.width, height: composition.height, coverFrame, coverTime: coverFrame / composition.fps}, null, 2)); | |
| console.log('rendered', hand); | |
| } | |