-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate-poem.js
51 lines (40 loc) · 1.38 KB
/
generate-poem.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const { exec } = require('child_process');
const basePath = "poems/masnavi-pas-cheh-bayad/";
const poemName = "08-faqr-45-68";
function renderPoem(poemName, layout) {
return new Promise((resolve, reject) => {
const poemBasePath = `${basePath}${poemName}/`;
const outputFileName = `upload/${poemName}-${layout}.mp4`;
console.log("Setting REMOTION_POEM_BASE_PATH to:", poemBasePath, layout);
const renderCommand = `REMOTION_POEM_BASE_PATH=${poemBasePath} REMOTION_LAYOUT=${layout} remotion render MyComp public/${poemBasePath}${outputFileName}`;
console.log(`Executing: ${renderCommand}`);
const child = exec(renderCommand, {
env: {
...process.env,
REMOTION_POEM_BASE_PATH: poemBasePath,
REMOTION_LAYOUT: layout
}
});
child.stdout.on('data', (data) => {
console.log(data);
});
child.stderr.on('data', (data) => {
console.error(data);
});
child.on('exit', (code) => {
console.log(`Child process exited with code ${code}`);
resolve();
});
child.on('error', (error) => {
console.error(`Error: ${error.message}`);
reject(error);
});
});
}
async function processPoems() {
await renderPoem(poemName, 'vertical');
console.log("Finished vertical layout");
await renderPoem(poemName, 'horizontal');
console.log("Finished horizontal layout");
}
processPoems();