Subtracting Audio Files with FFmpeg

TL;DR

Command line magic to the rescue!

ffmpeg -i input0.wav -i input1.wav \
  -filter_complex \
  "[1]    aeval  = -val(0) | -val(1)                     [a]; \
   [0][a] amerge = inputs=2,pan=stereo|c0<c0+c2|c1<c1+c3 [b]" \
  -map "[b]" -c:a pcm_s16le output.wav

Explanation

Sometimes when working on mixes I forget what has changed between versions. I keep notes, but they can be subtle or hard to verify.

The above FFmpeg command1 outputs the differences between two files. It works on both WAV and AIF input files. I haven’t tried too many variations2, but it’s working for stereo 16-bit 44.1k and 48k files just fine.

Note the command outputs the differences in BOTH input files to the output. For example if something was nudged over by 1 beat, you’ll hear the original start and the new one start 1 beat later over each other. It’s still helpful in drawing attention to what has changed though.

References

Krishna Bhamidipati
Built with Hugo
Theme Stack designed by Jimmy