Answers.Body: <p>Inverting the background should work, that's exactly how a balanced audio connection works to eliminate noise, but how exact a match is your isolated background track compared to the mixed track? It's only going to fully work if it is recorded at the exact same quality, volume, etc, and the timing is precisely the same. What was the recording source for each track? How confident are you that the two sets of background audio that were recorded are identical to each other?</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-28T00:00:37.807Z
Answers.Text: My guess is that the match isn't exact.  Or rather, that it is exact in the time dimension, but that the volume differs.  For context, I'm interested in doing this in general, but a particular use case I have in mind is isolating dialogue from a 5.1 surround audio.  Typically with 5.1 sound center channel (`FC`) contains all the dialogue, and sometime it also has the background sound at a lower volume.  That same background sound is also in the FR and FL channels (assuming no stereo differences, true most of the time).  So I'd like to subtract FR+FL from the FC to get just dialogue!
Answers.UserDisplayName: Chris
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-28T23:58:36.057Z
Answers.Text: I would suggest making a new post, specifically asking for the best way to isolate dialogue from a 5.1 audio mix. In this case, I doubt the audio in other channels matches enough to invert like you tried (but worth a shot), but I suspect there are other methods available that will work better. I've seen it done somewhat successfully by filtering frequencies to remove "non-voice" sounds, but there might be other better ways of doing this.
Answers.UserDisplayName: Peter Barton
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-16T08:46:53.073Z
Answers.LastActivityDate: 2020-07-16T08:46:53.073Z
Answers.UserDisplayName: Peter Barton
Body: <p>Given two audio streams, I'd like to remove the audio in one stream that also exists in another.  In this particular case the 1st stream contains everything mixed, and the 2nd stream contains just the background noise which also exists in the 1st stream.  Is there a reasonable way to go about &quot;subtracting&quot; this background audio track from the 1st audio track?</p>
  <p>Ideally using ffmpeg, but open to anything.  I've naively tried inverting the background channel and mixing it with the first channel with this ffmpeg filter: <code>aeval=val(0)|-val(1)</code> but that doesn't work.  I assume that's because the background is mixed at a different level. (I'm also assuming they're exactly in phase)</p>
  <p>Any other ideas?</p>
  <p><a href="https://i.sstatic.net/UcYcN.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/UcYcN.png" alt="audio visualization" /></a></p>
  <p>For reference, here's ffmpeg <code>showcqt</code> filter on each channel side by side.  You can see how the 2nd column seems to &quot;contain&quot; all of the audio in the first column, plus some more.  (and mixed at different levels)</p>
  
Tags: <ffmpeg><audio>
Title: How to filter out overlapping audio? Given a mixed track and one stem track, what's the best way to "subtract" the stem from the mix?
UserDisplayName: Chris
ThreadText: # How to filter out overlapping audio? Given a mixed track and one stem track, what's the best way to "subtract" the stem from the mix?
  
  (Asked by: username_0 on 2020-07-15)
  
  Given two audio streams, I'd like to remove the audio in one stream that also exists in another. In this particular case the 1st stream contains everything mixed, and the 2nd stream contains just the background noise which also exists in the 1st stream. Is there a reasonable way to go about "subtracting" this background audio track from the 1st audio track?
  
  Ideally using ffmpeg, but open to anything. I've naively tried inverting the background channel and mixing it with the first channel with this ffmpeg filter: `aeval=val(0)|-val(1)` but that doesn't work. I assume that's because the background is mixed at a different level. (I'm also assuming they're exactly in phase)
  
  Any other ideas?
  
  [![audio visualization](https://i.sstatic.net/UcYcN.png)](https://i.sstatic.net/UcYcN.png)
  
  For reference, here's ffmpeg `showcqt` filter on each channel side by side. You can see how the 2nd column seems to "contain" all of the audio in the first column, plus some more. (and mixed at different levels)
  
  **Tags:** ffmpeg, audio
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-07-16. Score: 3
  
  Inverting the background should work, that's exactly how a balanced audio connection works to eliminate noise, but how exact a match is your isolated background track compared to the mixed track? It's only going to fully work if it is recorded at the exact same quality, volume, etc, and the timing is precisely the same. What was the recording source for each track? How confident are you that the two sets of background audio that were recorded are identical to each other?
  
  > **Comments:**
  > **username_0**: My guess is that the match isn't exact.  Or rather, that it is exact in the time dimension, but that the volume differs.  For context, I'm interested in doing this in general, but a particular use case I have in mind is isolating dialogue from a 5.1 surround audio.  Typically with 5.1 sound center channel (`FC`) contains all the dialogue, and sometime it also has the background sound at a lower volume.  That same background sound is also in the FR and FL channels (assuming no stereo differences, true most of the time).  So I'd like to subtract FR+FL from the FC to get just dialogue!  
  > **username_1**: I would suggest making a new post, specifically asking for the best way to isolate dialogue from a 5.1 audio mix. In this case, I doubt the audio in other channels matches enough to invert like you tried (but worth a shot), but I suspect there are other methods available that will work better. I've seen it done somewhat successfully by filtering frequencies to remove "non-voice" sounds, but there might be other better ways of doing this.  
  
  ---
  
  