shiveshnavin commited on
Commit
20b3971
·
1 Parent(s): 256845f

Add plugins

Browse files
Files changed (2) hide show
  1. package.json +1 -2
  2. renderer.js +43 -5
package.json CHANGED
@@ -20,8 +20,7 @@
20
  "build:utils": "cd common-utils && npm run build && cd .. && npm install ./common-utils",
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 --audio-codec mp3 --image-format=jpeg --enable-multi-process-on-linux --quality=70 --timeout 60000 --concurrency 1 --gl=angle $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",
 
20
  "build:utils": "cd common-utils && npm run build && cd .. && npm install ./common-utils",
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": "remotion %npm_config_target% %npm_config_build_params% %npm_config_composition%",
 
24
  "render-still": "remotion still --image-format=jpeg SemibitCompositionPoster ",
25
  "render-image": "remotion still --image-format=jpeg --concurrency 1 $npm_config_composition $npm_config_output",
26
  "render-images": "remotion render --enable-multiprocess-on-linux --sequence --image-format=jpeg $npm_config_composition $npm_config_output",
renderer.js CHANGED
@@ -72,9 +72,7 @@ export async function doRender(
72
  }
73
  const renderComposition = composition || 'SemibitComposition';
74
  let script = 'render-build';
75
- if (platform() == 'win32') {
76
- script = `render-build:win32`
77
- }
78
  let buildParams = ` --audio-codec mp3 --frames=0-100 --image-format=jpeg --enable-multi-process-on-linux --quality=70 --timeout 60000 --concurrency 1 --gl=angle `
79
  buildParams = ' ' + (originalManuscript?.meta?.generationConfig?.extras?.buildParams || buildParams) + ' '
80
  if (originalManuscript?.meta?.generationConfig?.extras?.additionalBuildParams) {
@@ -90,13 +88,45 @@ export async function doRender(
90
  }
91
 
92
  const childProcess = spawn('npm', args, spawnOptions);
 
 
93
  if (controller && controller.stop) {
94
  controller.stop = () => {
95
  console.log('Stopping render studio cli process');
 
 
 
 
 
96
  try {
97
- process.kill(-childProcess.pid, 'SIGKILL');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  } catch (e) {
99
- console.error('Failed to kill process group:', e);
 
 
 
100
  }
101
  }
102
  }
@@ -118,6 +148,7 @@ export async function doRender(
118
 
119
  return new Promise((resolve, reject) => {
120
  childProcess.on('close', (code) => {
 
121
  console.log('Render video finished');
122
  sendToObserver(jobId, code === 0 ? 'completed' : 'failed');
123
  if (code === 0) {
@@ -130,6 +161,13 @@ export async function doRender(
130
  console.error(`'${target}' failed with code ${code}.`);
131
  }
132
  });
 
 
 
 
 
 
 
133
  });
134
  }
135
 
 
72
  }
73
  const renderComposition = composition || 'SemibitComposition';
74
  let script = 'render-build';
75
+
 
 
76
  let buildParams = ` --audio-codec mp3 --frames=0-100 --image-format=jpeg --enable-multi-process-on-linux --quality=70 --timeout 60000 --concurrency 1 --gl=angle `
77
  buildParams = ' ' + (originalManuscript?.meta?.generationConfig?.extras?.buildParams || buildParams) + ' '
78
  if (originalManuscript?.meta?.generationConfig?.extras?.additionalBuildParams) {
 
88
  }
89
 
90
  const childProcess = spawn('npm', args, spawnOptions);
91
+ let isProcessKilled = false;
92
+
93
  if (controller && controller.stop) {
94
  controller.stop = () => {
95
  console.log('Stopping render studio cli process');
96
+ if (isProcessKilled || !childProcess.pid) {
97
+ console.log('Process already terminated or no PID available');
98
+ return;
99
+ }
100
+
101
  try {
102
+ // First try to kill the child process directly
103
+ if (!childProcess.killed) {
104
+ childProcess.kill('SIGTERM');
105
+ isProcessKilled = true;
106
+ console.log('Process terminated with SIGTERM');
107
+ }
108
+
109
+ // If detached, also try to kill the process group
110
+ if (spawnOptions.detached) {
111
+ setTimeout(() => {
112
+ try {
113
+ if (childProcess.pid) {
114
+ process.kill(-childProcess.pid, 'SIGKILL');
115
+ console.log('Process group killed with SIGKILL');
116
+ }
117
+ } catch (e) {
118
+ // Ignore ESRCH errors - process already dead
119
+ if (e.code !== 'ESRCH') {
120
+ console.error('Failed to kill process group:', e.message);
121
+ }
122
+ }
123
+ }, 1000);
124
+ }
125
  } catch (e) {
126
+ // Ignore ESRCH errors - process already dead
127
+ if (e.code !== 'ESRCH') {
128
+ console.error('Failed to kill process:', e.message);
129
+ }
130
  }
131
  }
132
  }
 
148
 
149
  return new Promise((resolve, reject) => {
150
  childProcess.on('close', (code) => {
151
+ isProcessKilled = true; // Mark process as terminated
152
  console.log('Render video finished');
153
  sendToObserver(jobId, code === 0 ? 'completed' : 'failed');
154
  if (code === 0) {
 
161
  console.error(`'${target}' failed with code ${code}.`);
162
  }
163
  });
164
+
165
+ childProcess.on('error', (error) => {
166
+ isProcessKilled = true; // Mark process as terminated
167
+ console.error('Child process error:', error);
168
+ sendToObserver(jobId, 'failed');
169
+ reject(error);
170
+ });
171
  });
172
  }
173