11

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?

18

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).

  • 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 9: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 6: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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.