Spaces:
Sleeping
Sleeping
Commit
·
93540c2
1
Parent(s):
737b72d
RXP
Browse files- proxy-renderer.js +70 -0
- renderer.js +8 -2
- server.js +1 -1
- test-render.js → ssr.js +0 -0
proxy-renderer.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { renderFrames, renderStill, stitchFramesToVideo } from '@remotion/renderer';
|
| 2 |
+
import { bundle } from '@remotion/bundler';
|
| 3 |
+
import path from 'path';
|
| 4 |
+
import fs from 'fs';
|
| 5 |
+
|
| 6 |
+
const { RenderUtils } = await import('./src/RenderUtils.cjs');
|
| 7 |
+
const { GenerateScript } = await import('./src/GenerateScript.cjs');
|
| 8 |
+
|
| 9 |
+
const originalManuScriptPath = path.join(process.cwd(), 'public/original_manuscript.json');
|
| 10 |
+
|
| 11 |
+
export const renderProxy = async (outFile, frameRange) => {
|
| 12 |
+
const ScriptStr = fs.readFileSync(originalManuScriptPath);
|
| 13 |
+
const ScriptInput = JSON.parse(ScriptStr);
|
| 14 |
+
let {
|
| 15 |
+
duration,
|
| 16 |
+
Script,
|
| 17 |
+
contents,
|
| 18 |
+
intro,
|
| 19 |
+
outro,
|
| 20 |
+
playListsIDs
|
| 21 |
+
} = GenerateScript(ScriptInput)
|
| 22 |
+
let renderConfig = {
|
| 23 |
+
composition: {
|
| 24 |
+
id: compositionId,
|
| 25 |
+
fps: Script.meta.fps,
|
| 26 |
+
height: Script.meta?.resolution?.height,
|
| 27 |
+
width: Script.meta?.resolution?.width,
|
| 28 |
+
durationInFrames: duration,
|
| 29 |
+
defaultProps: Object.assign(Script, {
|
| 30 |
+
bgMusic: RenderUtils.getFileName(Script.bgMusic),
|
| 31 |
+
contents: contents,
|
| 32 |
+
intro: intro,
|
| 33 |
+
outro: outro
|
| 34 |
+
}),
|
| 35 |
+
props: Object.assign(Script, {
|
| 36 |
+
bgMusic: RenderUtils.getFileName(Script.bgMusic),
|
| 37 |
+
contents: contents,
|
| 38 |
+
intro: intro,
|
| 39 |
+
outro: outro
|
| 40 |
+
}),
|
| 41 |
+
},
|
| 42 |
+
serveUrl: bundleLocation,
|
| 43 |
+
output: path.join(frameOutputDir, 'output.jpg'),
|
| 44 |
+
// additional renderer options
|
| 45 |
+
audioCodec: 'mp3',
|
| 46 |
+
imageFormat: 'jpeg',
|
| 47 |
+
enableMultiProcessOnLinux: true,
|
| 48 |
+
jpegQuality: 70,
|
| 49 |
+
timeoutInMilliseconds: 60000,
|
| 50 |
+
concurrency: 1,
|
| 51 |
+
gl: 'angle'
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
if (!fs.existsSync(outputDir)) {
|
| 55 |
+
fs.mkdirSync(outputDir, { recursive: true });
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
const resultVideo = await stitchFramesToVideo({
|
| 59 |
+
assetsInfo: result.assetsInfo,
|
| 60 |
+
...renderConfig,
|
| 61 |
+
...renderConfig.composition,
|
| 62 |
+
audioCodec: 'mp3',
|
| 63 |
+
outputLocation: outFile,
|
| 64 |
+
verbose: true
|
| 65 |
+
})
|
| 66 |
+
|
| 67 |
+
console.log('resultVideo', resultVideo)
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
}
|
renderer.js
CHANGED
|
@@ -7,6 +7,7 @@ import {fileURLToPath} from 'url';
|
|
| 7 |
import { platform } from 'os';
|
| 8 |
import { renderSSR } from './test-render.js';
|
| 9 |
import path from 'path';
|
|
|
|
| 10 |
const {UnzipFiles, Utils, ZipFiles} = pkg;
|
| 11 |
|
| 12 |
const __filename = fileURLToPath(import.meta.url);
|
|
@@ -47,10 +48,15 @@ export function getNpmScript(mediaType) {
|
|
| 47 |
}
|
| 48 |
}
|
| 49 |
|
| 50 |
-
export async function doRender(jobId, composition, sendToObserver, target = 'render', ssrOptions) {
|
| 51 |
let outFile = path.join(process.cwd(), `out`, `${jobId}-video.mp4`);
|
| 52 |
if (ssrOptions) {
|
| 53 |
-
await renderSSR(outFile, ssrOptions.frameRange
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
sendToObserver(jobId, 'completed');
|
| 55 |
return outFile
|
| 56 |
}
|
|
|
|
| 7 |
import { platform } from 'os';
|
| 8 |
import { renderSSR } from './test-render.js';
|
| 9 |
import path from 'path';
|
| 10 |
+
import { renderProxy } from './proxy-renderer.js';
|
| 11 |
const {UnzipFiles, Utils, ZipFiles} = pkg;
|
| 12 |
|
| 13 |
const __filename = fileURLToPath(import.meta.url);
|
|
|
|
| 48 |
}
|
| 49 |
}
|
| 50 |
|
| 51 |
+
export async function doRender(jobId, composition, sendToObserver, target = 'render', ssrOptions, proxyOptions) {
|
| 52 |
let outFile = path.join(process.cwd(), `out`, `${jobId}-video.mp4`);
|
| 53 |
if (ssrOptions) {
|
| 54 |
+
await renderSSR(outFile, ssrOptions.frameRange)
|
| 55 |
+
sendToObserver(jobId, 'completed');
|
| 56 |
+
return outFile
|
| 57 |
+
}
|
| 58 |
+
else if (proxyOptions) {
|
| 59 |
+
await renderProxy(outFile, proxyOptions.frameRange)
|
| 60 |
sendToObserver(jobId, 'completed');
|
| 61 |
return outFile
|
| 62 |
}
|
server.js
CHANGED
|
@@ -45,5 +45,5 @@ io.on('connection', (socket) => {
|
|
| 45 |
});
|
| 46 |
|
| 47 |
server.listen(port, () => {
|
| 48 |
-
console.log(`Server listening on port ${port}`);
|
| 49 |
});
|
|
|
|
| 45 |
});
|
| 46 |
|
| 47 |
server.listen(port, () => {
|
| 48 |
+
console.log(`Remote Render Server listening on port ${port}`);
|
| 49 |
});
|
test-render.js → ssr.js
RENAMED
|
File without changes
|