shiveshnavin commited on
Commit
92ab15b
·
1 Parent(s): 1ebbab2

Fix dockerfile

Browse files
Files changed (2) hide show
  1. Dockerfile +1 -1
  2. proxy-renderer.js +6 -8
Dockerfile CHANGED
@@ -1,7 +1,7 @@
1
  FROM semibit/render-farm:latest
2
 
3
  # Install nginx
4
-
5
  RUN apt-get update && \
6
  apt-get install -y \
7
  bash \
 
1
  FROM semibit/render-farm:latest
2
 
3
  # Install nginx
4
+ USER root
5
  RUN apt-get update && \
6
  apt-get install -y \
7
  bash \
proxy-renderer.js CHANGED
@@ -52,9 +52,12 @@ export const renderProxy = async (outFile, jobId, options) => {
52
 
53
  const framesPerChunk = options?.framesPerChunk ?? 500;
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;
@@ -86,18 +89,13 @@ export const renderProxy = async (outFile, jobId, options) => {
86
  framesRendered = endFrame;
87
  }
88
 
89
- const chunkFiles = [];
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';
97
  const concatListPath = path.join(process.cwd(), 'out/concat_list.txt');
98
  fs.writeFileSync(concatListPath, chunkFiles.map(f => `file '${f}'`).join('\n'));
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) => {
@@ -115,7 +113,7 @@ export const renderProxy = async (outFile, jobId, options) => {
115
 
116
  // Clean up chunk files
117
  for (const chunkFile of chunkFiles) {
118
- fs.unlinkSync(chunkFile);
119
  }
120
  fs.unlinkSync(concatListPath);
121
 
 
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`);
60
+ chunkFiles.push(chunkOutFile)
61
  if (fs.existsSync(chunkOutFile)) {
62
  console.log(`Job ${jobId} chunk ${framesRendered}-${endFrame} already rendered. Skipping.`);
63
  framesRendered = endFrame;
 
89
  framesRendered = endFrame;
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
 
97
+ const concatCmd = `${ffmpegPath} -f concat -safe 0 -i ${concatListPath} -c:v copy -c:a aac -b:a 192k -y ${outFile}`;
98
+
99
  await new Promise((resolve, reject) => {
100
  console.log('Stitching chunks...: ' + concatCmd)
101
  exec(concatCmd, (error, stdout, stderr) => {
 
113
 
114
  // Clean up chunk files
115
  for (const chunkFile of chunkFiles) {
116
+ // fs.unlinkSync(chunkFile);
117
  }
118
  fs.unlinkSync(concatListPath);
119