shiveshnavin commited on
Commit
122af68
·
1 Parent(s): fd63cde

Update dpckerfile

Browse files
Files changed (2) hide show
  1. app.js +1 -1
  2. proxy-renderer.js +10 -5
app.js CHANGED
@@ -208,7 +208,7 @@ app.all('/busy', async (req, res) => {
208
  });
209
  });
210
 
211
- console.log('process.env.audit_log_creds', process.env)
212
  let acreds = process.env.audit_log_creds || {
213
  "type": "service_account",
214
  "project_id": "xx",
 
208
  });
209
  });
210
 
211
+ console.log('process.env', process.env)
212
  let acreds = process.env.audit_log_creds || {
213
  "type": "service_account",
214
  "project_id": "xx",
proxy-renderer.js CHANGED
@@ -5,12 +5,15 @@ import fs from 'fs';
5
  import axios from 'axios';
6
  import os from 'os'
7
  import { exec, spawn } from 'child_process';
 
 
8
  const { RenderUtils } = await import('./src/RenderUtils.cjs');
9
  const { GenerateScript } = await import('./src/GenerateScript.cjs');
10
 
11
  const originalManuScriptPath = path.join(process.cwd(), 'public/original_manuscript.json');
12
  let cmd = `npm run preview`;
13
  let childProcess = null;
 
14
 
15
  function startChildProcess() {
16
  if (childProcess && !childProcess.killed) {
@@ -39,6 +42,8 @@ function startChildProcess() {
39
  return childProcess;
40
  }
41
 
 
 
42
  // start immediately
43
  startChildProcess();
44
  export const renderProxy = async (outFile, jobId, options) => {
@@ -49,11 +54,11 @@ export const renderProxy = async (outFile, jobId, options) => {
49
  Script,
50
  } = GenerateScript(ScriptInput)
51
  const composition = ScriptInput?.meta?.renderComposition;
52
-
 
53
  const framesPerChunk = options?.framesPerChunk ?? 500;
54
  let framesRendered = 0;
55
  const chunkFiles = [];
56
-
57
  while (framesRendered < duration) {
58
  const endFrame = Math.min(framesRendered + framesPerChunk, duration);
59
  const chunkOutFile = path.join(process.cwd(), `out/${jobId}-chunk-${framesRendered}-${endFrame}.mp4`);
@@ -90,7 +95,7 @@ export const renderProxy = async (outFile, jobId, options) => {
90
  }
91
 
92
 
93
- const ffmpegPath = os.platform() === 'win32' ? 'ffmpeg.exe' : 'ffmpeg';
94
  const concatListPath = path.join(process.cwd(), 'out/concat_list.txt');
95
  fs.writeFileSync(concatListPath, chunkFiles.map(f => `file '${f}'`).join('\n'));
96
 
@@ -98,7 +103,8 @@ export const renderProxy = async (outFile, jobId, options) => {
98
 
99
  await new Promise((resolve, reject) => {
100
  console.log('Stitching chunks...: ' + concatCmd)
101
- const ffmpegProcess = spawn(ffmpegPath, [
 
102
  '-f', 'concat',
103
  '-safe', '0',
104
  '-i', concatListPath,
@@ -108,7 +114,6 @@ export const renderProxy = async (outFile, jobId, options) => {
108
  '-y',
109
  outFile
110
  ]);
111
-
112
  ffmpegProcess.stdout.on('data', (data) => {
113
  console.log(data.toString());
114
  });
 
5
  import axios from 'axios';
6
  import os from 'os'
7
  import { exec, spawn } from 'child_process';
8
+ import { ensureFfmpeg } from "@remotion/renderer";
9
+
10
  const { RenderUtils } = await import('./src/RenderUtils.cjs');
11
  const { GenerateScript } = await import('./src/GenerateScript.cjs');
12
 
13
  const originalManuScriptPath = path.join(process.cwd(), 'public/original_manuscript.json');
14
  let cmd = `npm run preview`;
15
  let childProcess = null;
16
+ var ffmpegLocation = os.platform() === 'win32' ? 'ffmpeg.exe' : 'ffmpeg';
17
 
18
  function startChildProcess() {
19
  if (childProcess && !childProcess.killed) {
 
42
  return childProcess;
43
  }
44
 
45
+
46
+
47
  // start immediately
48
  startChildProcess();
49
  export const renderProxy = async (outFile, jobId, options) => {
 
54
  Script,
55
  } = GenerateScript(ScriptInput)
56
  const composition = ScriptInput?.meta?.renderComposition;
57
+ duration = options?.duration || duration
58
+ await ensureFfmpeg();
59
  const framesPerChunk = options?.framesPerChunk ?? 500;
60
  let framesRendered = 0;
61
  const chunkFiles = [];
 
62
  while (framesRendered < duration) {
63
  const endFrame = Math.min(framesRendered + framesPerChunk, duration);
64
  const chunkOutFile = path.join(process.cwd(), `out/${jobId}-chunk-${framesRendered}-${endFrame}.mp4`);
 
95
  }
96
 
97
 
98
+ const ffmpegPath = ffmpegLocation;
99
  const concatListPath = path.join(process.cwd(), 'out/concat_list.txt');
100
  fs.writeFileSync(concatListPath, chunkFiles.map(f => `file '${f}'`).join('\n'));
101
 
 
103
 
104
  await new Promise((resolve, reject) => {
105
  console.log('Stitching chunks...: ' + concatCmd)
106
+ const ffmpegProcess = spawn('npx', [
107
+ 'remotion', 'ffmpeg',
108
  '-f', 'concat',
109
  '-safe', '0',
110
  '-i', concatListPath,
 
114
  '-y',
115
  outFile
116
  ]);
 
117
  ffmpegProcess.stdout.on('data', (data) => {
118
  console.log(data.toString());
119
  });