shiveshnavin commited on
Commit
1ebbab2
·
1 Parent(s): 2ccef40

Fix dockerfile

Browse files
Files changed (2) hide show
  1. proxy-renderer.js +9 -4
  2. renderer.js +1 -1
proxy-renderer.js CHANGED
@@ -41,7 +41,7 @@ function startChildProcess() {
41
 
42
  // start immediately
43
  startChildProcess();
44
- export const renderProxy = async (outFile, options) => {
45
  const ScriptStr = fs.readFileSync(originalManuScriptPath);
46
  const ScriptInput = JSON.parse(ScriptStr);
47
  let {
@@ -54,8 +54,12 @@ export const renderProxy = async (outFile, options) => {
54
  let framesRendered = 0;
55
  while (framesRendered < duration) {
56
  const endFrame = Math.min(framesRendered + framesPerChunk, duration);
57
- const chunkOutFile = path.join(process.cwd(), `out/chunk-${framesRendered}-${endFrame}.mp4`);
58
-
 
 
 
 
59
  let retryAttemptsLeft = options?.retry ?? 1
60
  while (retryAttemptsLeft >= 0) {
61
  try {
@@ -86,7 +90,7 @@ export const renderProxy = async (outFile, options) => {
86
  for (let i = 0; i < duration; i += framesPerChunk) {
87
  const chunkStart = i;
88
  const chunkEnd = Math.min(i + framesPerChunk, duration);
89
- chunkFiles.push(path.join(process.cwd(), `out/chunk-${chunkStart}-${chunkEnd}.mp4`));
90
  }
91
 
92
  const ffmpegPath = os.platform() === 'win32' ? 'ffmpeg.exe' : 'ffmpeg';
@@ -95,6 +99,7 @@ export const renderProxy = async (outFile, options) => {
95
 
96
  const concatCmd = `${ffmpegPath} -f concat -safe 0 -i ${concatListPath} -c copy ${outFile}`;
97
  await new Promise((resolve, reject) => {
 
98
  exec(concatCmd, (error, stdout, stderr) => {
99
  if (error) {
100
  console.error(`Error stitching chunks: ${error.message}`);
 
41
 
42
  // start immediately
43
  startChildProcess();
44
+ export const renderProxy = async (outFile, jobId, options) => {
45
  const ScriptStr = fs.readFileSync(originalManuScriptPath);
46
  const ScriptInput = JSON.parse(ScriptStr);
47
  let {
 
54
  let framesRendered = 0;
55
  while (framesRendered < duration) {
56
  const endFrame = Math.min(framesRendered + framesPerChunk, duration);
57
+ const chunkOutFile = path.join(process.cwd(), `out/${jobId}-chunk-${framesRendered}-${endFrame}.mp4`);
58
+ if (fs.existsSync(chunkOutFile)) {
59
+ console.log(`Job ${jobId} chunk ${framesRendered}-${endFrame} already rendered. Skipping.`);
60
+ framesRendered = endFrame;
61
+ continue;
62
+ }
63
  let retryAttemptsLeft = options?.retry ?? 1
64
  while (retryAttemptsLeft >= 0) {
65
  try {
 
90
  for (let i = 0; i < duration; i += framesPerChunk) {
91
  const chunkStart = i;
92
  const chunkEnd = Math.min(i + framesPerChunk, duration);
93
+ chunkFiles.push(path.join(process.cwd(), `out/${jobId}-chunk-${framesRendered}-${endFrame}.mp4`));
94
  }
95
 
96
  const ffmpegPath = os.platform() === 'win32' ? 'ffmpeg.exe' : 'ffmpeg';
 
99
 
100
  const concatCmd = `${ffmpegPath} -f concat -safe 0 -i ${concatListPath} -c copy ${outFile}`;
101
  await new Promise((resolve, reject) => {
102
+ console.log('Stitching chunks...: ' + concatCmd)
103
  exec(concatCmd, (error, stdout, stderr) => {
104
  if (error) {
105
  console.error(`Error stitching chunks: ${error.message}`);
renderer.js CHANGED
@@ -56,7 +56,7 @@ export async function doRender(jobId, composition, sendToObserver, target = 'ren
56
  return outFile
57
  }
58
  else if (proxyOptions) {
59
- await renderProxy(outFile, proxyOptions)
60
  sendToObserver(jobId, 'completed');
61
  return outFile
62
  }
 
56
  return outFile
57
  }
58
  else if (proxyOptions) {
59
+ await renderProxy(outFile, jobId, proxyOptions)
60
  sendToObserver(jobId, 'completed');
61
  return outFile
62
  }