obsproject / obs-studio

OBS Studio - Free and open source software for live streaming and screen recording
https://obsproject.com
GNU General Public License v2.0
60.1k stars 7.96k forks source link

VLC Media Player Source does not properly support 5.1 video files when streaming to any output sound profile. (Stereo, 2.1, etc) #6295

Closed dencur closed 2 years ago

dencur commented 2 years ago

Operating System Info

Windows 11

Other OS

Ubuntu 20.04, Windows 10

OBS Studio Version

27.2.4

OBS Studio Version (Other)

No response

OBS Studio Log URL

https://obsproject.com/logs/wpBbuDdp4GsJhMtF

OBS Studio Crash Log URL

No response

Expected Behavior

Audio playback through the VLC Media Player Source that has 5.1 Audio should correctly output audio that balances dialog for L and R channels.

The Media Player Source does not have this problem, however it can not play subtitles. The only solution as of now is to Window Capture VLC, or Re-encode the video file so that subtitles are embedded and use the Media Player Source.

Current Behavior

When listening to any videos with 5.1 Sound (3F2M/LFE), the audio channels for dialog favor the Left speaker, unless multiple people are speaking, during which audio fades between Left and Right speakers. In a movie, this means most dialog comes out of the Left Speaker/Channel.

Steps to Reproduce

  1. Add VLC Media Source
  2. Add Video with 5.1 Sound. (i.e. 3F2M/LFE)
  3. Configure Audio as any: Stereo, 2.1, 3.1, 5.1, 6.1, 7.1, 8.1, or 9.1
  4. Configure Audio Output for Local Monitoring -OR- Stream and Listen to the output
  5. Audio Without Dialog sounds well balanced. Any Dialog heavily favors Left Channel unless multiple people are speaking, in which it might output some dialog to the right channel.

Anything else we should know?

This seems to have been attempted to be fixed here, but there are still issues noted above.

https://github.com/obsproject/obs-studio/pull/5881

I have tested this on Windows 10, Windows 11, and Ubuntu 20.04 which all exhibit the same issue.

pkviet commented 2 years ago

is it possible to get a sample of your source ? i'll have a look. It's quite odd. It 's probably that the channel layout is not correctly retrieved by swresample lib.

dencur commented 2 years ago

Thanks! Here's a public sample that has 5.1, and showcases the issue very well: https://drive.google.com/file/d/0BwxFVkl63-lETFVpOWRVVGNfeEU/view?usp=sharing&resourcekey=0-e9HrVO61IGkoTc_GBMNbww

Pulled from: https://kodi.wiki/view/Samples

pkviet commented 2 years ago

Ok the issue stems from the fact that the speaker layout is 5.1(side) while we use 5.1(back) which is the default 5.1 layout. Media Source correctly identifies the layout while VLC Source doesn't give that info to obs. I'll check the vlc api; it's probably an easy fix.

piotrmerton commented 2 years ago

I am having the exact same problem. Thank you @dencur for reporting this issue thoroughly. It seems to occur only on OBS 27.2.X. I can only add that downgrading OBS to version 27.1.3 solved it for me though I am aware that it's not the ideal solution. Let's hope it will be fixed in the next releases.

pkviet commented 2 years ago

Bad news; libvlc API doesn't give any information about the speaker layout of the media source ... I've confirmed that with a vlc dev. So this can't be fixed easily. There are solutions though for a motivated user:

TinFoilFox commented 2 years ago

That's unfortunate. I've been streaming a movie night with friends for over a year now and I was really looking forward to a fix for the surround sound bug. A lot of the movies I stream if not all seem to be bugged on newer obs releases. I've downgraded obs back to 27.1.3 but I'd hoped that would only be only a temporary fix. I tried ffmpeg to downmix the audio to stereo myself but the balance always seemed off and doing that every time for every movie seemed tedious. As for the rematrix filter, I don't see an option for that in obs? How can I use it to fix the channels?

dencur commented 2 years ago

@pkviet Thanks for the update. Real downer, same sentiment as @TinFoilFox. What changed after 27.1.3 that caused the issue? If this were to be fixed, where would it be fixed?

Since this is a known issue that is reproducible and present in the current OBS release, wouldn't it make more sense to leave it open so that another contributor might be able to fix it?

TinFoilFox commented 2 years ago

I found a OBS plugin to rematrix sound channels and downloaded the 5.1 Dolby Surround Test and the DTS HD Master Audio Sound Check to test which channels go where and I have the same center channel issues with it coming out of the left side and I can't even hear the Rs channel. Using the standard OBS media source I can hear all the channels in their proper places but I can't use things like selecting different audio tracks or subtitles like with the VLC plugin.

TinFoilFox commented 2 years ago

Update: Using the rematrix-filter plugin I have successfully remapped the channels to their correct sources. The correct channel order for 5.1 is: 1, 2, 5, 6, 3, 4. Unfortunately I was never able to get any output from channel 4 from both the VLC plugin and the media source, whether that was the Rs channel (by default) or the LFE channel (once rematrixed).

However, I am still confused as to why this is happening? Every piece of 5.1 surround sound media I play with the VLC plugin gets its channels mixed up. Whether I play a movie or official Dolby test audio, the VLC plugin seems to change the ordering of the channels.

Addendum: I should also add that the rematrix filter only works if you have set OBS to 5.1 in OBS' audio settings. If you set your audio back to stereo, all your channel rematrix settings will not take effect. While streaming in 5.1 works in my specific application, it seems impractical to assume that everyone will be able to do the same, and I would really like to find out why the VLC plugin specifically is having issues where ever other media player seems to correctly order the channels.

dencur commented 2 years ago

Thanks for doing the work to figure out the workaround. Very hacky, requires a 3rd party plugin, and I agree nearly every video I play has this issue. Definitely think this is still worth being listed as a open issue to be fixed as it's not working as intended at the moment.

pkviet commented 2 years ago
  1. I'm confused as to why you're saying that decoding of 5.1(side) (for instance) was working before in 27.1.3. It couldn't work : the vlc plugin did not support surround sound at all. It would keep only the first two channels. I removed this limitation in this commit : https://github.com/obsproject/obs-studio/commit/17c069e1d02049b0e8175b93c5e4922a3dc5707e So check again but in 27.1.3, the surround channels are all removed apart from FL & FR (front left & front right).
  2. As I wrote above, this is NOT fixable because libvlc does not provide us with the necessary info about the speaker layout of the audio source. (I wrote the surround sound support in obs, so I guess I can be trusted on that.) So there's no reason to re-open. Nobody will be able to fix that until the vlc devs expand their API.
piotrmerton commented 2 years ago

@pkviet so if this change renders VLC plugin unusable for sources with more than 2 channels, what is the reason to keep it? Untitled-1

pkviet commented 2 years ago

@pkviet so if this change renders VLC plugin unusable for sources with more than 2 channels, what is the reason to keep it?

you should correct that sentence. It's plain wrong. That the plugin assigns wrong channels for some sources doesn't mean that it doesn't work at all for more than 2 channels. As long as you stick to: mono, stereo, surround (FL FR FC), 4.0 ((surround + BC), 4.1, 5.1(back) (=surround + BL + BR), 7.1(side) (= surround + SL +SR + FLE + BL + BR), there shouldn't be any issue. Libvlc only tells us the number of channels; how are we supposed to guess that it's 5.1(side) rather than 5.1(back) ?

Here's the explanation about the screenshots and I now understand why you would believe that surround sound worked before in vlc source.

  1. the balance slider is available only for stereo sources.
  2. It would appear before for vlc source because the code would strip all surround channels making it an effective stereo source.

Restoring that slider is NOT possible for a true surround sound source (ex: 5.1). There's no reason to restore behaviour to 27.1.3 because 27.1.3 removes ALL surround sound channels.

TinFoilFox commented 2 years ago

It couldn't work : the vlc plugin did not support surround sound at all. It would keep only the first two channels.

Ok, to test this out I have in front of me two instances of OBS. 27.1.3 and the most recent 27.2.4. I will play the test movie clip and Dolby test footage linked above.

When 5.1 surround sound is played on the earlier version of OBS it is as you say and only two channels are being output by OBS no matter what setting I use in the settings menu. However, it appears as though all channels are down mixed appropriately to stereo most notably with center dialogue coming out of both Left and Right.

When I play the same samples on the latest version of OBS I can now see all channels correctly and the settings menu actually works. But the most audible change is now that the center dialogue comes almost exclusively from the left ear. The order of the channels now seems wrong. Using the rematrix plugin linked above I can reorder the channels so that they sound as they did in the earlier version.

In 27.1.3 audio was properly downmixed to stereo. You were limited to only two channels but they were balanced. Now in 27.2.4 the audio does not downmix to stereo properly.

piotrmerton commented 2 years ago

Thanks for an explanation @pkviet . But if I check the "Mono" option, the audio still seems to be outputted only via left channel.

pkviet commented 2 years ago

ok @TinFoilFox i understand better the concern. I can fix that. I'm reopening.

pkviet commented 2 years ago

once CI is done, please test whether the PR fixes the issue. Link to the builds: https://github.com/obsproject/obs-studio/actions/runs/2277949011 (there will be zips once the compilation is done)

pkviet commented 2 years ago

there: https://github.com/obsproject/obs-studio/suites/6393628228/artifacts/232555426

pkviet commented 2 years ago

so check whether:

TinFoilFox commented 2 years ago

Note: As I do not have surround sound setup I cannot test how this build performs on an actual surround sound stage. For this test I used my headphones and computer speakers.

When OBS is set to Stereo:

5.1 and 7.1 audio tests are successfully down mixed to stereo on my headphones. Correctly placing the center channel between left and right. All back channels are on the appropriate sides.

When OBS is set to 5.1 or 7.1:

Audio channels are back to having the center channel exclusively coming out of the left side of my headphones and channels seemingly out of order with Back Right missing (I'm assuming this is because OBS or VLC thinks BR is the LFE channel and discards it or something).

Conclusion

For me this fixes my issues, as I am more than content to set OBS to stereo and have the audio be downmixed when I am streaming. Neither I nor any of those viewing my stream have surround setups so the priority for me is a balanced stereo output.

Thank you for your help and I hope to see this merged into master. :)

pkviet commented 2 years ago

@TinFoilFox note that the fix works by leaving the downmixing to vlc. But if someone does output to 5.1, my previous comment applies: one has to use rematrix unless the source has 5.1(back). For instance, the sample is 5.1(side) but since obs knows only 5.1(back) and since vlc doesn't provide the channel layout, there's no fix. So for checking 5.1 with the sample linked above, you have to use rematrix. So your result is consistent with what I'd expect.