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

Browser Source not playing WebRTC videos on MacOS only #209

Closed
steveseguin opened this issue Mar 23, 2020 · 56 comments
Closed

Browser Source not playing WebRTC videos on MacOS only #209

steveseguin opened this issue Mar 23, 2020 · 56 comments

Comments

@steveseguin
Copy link

I can load WebRTC video into OBS Browser Source on Windows without issue, but on MacOS the video does not play.

The same video will play fine on Chrome Standalone for MacOS though.

It may be a STUN/ICE issue, or perhaps a Codec decoder issue; not sure yet.

Copy of console logs of a working session:
https://docs.google.com/document/d/1ZqbjUUKrRmKZoL5CU0Nt6VtmJMIFWqA5sQEAV8Hy2VE/edit?usp=sharing

Copy of console logs of it NOT working on OBS for MacOS.
https://docs.google.com/document/d/1Knnk4kOc7JOTMfemWxh5-8RUIn1t8Ksnm6UA9vwzHAM/edit?usp=sharing

I've tried forcing H264 and VP8; neither worked.
The Mac is connected over Ethernet with no Firewall enabled on the Mac.

I've had other Mac users report the same issue.

You can reproduce by trying to load a self-hosted video stream at https://obs.ninja , or even try Caffeine.tv.

Expected Behavior

WebRTC video should play on OBS if loaded via a browser source

Current Behavior

Just spins, as if the ICE negotiation failed or the video codec isn't supported; not sure.

Steps to Reproduce

  1. Create a webRTC video stream at https://obs.ninja/
  2. Copy the provided link into OBS Browser source for MacOS (v24 or v25 RC1)
  3. Video should load; but does not -- instead it just spins, waiting for the video to load

Additional information

If you load the video into OBS with the URL https://obs.ninja/beta/?streamid=xxxxx instead, you will be able to access console logs of OBS @ https://console.re/obsninja

I have not tried using a TURN server yet, but that is not an option for me.

@pkviet
Copy link
Member

pkviet commented Mar 23, 2020

try with an earlier version of obs (v23 for instance); we updated the cef version in v24.
Could be an issue with cef 3770; search in cef repo for webrtc issues.

@pkviet
Copy link
Member

pkviet commented Mar 23, 2020

only seeing this: https://bitbucket.org/chromiumembedded/cef/issues/2064/persist-webrtc-deviceids-across-restart
No idea if this would matter in your case, you're the one positioned to tell us.
Anyway, as it's most certainly a cef issue, I doubt we can fix it without patching cef; you'll have to wait till we upgrade cef and in the meantime, the best course is to downgrade obs.

@steveseguin
Copy link
Author

Thank you. Much appreciated!!

OBS 23.1.0 for Mac works. I'll try to see why this is the case and report back if I find the answer.

With WebRTC a growing component of the web and video/audio, I'm surprised this hasn't been previously reported.

@steveseguin
Copy link
Author

I had a user report that Audio capture via Browser Source wasn't working in v23 for them, but it was in v24? This despite the WebRTC issue being fixed for them when they reverted to v23.

I might need to take a deeper look into this CEF issue sooner than I wanted as v23 offers limited functionality for my users without audio also.

Based on what I saw earlier in my testing, it didn't seem like the WebRTC RTCP/SDP/ICE handshake completed. WebRTC traffic should be passed as UDP packets, but it seemed like it was resorting to TCP packets and still even then failing. This implies that the WebRTC handshake depleted all available connection methods and was getting desperate.

This may imply perhaps a Software Firewall is blocking non-standard ports from opening?

I ran https://browserleaks.com/webrtc on OBS v24 on MacOS and it identified that WebRTC IP address sharing is disabled. It is enabled on OBS v25 for PC however.

I took a closer look at CEF and IP blocking and there appear to be quite a few flags that will enable or disable WebRTC.
'''WebRTC is disabled by default in CEF unless you pass enable-media-stream flag.'''
https://www.magpcss.org/ceforum/viewtopic.php?f=14&t=15194

Here's a sample of it added to the sample CEF build.
https://github.com/cefsharp/CefSharp.MinimalExample/blob/726c328f6a268f5eb13a28d758ed183a853f05bb/CefSharp.MinimalExample.WinForms/Program.cs#L19

I've tried '''open -a OBS.app --args --enable-media-stream''' without any luck. The same with '''/Applications/OBS.app/Contents/MacOS/OBS --enable-media-stream'''

Other settings like "webrtc.ip_handling_policy" is a preference that must be set using CefRequestContext::SetPreference concern me, but I don't know if they were enabled during build or not.

On Safari, to enable WebRTC, the user first needs to accept the Microphone's permission via a popup. Not sure if there is anything like that going on in 3770.

I've downloaded the source code for 3770, yet just don't have the time right now to dig deep into figure it out there.

@steveseguin
Copy link
Author

steveseguin commented Apr 4, 2020

StreamLabs OBS Beta (newly released) seems to solve the OBS+MacOS issue for me. Browser Audio + WebRTC playback works with it, although its browser-source video playback frame rate is much lower than with OBS v23.

https://streamlabs.com/

@dodgepong
Copy link
Member

If I had to guess, this might be due to disabling NetworkService in this commit: 1a5f241

The reasoning for doing this is found in this commit: 8e1279e

Unfortunately I don't have a way to test this, but it seems plausible to me. It's possible upgrading to 3809 would let us use NetworkService again, though so far we've had trouble getting 3809 to render anything on Mac.

@pkviet
Copy link
Member

pkviet commented Apr 4, 2020

indeed if I re-enable NetworkService, obs.ninja works. But it breaks loading of video files larger than a few megs ...

@steveseguin
Copy link
Author

steveseguin commented Apr 4, 2020 via email

@pkviet
Copy link
Member

pkviet commented Apr 4, 2020

we need to discuss within the dev team and Jim will decide what to do. The fix is simple. But it breaks something else so ...

@dodgepong
Copy link
Member

I suspect that even if we just re-enabled NetworkService on Mac, WebRTC streams would have poor performance for lack of hardware acceleration in the browser source. I don't think there's going to be a good solution here until we can upgrade CEF, which we can't do until CEF merges back in audio mirroring support and I think also OSR support.

@broady
Copy link

broady commented May 15, 2020

Could it be a configuration setting in the settings for the source?

"Optimize for WebRTC (experimental)"

@jburbs
Copy link

jburbs commented May 15, 2020

As a possibly related issue, I've been trying to get obs-mac-virtualcam running with a streaming web video in the background using the Browser Source. I have essentially the same experience as @steveseguin, the "Interact with browser" brings up the web page, but I cannot play the stream, the browser is mostly unresponsive. However, if I launch the Windows version of OBS from a virtual PC, it works fine, and if I switch to StreamLabs, it works there as well (without the virtual cam).

If you think logfiles would be useful for troubleshooting, or if you have suggestions for things to try, happy to help.

@dodgepong
Copy link
Member

We know exactly what the problem is, so we don't need any more troubleshooting. The problem is that fixing what is wrong will break something else. There isn't going to be a good solution to this problem until latest CEF fixes a couple lingering issues, and then we can update.

@jpbecotte
Copy link

I want to use WebRTC feeds in obs-browser on Mac too. Is this issue related to the fact that the plugin must stick with the version 75.1.14 of CEF? It seems that this bug is related to this specific version. I tried to compile with multiple newer versions and it looks like the plugin code is no longer in sync with CEF's API.

@dodgepong
Copy link
Member

The specific cause of the problem with WebRTC video is that OBS ships obs-browser with NetworkService disabled on Mac. Technically NetworkService could be enabled on the build of CEF that we are currently shipping (3770), but the reason it was disabled is because Mac was seeing a problem related to loading large remote video files, and the solution at the time turned out to be disabling NetworkService.

It's possible a future release of CEF has fixed that issue, such that NetworkService could be re-enabled without causing problems for large video files. However, future releases of CEF have broken other functionality, namely hardware acceleration (and for a while the new audio API as well, but that has since been fixed).

There does not exist a newer release of CEF that has all of the issues fixed that we need. Once one does exist, then we will upgrade.

@jburbs
Copy link

jburbs commented Jun 2, 2020

@dodgepong Thanks for the details. Are you saying that if I don't need the feature of loading a large remote video file, but do want the feature of playing video from BrowserSource, then I can recompile OBS with NetworkService enabled?

@dodgepong
Copy link
Member

Yes.

@sjpapai
Copy link

sjpapai commented Jul 16, 2020

@jburbs Have you had any success with this? I have not, and the solution of rolling back to v23 does not work for me as using studio mode was for all intents and purposes broken before 25.0.5 (I believe). But I'm sure I'm doing something wrong in my compiling, as I'm not that advanced...

@rtgoodwin
Copy link

rtgoodwin commented Jul 29, 2020

@sjpapai @jburbs I was able to compile and it seems to work in quick testing. Catalina, OBS 25.0.7-448 completely from source. Build instructions from https://github.com/obsproject/obs-studio/wiki/Install-Instructions#macos-build-directions

Clone the git repository, then edit the obs-browser source (the .CPP) to rollback obsproject/obs-studio@80a1fee

Build, run, grant screen recording if needed on Catalina. (You will probably have to remove the current OBS from the list to use the new build.)

Add browser source with OBS.ninja push URL. You also have to add the &streamlabs=1 to get around @steveseguin detection of OBS version :)

Note: I have no expertise with any of the underlying libraries or anything that might break (besides reading the comment about large remote video files above)! Build and use at your own risk, etc. That said, would love to hear if it reliably works for anyone, and will try to report back if I end up using it as well.

@marcelomoyano
Copy link

Hello everyone, @dodgepong thank you for the info you shared.

Any news about the update on CEF? Or where can I see that status?

I just need to load video streams in a browser source within OBS for Mac.

I have a game changer technology I'm making and this is really needed from our beta testing users.

Thank you!

Marcelo.

@WizardCM
Copy link
Member

WizardCM commented Aug 4, 2020

When we have more information to share about a CEF update, it'll be posted in here, among other places. Feel free to subscribe to updates for this thread.

@DrWig
Copy link

DrWig commented Sep 10, 2020

It's a real shame this issue persists on the Mac. Any updates?

@steveseguin
Copy link
Author

Last update was 10-days ago or so:

https://www.reddit.com/r/obs/comments/ijbst7/obs_studio_260_release_candidate_is_now_available/g3cowgr/?utm_source=reddit&utm_medium=web2x&context=3

Browser source on macOS is something I'm personally keeping a very close eye on. It's using the same version as Windows (Chrome 75-based), but the difference is we disable the newer networking capabilities, as they break third party alerts. It's essentially trading one downside for another downside. At this moment, we're waiting on CEF to merge updated offscreen rendering code (VIZ OSR) which'd also open the door to hardware-accelerated browser sources in OBS on macOS. There hasn't been much of an update on their side for a couple months unfortunately.

Custom browser docks on macOS are not in 26, but they're getting really close. There are complications in terms of copy/paste keyboard shortcuts that we still need to work through, but I'm personally hoping the next update in a few months (likely a 26.1.0) will finally include this feature on macOS.

-via wizardCM

@unknowndomain
Copy link

@WizardCM third party alerts don't work anyway on macOS for many users?

@DrWig
Copy link

DrWig commented Sep 10, 2020

Thanks Steve.

@pkviet
Copy link
Member

pkviet commented Sep 10, 2020

there's been no movement unfortunately on cef side regarding the merge of shared textures PR. It'll require a bit of work on our side since it adds shared textures for mac, so patience should be rewarded eventually for mac users. We're following closely the situation.

@PatTheMav
Copy link
Member

Just FYI this whole thing will work with CEF 4183 (see also: #252).

I tested the WebRTC output from obs.ninja and after clicking on the link to bypass the macOS detection it worked fine.

@WizardCM Somehow my PR also fixes browser source interaction on macOS. 🤷🏻‍♂️

@marcelomoyano
Copy link

hi! so how can i test this in my mac? i downloaded the cefclient binary and it works! but how can i test this inside an OBS beta? ... I'm sorry for not understanding how to build it :) but i really need to test this out! thank you.

@2xbass
Copy link

2xbass commented Dec 16, 2020

I would also really like to test this if possible. Ideally without having to build OBS on the Mac.

@chrismarquardt
Copy link

Woah, a new CEF version for OBS on Mac would be more than amazing. Is there a timeline for this PR to be incorporated? Can't wait.

@dodgepong
Copy link
Member

No "timeline" specifically, but it's being actively worked on. Follow the PR that @PatTheMav linked for more details.

@WizardCM
Copy link
Member

Hello everyone! Just wanted to provide an update.

@PatTheMav @pkviet and myself have recently put in a fair bit of work to try and get a number of macOS browser-related issues fixed. While it's not all ready for a release just yet, we wanted to open it up for more testing.

These changes should solve all the issues you've been running into. Please test and let us know if you run into any strange behaviours.

  • Updated CEF to 4183, fixing media playback in browser sources
  • Enable hardware acceleration for browser sources
  • Enable texture sharing with browser sources
  • Enable native browser panels
  • Enable hardware acceleration for media sources (H263, H264 and HEVC only)
  • Enable hardware acceleration for stingers (H263, H264 and HEVC only)

Download the build here.

Note: The release is code signed, but not notarised, so the the .dmg and .app need to be opened by actively selecting "Open" in the files' context menu.

@castles
Copy link

castles commented Dec 20, 2020

Awesome job @WizardCM, @PatTheMav and @pkviet. It works perfectly for me! The only oddity I discovered was every time I close OBS I get a message saying "OBS quit unexpectedly."

@PatTheMav
Copy link
Member

Awesome job @WizardCM, @PatTheMav and @pkviet. It works perfectly for me! The only oddity I discovered was every time I close OBS I get a message saying "OBS quit unexpectedly."

That sounds like a crash on exit, I've had that occur at weird times but wasn't able to replicate it after.

Did you get a crash report or anything? Does the log say anything at the bottom?

@castles
Copy link

castles commented Dec 21, 2020

I just tried deleting all my scenes and that seems to have fixed it. Maybe something was up with the different versions of OBS that I've been testing?

Here is the crash log before I deleted the scenes:

OBS-crash.txt

@PatTheMav
Copy link
Member

@castles Please re-attach that log as a txt file to your post, makes it easier to follow the discussion. Thank you.

@castles
Copy link

castles commented Dec 21, 2020

@castles Please re-attach that log as a txt file to your post, makes it easier to follow the discussion. Thank you.

Yeah, sorry about that.. I thought github compressed long posts. txt file has been added.

@PatTheMav
Copy link
Member

Looks like EOSWebcamUtility was involved, but also weird how after it an event was posted to the main window which triggered recursive paint events that lead to the crash.. Doesn't immediately look familiar to me though.

@caseymrm
Copy link

This build is working great for me, and feels snappy with a browser overlay that used to seriously lag OBS. Very exciting, thank you!

No crash on exit for me fwiw.

@castles
Copy link

castles commented Dec 21, 2020

Looks like EOSWebcamUtility was involved, but also weird how after it an event was posted to the main window which triggered recursive paint events that lead to the crash.. Doesn't immediately look familiar to me though.

I can't seem to replicate it now that I've re-created my scenes so I don't think its worth trying to track down. I will comment again if it comes back.

@2xbass
Copy link

2xbass commented Dec 21, 2020

I tested this with OBSN and it appears to work well. No crash on exit for me either.

@UnixCro
Copy link

UnixCro commented Dec 21, 2020

it works with no problems. Very good work!

@marcelomoyano
Copy link

marcelomoyano commented Dec 21, 2020 via email

@PatTheMav
Copy link
Member

Sounds like ProRes? Those ones take quite the toll. Converting it to vp9 with alpha might help a bit - it's still CPU-decoded, but the ffmpeg decoder is already quite efficient. At least on my 5-year old iMac the vp9 was less taxing than the ProRes file.

Iirc encoded it with this: ffmpeg -i IN.mov -c:v libvpx-vp9 -b:v 0 -crf 15 -vf scale=1280:-2 -sws_flags lanczos+full_chroma_inp -an OUT.webm. If you don't want to downscale to your canvas resolution you can leave out the -vf option of course.

@marcelomoyano
Copy link

marcelomoyano commented Dec 21, 2020 via email

@marcelomoyano
Copy link

marcelomoyano commented Dec 21, 2020 via email

@marcelomoyano
Copy link

marcelomoyano commented Dec 21, 2020 via email

@PatTheMav
Copy link
Member

No idea, the command doesn't specify anything regarding frames - it takes the file as-is and converts it. You can try making output more verbose while encoding (ffmpeg allows keyboard input during it) and then hit Google with any specific error you might get.

@marcelomoyano
Copy link

marcelomoyano commented Dec 21, 2020 via email

@verstaerker-583
Copy link

verstaerker-583 commented Dec 30, 2020

©WizardCM Wonderfull, thank you so much. I did test your build extensively with various overlays and found it very stable and - most amazing - the CPU load almost reduced by half! Default fps seem to be lower than normal and a little too low for most css animations.

OBS Ninja now works fine for me. Unfortunately the audio signal has much more noise compared to Chrome and within OBS I hear clicks which I don't hear when monitoring the same signal with Chrome. I don't know if this is related to OBS or to OBS Ninja.

I tried to run OBS Ninja (to broadcast the virtual cam) as custom browser dock, but received the following error message: "Permissions denied. Please ensure you have allowed the mic/camera permissions."

@marco-par
Copy link

Hi guys!

Apologies in advance if I'm doing something wrong here. I'm trying to share the screen of an external laptop using OBS Ninja into my OBS. I've received a message into the browser link in OBS, saying that the 26.1 doesn't support OBS Ninja, but I could install the test build of the 26.2 at the link quoted. It looks like, though, the download link is not active anymore. Could you please help me?

Also, is this the only way I can achieve what I'm trying to achieve? :)

Thank you,

Marco

Hello everyone! Just wanted to provide an update.

@PatTheMav @pkviet and myself have recently put in a fair bit of work to try and get a number of macOS browser-related issues fixed. While it's not all ready for a release just yet, we wanted to open it up for more testing.

These changes should solve all the issues you've been running into. Please test and let us know if you run into any strange behaviours.

  • Updated CEF to 4183, fixing media playback in browser sources
  • Enable hardware acceleration for browser sources
  • Enable texture sharing with browser sources
  • Enable native browser panels
  • Enable hardware acceleration for media sources (H263, H264 and HEVC only)
  • Enable hardware acceleration for stingers (H263, H264 and HEVC only)

Download the build here.

Note: The release is code signed, but not notarised, so the the .dmg and .app need to be opened by actively selecting "Open" in the files' context menu.

@steveseguin
Copy link
Author

steveseguin commented Jan 9, 2021

Hi Marco, join me on discord @ https://discord.obs.ninja. This isn't the correct place for OBS.Ninja support.
( Support for this new OBS preview build is on https://obs.ninja/beta ; or add &streamlabs to the URL, as Pat mentions)

@PatTheMav
Copy link
Member

FWIW you just need to add the streamelements(iirc) parameter that makes OBS.ninja skip the OS detection. The WebRTC functionality hasn't been officially released, so OBS.ninja cannot discover the new "working" version.

@WizardCM
Copy link
Member

WizardCM commented Jan 9, 2021

Thanks to the following PRs and the work of @PatTheMav and @pkviet - hardware acceleration is now available in OBS starting in 26.1.2.

Also big thanks to all of you who tested the build and verified that everything works.

@WizardCM WizardCM closed this as completed Jan 9, 2021
@DrWig
Copy link

DrWig commented Jan 11, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests