-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate-rubai.js
54 lines (43 loc) · 1.42 KB
/
generate-rubai.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
52
53
54
const {exec} = require('child_process');
const basePath = 'poems/payam-e-mashriq/lala-e-toor/';
const startRubai = 33; // Start of the range
const endRubai = 33; // End of the range
function renderRubai(rubaiNumber, layout) {
return new Promise((resolve, reject) => {
const poemBasePath = `${basePath}rubai-${rubaiNumber}/`;
const outputFileName = `upload/rubai-${rubaiNumber}-${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 processRubais() {
for (let i = startRubai; i <= endRubai; i++) {
await renderRubai(i, 'vertical');
console.log('Finished vertical layout');
await renderRubai(i, 'horizontal');
console.log('Finished horizontal layout');
}
}
processRubais();