Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vlc-source: Fix surround sound not properly downmixed #6424

Merged
merged 1 commit into from
May 6, 2022

Conversation

pkviet
Copy link
Member

@pkviet pkviet commented May 5, 2022

Description

This fixes issue #6295 .
libvlc does some downmixing/upmixing when the number of channels
requested is less than the number of channels of the source.
We take advantage of that feature to avoid doing it with swresample
because we're missing info that libvlc is not giving (the exact channel
layout of the source).

Motivation and Context

Fixes a bug.

Important Note

  • surprisingly libvlc does not provide any speaker layout info about a source it decodes. I checked with ePirat. This is a real bummer because this means we can't let swresample do its usual task of downmixing or upmixing to the output speaker layout.
  • the libvlc audio callback has however an interesting feature which I haven't seen documented, which is if we request less channels than the original audio soruce has, then vlc will downmix it.
  • That's the feature we take advantage of in this PR. A 5.1 source will be then properly downmixed to stereo.
  • However a 5.1(side) source won't be touched at all and since obs default corresponds to 5.1(back) (default speaker layout for aac), there will be some channels which are swapped in the wrong positions. That's not something as easy to solve and is beyond the scope of this PR. A solution would be to have the user select a speaker layout and that the plugin calls swresample. That's not something I want to implement at the moment, but maybe in the future.

How Has This Been Tested?

Fixes the issue #6295

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code has been run through clang-format.
  • I have read the contributing document.
  • My code is not on the master branch.
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

This fixes issue obsproject#6295 .
libvlc does some downmixing/upmixing when the number of channels
requested is less than the number of channels of the source.
We take advantage of that feature to avoid doing it with swresample
because we're missing info that libvlc is not giving (the exact channel
layout of the source).

Signed-off-by: pkv <pkv@obsproject.com>
@pkviet pkviet marked this pull request as draft May 5, 2022 19:58
@RytoEX RytoEX added Seeking Testers Build artifacts on CI Bug Fix Non-breaking change which fixes an issue labels May 5, 2022
@RytoEX RytoEX added this to the OBS Studio 28.0 milestone May 5, 2022
@pkviet
Copy link
Member Author

pkviet commented May 6, 2022

Bug confirmed as fixed. Removing the Draft status

@pkviet pkviet marked this pull request as ready for review May 6, 2022 13:16
@RytoEX RytoEX merged commit 5e4081e into obsproject:master May 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Fix Non-breaking change which fixes an issue Seeking Testers Build artifacts on CI
Projects
None yet
2 participants