12

We start with this mono file: test.wav

In audacity it looks like this:

mono

Then we convert it to stereo with this command:

ffmpeg -i test.wav -ac 2 out.wav

Now it looks like this:

stereo

Notice that the amplitude changed!

Finally, we convert the stereo back to mono:

ffmpeg -i out.wav -ac 1 back.wav

We should get the same file from which we started. But in audacity we get the following picture:

sine wave with different phase and amplitude from original

The questions are:

1) Why did the amplitude change when converting to stereo?

2) Why did the amplitude not change back when converting to mono?

3) how can I make the amplitude change back when converting to mono?

Community
  • 1
  • 3
Igor Liferenko
  • 223
  • 2
  • 7

1 Answers1

21

1 - It seems that FFmpeg attempts to respect a common pan law (when routing a centered mono track to a stereo track, lower the mono signal by - 3 dB on each channel of the stereo track). The goal is that the perceived loudness remains coherent.

EDIT

As mentioned by @Mulvya, you can use the pan filter to keep input file level untouched :

ffmpeg -i test.wav -af "pan=stereo|c0=c0|c1=c0" out.wav

END EDIT

2 - It seems that FFmpeg attempts to lower each of the contributing mono signals to prevent the sum to be over maximum level in the destination track.

I couldn't find a definitive description of the processes involved when using the -ac option, but on the AudioChannelManipulation page, you can find the following sentence :

ffmpeg integrates a default down-mix (and up-mix) system that should be preferred (the -ac option) over the pan filter unless you have very specific needs.

3 - For a 2 channel input to a 1 channel output, it seems that :

ffmpeg -i out.wav -filter:a "volume=3dB" -ac 1 back.wav

restores the original level. That should be used with care in the general case for the reasons mentionned above (prevent overloading).

audionuma
  • 2,834
  • 1
  • 14
  • 26
  • 6
    Use ffmpeg -i test.wav -af "pan=stereo|c0=c0|c1=c0" out.wav for mono-to-stereo step to keep channel as-is. – Gyan Jan 15 '18 at 09:35
  • I'm curious if the same happens "behind the scenes" in alsa or pulseaudio when we play mono file on a stereo sound card. – Igor Liferenko Jan 16 '18 at 06:19
  • That would be another question. But this question is related to the actual player software more than the underlying OS audio architecture. When playing a mono file, some players do not apply the pan law and put the untouched mono channel to L and R output channels. – audionuma Jan 18 '18 at 10:38
  • @audionuma @Gyan when converting stereo to mono, same volume lowering happens. How can we use the same pan filter in that case? – Riz Jul 28 '20 at 00:29