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
57.22k stars 7.72k forks source link

OBS Feature Browser "control audio via OBS" on a Browser source Bug #7588

Open Giovanni-2005 opened 1 year ago

Giovanni-2005 commented 1 year ago

Operating System Info

Windows 11

Other OS

No response

OBS Studio Version

28.0.3

OBS Studio Version (Other)

No response

OBS Studio Log URL

https://obsproject.com/logs/ddo2YA4NYKKOOyHR

OBS Studio Crash Log URL

No response

Expected Behavior

that everything works

Current Behavior

The error where the sound changes automatically. the sound automatically distorts when obs is minimized

Steps to Reproduce

  1. OBS Open
  2. New Browser Source add this Music to the url (https://www.youtube.com/watch?v=7tNtU5XFwrU)
  3. On Feature "Control audio via OBS" + Monitoring on (output switched off)
  4. Minimize OBS
  5. Wait 10 sec
  6. The error sounds distorted and has a nightcore style.
  7. open OBS again wait 10 seconds the problem disappears

Anything else we should know?

With version 27.1.3 the bug is not MP4 error Ignoring pls in the log The Problem come not when the feature disabled "Control audio via OBS"

pkviet commented 1 year ago

yeah i can confirm the bug, which occurs both on monitor and recording. The monitoring doesn't need to be 'monitor only' btw. We upgraded cef to 103. The api hasn't changed though so it stems from a change in chromium itself. This will be hard to debug. The distortion sounds like a frequency shift.

Giovanni-2005 commented 1 year ago

will it be fixed in 28.0.4? because that's a hard bug

pkviet commented 1 year ago

It's specific to win 11. The bug doesn't occur with win10. As to when the bug will be fixed, it'll be when me or someone else figure it out, which requires time to devote to that specific bug. Be patient.

Giovanni-2005 commented 1 year ago

ok, I'm glad that I could help, take your time so that it works. is very important

pkviet commented 1 year ago

Don't close. Or we'll lose track.

Giovanni-2005 commented 1 year ago

sry missclick

prgmitchell commented 1 year ago

Just to update on this from what I have observed in the support channels, this bug now is impacting users on Windows 10 22H2 as well. I believe the update was only for Windows 11 at the time this was originally posted. Here's a log from one of the users who has reported this: https://obsproject.com/logs/W9QmpG19Uv3FVEGn

SanPandaKai commented 1 year ago

I am having the same issue as well. I am currently using Windows 11 Pro version 22H2, here is my log file for your reference: https://obsproject.com/logs/TLOBkOKeRAkKfqAR

admiralspeedy commented 1 year ago

Happening to me on Windows 11 Pro 22H2. I wish I had known about this before upgrading...

WizardCM commented 1 year ago

Hmm, for those of you who have reproduced this, does it only happen when monitoring browser sources, or media sources too?

admiralspeedy commented 1 year ago

Just tested this. Created a media source and picked a movie (MP4) and I cannot reproduce the issue, only with the browser source it seems.

Also of note, I just opened OBS to test this and the first time I minimized it while something was playing in the browser source, it actually worked fine. It didn't start doing it until the second time I minimized the window after bringing it back to the foreground once. It then did it every time I minimized it after that.

WizardCM commented 1 year ago

Hmm. Interesting. Thanks for checking. It could specifically be a CEF/Chromium thing, a Windows optimization thing, a combination, or something else. It'll need further investigation.

WizardCM commented 1 year ago

I did some testing today. I was not able to reproduce on Windows 10 22H2. I was able to reproduce on Windows 11 Dev Insider Preview, it happens for me after 5 seconds minimised, not 10 though.

The pitch of the audio shifts up and introduces audio stutter and crackling. Restoring the window restores the audio within 5-10 seconds.

It doesn't seem to be 100% reproducible, I managed to reproduce it about 6 times, the 7th and 8th attempts were fine. It might've been tied to viewing the Performance tab in Task Manager.

I'll continue digging, I don't have a fully configured development environment on my Windows 11 machine to verify what's going on.

admiralspeedy commented 1 year ago

Yah, this never happened to me on Windows 10 22H2 and I was on 22H2 pretty much from the day it was available when I was still on 10.

I don't think the inconsistency in reproducing it has anything to do with the Task Manager performance tab. It just occasionally doesn't happen for me either. Sometimes you can minimize it 2-3 times before it happens, sometimes it happens every time you minimize it.

I played around with process priority and affinity as well as the "Efficiency mode" thinking maybe Windows was triggering it while the app was minimized and pulling resources from OBS, but it never triggers it so it has nothing to do with that, and priority and affinity didn't help either.

WizardCM commented 1 year ago

After some further testing today, here's what else I've discovered:

  1. it's not just when OBS is minimised, but when it's overlayed by a fullscreen window - verified by making the OBS window small, placing Notepad in front of it (no audio distortion), and then fullscreening Notepad (audio distortion)
  2. if a windowed projector (either source or preview) is kept open & visible, even Always on Top, distortion never happens, even if the main window is minimised. the moment the projector is minimised, distortion returns
  3. disabling hardware acceleration in browser docks does not fix it
  4. a quick skim through the data of OnAudioStreamPacket doesn't reveal anything unexpected/wrong.
  5. OnAudioStreamError doesn't get called, so CEF doesn't think anything is wrong.

Edit: Bonus:

  1. Running OBS as Administrator seems to make it occur significantly less often
  2. I have verified the issue can be reproduced in OBS 27.2, 28.0 and 28.1, but is fine in OBS 27.1. This confirms it's a. not directly a Windows 11 optimization issue b. not directly related to the Qt 6 upgrade (that occurred in 28.0)
admiralspeedy commented 1 year ago

So do we need to look for commits related to the browser plugin between 27.1 and 27.2 then?

WizardCM commented 1 year ago

Between 27.1 and 27.2 is when CEF upgraded their Audio API and we updated our code to match. That PR on our side can be found here: https://github.com/obsproject/obs-browser/pull/249

The next task will likely be to try and determine if our code is somehow mishandling the incoming audio from CEF, or whether CEF is doing something wrong and that it needs to be reported upstream.

admiralspeedy commented 1 year ago

Any luck on figuring this out?

prgmitchell commented 1 year ago

@Giovanni-2005 hello, did you mean to close this? i would like this to remain open, otherwise it will be forgotten by most.

admiralspeedy commented 1 year ago

@Giovanni-2005 hello, did you mean to close this? i would like this to remain open, otherwise it will be forgotten by most.

I wondered the same thing but then also tested it last night and the issue seemingly no longer exists for me.

Giovanni-2005 commented 1 year ago

Okay, I thought nobody cares

mbuffa commented 1 year ago

Hello there,

I also got an issue with Browser sources, but I'm not getting any sound, it's not distorted.

What works:

What doesn't:

mbuffa commented 1 year ago

Hmm, actually, this is more complicated than that.

Tested on OBS 29.1.3:

A simple Browser source (literally a Twitch stream) works, with audio controlled by OBS, and monitored.

The browser source I'm trying to use is a Text-To-Speech web app. AFAIK, it uses the system native TTS voices to work. In this case, having the browser source with audio not controlled by OBS works (got actual sound output).

I was not able to test if it worked on OBS 27.1 because the app didn't detect any system voicepacks.

Other notable info: I was using Nvidia Broadcast (which I uninstalled before reswitching to 29.1.3) and I'm using VB-Audio Virtual Cable (so that I can redirect Spotify sound to a separate channel).

admiralspeedy commented 1 year ago

Hmm, actually, this is more complicated than that.

Tested on OBS 29.1.3:

A simple Browser source (literally a Twitch stream) works, with audio controlled by OBS, and monitored.

The browser source I'm trying to use is a Text-To-Speech web app. AFAIK, it uses the system native TTS voices to work. In this case, having the browser source with audio not controlled by OBS works (got actual sound output).

I was not able to test if it worked on OBS 27.1 because the app didn't detect any system voicepacks.

You should open your own issue since it really has nothing to do with this one.

pkviet commented 1 year ago

Hmm, actually, this is more complicated than that.

Tested on OBS 29.1.3:

A simple Browser source (literally a Twitch stream) works, with audio controlled by OBS, and monitored.

The browser source I'm trying to use is a Text-To-Speech web app. AFAIK, it uses the system native TTS voices to work. In this case, having the browser source with audio not controlled by OBS works (got actual sound output).

I was not able to test if it worked on OBS 27.1 because the app didn't detect any system voicepacks.

Other notable info: I was using Nvidia Broadcast (which I uninstalled before reswitching to 29.1.3) and I'm using VB-Audio Virtual Cable (so that I can redirect Spotify sound to a separate channel).

TTS is not captured by the cef audio api. This can't be solved at our level. It would have to be supported by cef. So not a bug on our side.

mbuffa commented 1 year ago

@pkviet Fair enough, thank you for the explanations 🙏

basilbowman commented 11 months ago

I'm also running into this issue - and a few "issues I think are probably related" where browser audio sources just aren't showing up in the audio control

twospaxe commented 4 days ago

This is still happening in the latest version of OBS.

pkviet commented 4 days ago

This is still happening in the latest version of OBS.

well, we haven't upgraded cef yet. Wait till next release or the following one.