shiveshnavin commited on
Commit
4edf38e
·
1 Parent(s): 048ed88

Bubbles checkpotin working but the volue i sles

Browse files
Files changed (1) hide show
  1. utils/bubble/Bubble.js +14 -12
utils/bubble/Bubble.js CHANGED
@@ -113,19 +113,21 @@ class BubbleMaker {
113
  mixLabels.push(`[${label}]`);
114
  });
115
 
116
- const totalInputs = mixLabels.length;
117
- // older ffmpeg builds (including the bundled one) only support the
118
- // normalize=0 argument when mixing exactly two inputs. when there are more
119
- // streams the option causes "Option 'normalize' not found" errors, so we
120
- // omit it in that case. the normalization was only added to prevent the
121
- // original audio from clipping when a single SFX is overlaid; with multiple
122
- // effects we're better off letting downstream logic handle levels or using
123
- // a newer ffmpeg binary via FFMPEG_PATH.
124
- let amixArgs = `inputs=${totalInputs}:duration=first:dropout_transition=0`;
125
- if (totalInputs <= 2) {
126
- amixArgs += ':normalize=0';
 
 
 
127
  }
128
- filterParts.push(`${mixLabels.join('')}amix=${amixArgs}[aout]`);
129
 
130
  const ac = outputAudioPath.toLowerCase().endsWith('.mp3') ? 'libmp3lame' : 'aac';
131
  const fc = filterParts.join(';');
 
113
  mixLabels.push(`[${label}]`);
114
  });
115
 
116
+ // Instead of feeding all streams into a single `amix` (which averages the
117
+ // input samples when more than two streams are present), build a sequential
118
+ // 2-input mixing chain. this keeps the original audio level constant no
119
+ // matter how many effects have not yet started or have already finished.
120
+ // each step uses `normalize=0`, which is safe because amix only has two
121
+ // inputs in each invocation. this also sidesteps the old-
122
+ // ffmpeg-throws-errors bug.
123
+ let prevLabel = mixLabels[0];
124
+ for (let idx = 1; idx < mixLabels.length; idx++) {
125
+ const curLabel = mixLabels[idx];
126
+ const outLabel = idx === mixLabels.length - 1 ? '[aout]' : `[mix${idx}]`;
127
+ // inputs=2 because we're only mixing a running mix with a single new sfx
128
+ filterParts.push(`${prevLabel}${curLabel}amix=inputs=2:duration=first:dropout_transition=0:normalize=0${outLabel}`);
129
+ prevLabel = outLabel;
130
  }
 
131
 
132
  const ac = outputAudioPath.toLowerCase().endsWith('.mp3') ? 'libmp3lame' : 'aac';
133
  const fc = filterParts.join(';');