shiveshnavin commited on
Commit
6216349
·
1 Parent(s): 844fd99
Files changed (1) hide show
  1. utils/bubble/Bubble.js +27 -2
utils/bubble/Bubble.js CHANGED
@@ -302,7 +302,19 @@ class BubbleMaker {
302
 
303
  const cmd = `ffmpeg ${inputs.join(' ')} -filter_complex "${fc}" -map "${currentLabel === '[0:v]' ? '[0:v]' : currentLabel}" ${audioFilter ? '-map "[aout]" -c:a aac' : ''} -c:v libx264 -preset veryfast -crf 23 -shortest "${outputPath}" -y`;
304
  onLog && onLog('Running ffmpeg: ' + cmd);
305
- await FFMpegUtils.execute(cmd);
 
 
 
 
 
 
 
 
 
 
 
 
306
  return outputPath;
307
  }
308
 
@@ -661,7 +673,20 @@ class BubbleMaker {
661
  }
662
 
663
  onLog && onLog('Running ffmpeg: ' + cmd);
664
- await FFMpegUtils.execute(cmd);
 
 
 
 
 
 
 
 
 
 
 
 
 
665
  return outputPath;
666
  }
667
  }
 
302
 
303
  const cmd = `ffmpeg ${inputs.join(' ')} -filter_complex "${fc}" -map "${currentLabel === '[0:v]' ? '[0:v]' : currentLabel}" ${audioFilter ? '-map "[aout]" -c:a aac' : ''} -c:v libx264 -preset veryfast -crf 23 -shortest "${outputPath}" -y`;
304
  onLog && onLog('Running ffmpeg: ' + cmd);
305
+ try {
306
+ await FFMpegUtils.execute(cmd);
307
+ } catch (err) {
308
+ // if audio mixing caused failure, try again without any audio effects
309
+ if (audioParts.length) {
310
+ onLog && onLog('ffmpeg optimized mix failed, retrying without audio effects: ' + err);
311
+ const retryCmd = `ffmpeg ${inputs.join(' ')} -filter_complex "${videoFilter}" -map "${currentLabel === '[0:v]' ? '[0:v]' : currentLabel}" -c:v libx264 -preset veryfast -crf 23 -shortest "${outputPath}" -y`;
312
+ onLog && onLog('Running ffmpeg (no audio): ' + retryCmd);
313
+ await FFMpegUtils.execute(retryCmd);
314
+ } else {
315
+ throw err;
316
+ }
317
+ }
318
  return outputPath;
319
  }
320
 
 
673
  }
674
 
675
  onLog && onLog('Running ffmpeg: ' + cmd);
676
+ try {
677
+ await FFMpegUtils.execute(cmd);
678
+ } catch (err) {
679
+ // if it failed due to mixing we try again without the audio effect file
680
+ if (bubble && bubble.audioEffectFile) {
681
+ onLog && onLog('ffmpeg failed, retrying without audio effect: ' + err);
682
+ const clone = _.cloneDeep(bubble);
683
+ delete clone.audioEffectFile;
684
+ // recursive call to render without audio
685
+ await this.makeBubble(videoPath, clone, outputPath, onLog);
686
+ return outputPath;
687
+ }
688
+ throw err;
689
+ }
690
  return outputPath;
691
  }
692
  }