Opened 4 years ago

Closed 3 years ago

#1792 closed defect (wontfix)

libswresample mono to stereo conversion is lowering the amplitude

Reported by: albertzeyer Owned by: michael
Priority: normal Component: swresample
Version: git-master Keywords: regression
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

I am resampling sound data with libswresample. I have one sample case where I resample

44100Hz, sint16, mono

to

44100Hz, sint16, stereo.

I.e. this is just a mono to stereo conversion.

I was expecting that

leftSample = rightSample = monoSample;

However, I was more getting something mostly like:

leftSample = rightSample = monoSample / 1.41;
(maybe 1.41 ~= sqrt(2) ?)

Is this a bug? Or expected? I don't have profesional audio background but I heard that a normal mono to stereo conversion is as what I would expect. I also have seen many different implementations where it is done like this, e.g. the main ReplayGain implementation.

Change History (10)

comment:1 Changed 3 years ago by richardpl

  • Resolution set to invalid
  • Status changed from new to closed

This is not place to ask questions.

comment:2 Changed 3 years ago by albertzeyer

  • Resolution invalid deleted
  • Status changed from closed to reopened

It was not simply a question. Either this is expected, then it maybe should be documented somehow. Or it is not expected, then it is a bug.

comment:3 Changed 3 years ago by richardpl

It is expected, if you want different behavior use pan filter.

comment:4 Changed 3 years ago by cehoyos

SoX behaves differently: sox mono.wav -c 2 stereo.wav does not change the loudness.

comment:5 Changed 3 years ago by heleppkes

When you output one channel to two speakers, the perceived loudness increases and swresample compensates for this by reducing the loudness of the channels accordingly, so that the perceived loudness does not change.

This behavior is expected.

comment:6 Changed 3 years ago by albertzeyer

I think when you send a mono-signal to the sound driver, it just uses the same signal for both channels. That is different from what FFmpeg does.

comment:7 Changed 3 years ago by richardpl

If you want custom conversion use audio filters, or send patch for swresample.

This ticket is neither bug report or feature request.

comment:8 Changed 3 years ago by albertzeyer

But when the behavior is supposed to be different, it is a bug.

Or it is a bug that this is the default behavior. (Because the default is normally something else.)

comment:9 Changed 3 years ago by richardpl

Its not a bug. Its expected normal and default behavior.

comment:10 Changed 3 years ago by cehoyos

  • Keywords regression added
  • Reproduced by developer set
  • Resolution set to wontfix
  • Status changed from reopened to closed
  • Version changed from unspecified to git-master

The new behaviour is reproducible since release 0.9, apart from what Hendrik wrote above I believe there are two additional good reasons why it should not be changed again:
$ ffmpeg -i mono.wav -channel_layout 7.0 out.wav would produce surprising output if we copy sox's behaviour (upmixing to more than two channels did not work before 0.9)
The behaviour you want can easily be achieved using the pan filter.

Note: See TracTickets for help on using tickets.