R Tyler McLaughlin
R Tyler McLaughlin

Reputation: 95

Adding / superimposing two wav files

I'm interested in adding / superimposing two wav files using ffmpeg or a similar library that I can use at the unix command line in Mac OS X. Note that I am not trying to concatenate the wav files. Instead I am trying to yield a single merged wav file that has the same duration as the input wavs, which each have the same duration. The total gain should be the sum of the input wavs at each sample.

I have tried the following:

ffmpeg -i wav1.wav -i wav2.wav -filter_complex amix=inputs=2:duration=first:dropout_transition=3 wav_merged.wav

but it produces a wav file that is not as loud as the sum of the two wavs should be. Further, I have read this post Mixing two wav files in FFmpeg but I am not trying to do any looping and this solution is a bit complex.

Upvotes: 0

Views: 276

Answers (1)

Gyan
Gyan

Reputation: 92928

The amix filter will rescale the volume of the inputs, so to recover volume, add a filter afterwards.

ffmpeg -i wav1.wav -i wav2.wav -filter_complex amix=inputs=2:duration=first,volume=2 wav_merged.wav

The volume arg is equal to the number of amix inputs.

(If you're stopping amix with the first file, there's no need for a dropout transition.)

Upvotes: 1

Related Questions