Spaces:
Running
Running
Commit
·
2f9c678
1
Parent(s):
7b4e087
Add cli
Browse files- common-utils +1 -1
- package.json +1 -1
- renderer.js +34 -17
- routes.js +3 -0
common-utils
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
Subproject commit
|
|
|
|
| 1 |
+
Subproject commit d8e83ba4748273a696d23d0a11df0dc1ae7fae32
|
package.json
CHANGED
|
@@ -21,7 +21,7 @@
|
|
| 21 |
"render-build:igreels": "remotion render --audio-codec mp3 --image-format=jpeg --enable-multi-process-on-linux --quality=70 --concurrency 1 --gl=vulkan IGReelComposition",
|
| 22 |
"render-build:win32:auto": "remotion render --audio-codec mp3 --image-format=jpeg --enable-multi-process-on-linux --quality=70 --timeout 60000 --concurrency 1 --gl=angle %npm_config_composition%",
|
| 23 |
"render-build:win32": "remotion %npm_config_target% %npm_config_build_params% %npm_config_composition%",
|
| 24 |
-
"render-build": "remotion $npm_config_target $npm_config_build_params
|
| 25 |
"render-still": "remotion still --image-format=jpeg SemibitCompositionPoster ",
|
| 26 |
"render-image": "remotion still --image-format=jpeg --concurrency 1 $npm_config_composition $npm_config_output",
|
| 27 |
"render-images": "remotion render --enable-multiprocess-on-linux --sequence --image-format=jpeg $npm_config_composition $npm_config_output",
|
|
|
|
| 21 |
"render-build:igreels": "remotion render --audio-codec mp3 --image-format=jpeg --enable-multi-process-on-linux --quality=70 --concurrency 1 --gl=vulkan IGReelComposition",
|
| 22 |
"render-build:win32:auto": "remotion render --audio-codec mp3 --image-format=jpeg --enable-multi-process-on-linux --quality=70 --timeout 60000 --concurrency 1 --gl=angle %npm_config_composition%",
|
| 23 |
"render-build:win32": "remotion %npm_config_target% %npm_config_build_params% %npm_config_composition%",
|
| 24 |
+
"render-build": "remotion $npm_config_target $npm_config_build_params $npm_config_composition $npm_config_out",
|
| 25 |
"render-still": "remotion still --image-format=jpeg SemibitCompositionPoster ",
|
| 26 |
"render-image": "remotion still --image-format=jpeg --concurrency 1 $npm_config_composition $npm_config_output",
|
| 27 |
"render-images": "remotion render --enable-multiprocess-on-linux --sequence --image-format=jpeg $npm_config_composition $npm_config_output",
|
renderer.js
CHANGED
|
@@ -55,8 +55,27 @@ export async function doRender(
|
|
| 55 |
ssrOptions,
|
| 56 |
proxyOptions,
|
| 57 |
controller) {
|
| 58 |
-
const composition = originalManuscript?.meta?.
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
if (target.includes('still')) {
|
| 61 |
outFile = path.join(process.cwd(), `out`, `${jobId}-still.jpg`);
|
| 62 |
}
|
|
@@ -71,25 +90,22 @@ export async function doRender(
|
|
| 71 |
return outFile
|
| 72 |
}
|
| 73 |
const renderComposition = composition || 'SemibitComposition';
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
const cmd = `npm ${args.join(' ')}`;
|
| 85 |
-
const spawnOptions = { detached: false };
|
| 86 |
|
| 87 |
if (platform() === 'win32') {
|
| 88 |
-
spawnOptions.shell = true;
|
| 89 |
spawnOptions.detached = true;
|
| 90 |
}
|
| 91 |
|
| 92 |
-
const childProcess = spawn('
|
| 93 |
let isProcessKilled = false;
|
| 94 |
|
| 95 |
if (controller && controller.stop) {
|
|
@@ -139,7 +155,8 @@ export async function doRender(
|
|
| 139 |
sendToObserver(jobId, data);
|
| 140 |
if (!process.env.is_pm2) console.log(data?.toString());
|
| 141 |
if (updateCounter++ % 100 == 0 || updateCounter < 5) {
|
| 142 |
-
|
|
|
|
| 143 |
}
|
| 144 |
});
|
| 145 |
|
|
|
|
| 55 |
ssrOptions,
|
| 56 |
proxyOptions,
|
| 57 |
controller) {
|
| 58 |
+
const composition = originalManuscript?.meta?.renderComposition || 'SemibitComposition';
|
| 59 |
+
|
| 60 |
+
// Determine file extension based on codec
|
| 61 |
+
let defaultBuildParams = ` --audio-codec mp3 --frames=0-100 --image-format=jpeg --enable-multi-process-on-linux --quality=70 --timeout 60000 --concurrency 1 --gl=angle `;
|
| 62 |
+
let tempBuildParams = ' ' + (originalManuscript?.meta?.generationConfig?.extras?.buildParams || defaultBuildParams) + ' ';
|
| 63 |
+
if (originalManuscript?.meta?.generationConfig?.extras?.additionalBuildParams) {
|
| 64 |
+
tempBuildParams += ' ' + originalManuscript?.meta?.generationConfig?.extras?.additionalBuildParams + ' ';
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
// Extract codec from build params to determine file extension
|
| 68 |
+
const codecMatch = tempBuildParams.match(/--codec[=\s]+([^\s]+)/);
|
| 69 |
+
const codec = codecMatch ? codecMatch[1] : 'h264';
|
| 70 |
+
let videoExtension = '.mp4';
|
| 71 |
+
|
| 72 |
+
if (codec === 'vp8' || codec === 'vp9') {
|
| 73 |
+
videoExtension = '.webm';
|
| 74 |
+
} else if (codec === 'prores') {
|
| 75 |
+
videoExtension = '.mov';
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
let outFile = path.join(process.cwd(), `out`, `${jobId}-video${videoExtension}`);
|
| 79 |
if (target.includes('still')) {
|
| 80 |
outFile = path.join(process.cwd(), `out`, `${jobId}-still.jpg`);
|
| 81 |
}
|
|
|
|
| 90 |
return outFile
|
| 91 |
}
|
| 92 |
const renderComposition = composition || 'SemibitComposition';
|
| 93 |
+
// Use the build params we computed above for codec detection
|
| 94 |
+
const buildParams = tempBuildParams;
|
| 95 |
+
|
| 96 |
+
// Directly call remotion instead of going through npm scripts to avoid parameter parsing issues
|
| 97 |
+
const remotionArgs = ['-y', 'remotion', target, ...buildParams.trim().split(/\s+/).filter(arg => arg), renderComposition, outFile];
|
| 98 |
+
const cmd = `npx ${remotionArgs.join(' ')}`;
|
| 99 |
+
const spawnOptions = {
|
| 100 |
+
detached: false,
|
| 101 |
+
shell: true // Always use shell for proper parameter parsing
|
| 102 |
+
};
|
|
|
|
|
|
|
| 103 |
|
| 104 |
if (platform() === 'win32') {
|
|
|
|
| 105 |
spawnOptions.detached = true;
|
| 106 |
}
|
| 107 |
|
| 108 |
+
const childProcess = spawn('npx', remotionArgs, spawnOptions);
|
| 109 |
let isProcessKilled = false;
|
| 110 |
|
| 111 |
if (controller && controller.stop) {
|
|
|
|
| 155 |
sendToObserver(jobId, data);
|
| 156 |
if (!process.env.is_pm2) console.log(data?.toString());
|
| 157 |
if (updateCounter++ % 100 == 0 || updateCounter < 5) {
|
| 158 |
+
if (data?.split?.('\n')?.[0])
|
| 159 |
+
console.log(data?.split?.('\n')?.[0]);
|
| 160 |
}
|
| 161 |
});
|
| 162 |
|
routes.js
CHANGED
|
@@ -377,6 +377,9 @@ RenderRouter.post('/api/render-sync', async (req, res) => {
|
|
| 377 |
});
|
| 378 |
let url =
|
| 379 |
urls.find((u) => u.includes('.mp4')) ||
|
|
|
|
|
|
|
|
|
|
| 380 |
urls.find((u) => u.includes('.jpg')) ||
|
| 381 |
urls.find((u) => u.includes('.jpeg')) ||
|
| 382 |
urls.find((u) => u.includes('.png'));
|
|
|
|
| 377 |
});
|
| 378 |
let url =
|
| 379 |
urls.find((u) => u.includes('.mp4')) ||
|
| 380 |
+
urls.find((u) => u.includes('.webm')) ||
|
| 381 |
+
urls.find((u) => u.includes('.mov')) ||
|
| 382 |
+
urls.find((u) => u.includes('.avi')) ||
|
| 383 |
urls.find((u) => u.includes('.jpg')) ||
|
| 384 |
urls.find((u) => u.includes('.jpeg')) ||
|
| 385 |
urls.find((u) => u.includes('.png'));
|