obsproject / obs-browser

CEF-based OBS Studio browser plugin
GNU General Public License v2.0
783 stars 225 forks source link

Browser Source not playing WebRTC videos on MacOS only #209

Closed steveseguin closed 3 years ago

steveseguin commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

If I had to guess, this might be due to disabling NetworkService in this commit: https://github.com/obsproject/obs-browser/commit/1a5f2419e20b5de9aa1abb5a8ab2795444fe41a6

The reasoning for doing this is found in this commit: https://github.com/obsproject/obs-browser/commit/8e1279e2994a3b9ecbf87457548e2ddcd27d9eb8

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 commented 4 years ago

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

steveseguin commented 4 years ago

Thank you for figuring that out and confirming it. It’s a relief.

I suppose there wouldn’t be a way to offer a custom build on here for Mac users looking for WebRTC support instead? :)

Technically WebRTC users are not loading files; rather they are streaming video data. There is no solution for them that is all that great right now. I get a few requests a day about this issue from Mac users.

Regardless, thank you

On Sat, Apr 4, 2020 at 4:23 AM pkv notifications@github.com wrote:

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

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/obsproject/obs-browser/issues/209#issuecomment-608995021, or unsubscribe https://github.com/notifications/unsubscribe-auth/AATU2UROEJFHQYI6WG36I2DRK3VB7ANCNFSM4LRT7CWQ .

--


Steve Seguin

pkviet commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

"Optimize for WebRTC (experimental)"

jburbs commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

@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 commented 4 years ago

Yes.

sjpapai commented 4 years ago

@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 commented 4 years ago

@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 https://github.com/obsproject/obs-studio/commit/80a1fee70fd68b4b6389a6ec990522e78e82820a

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

steveseguin commented 4 years ago

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 commented 4 years ago

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

DrWig commented 4 years ago

Thanks Steve.

pkviet commented 4 years ago

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 commented 3 years ago

Just FYI this whole thing will work with CEF 4183 (see also: https://github.com/obsproject/obs-browser/pull/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. 🤷🏻‍♂️

PatTheMav commented 3 years ago

It was actually @WizardCM who fixed interaction, not the CEF update: https://github.com/obsproject/obs-browser/commit/7143a01e9499d0005129a1fbff844c8be5f16765 👏🏻

marcelomoyano commented 3 years ago

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 commented 3 years ago

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

chrismarquardt commented 3 years ago

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 commented 3 years ago

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

WizardCM commented 3 years ago

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.

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

castles commented 3 years ago

@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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

UnixCro commented 3 years ago

it works with no problems. Very good work!

marcelomoyano commented 3 years ago

It works, the only thing I see (maybe because I'm using an M1 Mac Mini) is the stinger transition when recording locally stutters a lot.

I'm using a quicktime video with alpha channel for the transition...

Other than that, works great.

On Mon, Dec 21, 2020 at 9:15 AM UnixCro notifications@github.com wrote:

it works with no problems. Very good work!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/obsproject/obs-browser/issues/209#issuecomment-748994698, or unsubscribe https://github.com/notifications/unsubscribe-auth/AG2XE5TOMTYLE7CCIP3TFATSV5J6LANCNFSM4LRT7CWQ .

PatTheMav commented 3 years ago

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 commented 3 years ago

Love VP9, will try this for sure.

thanks.

On Mon, Dec 21, 2020 at 11:58 AM Patrick Heyer notifications@github.com wrote:

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.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/obsproject/obs-browser/issues/209#issuecomment-749080821, or unsubscribe https://github.com/notifications/unsubscribe-auth/AG2XE5TQAHBB3RZ5DDKZ7XDSV55CVANCNFSM4LRT7CWQ .

marcelomoyano commented 3 years ago

I just tried this ffmpeg command and it works but it didn't encode all the frames.... is there a way to make sure all the frames are converted?

I will try again tho :)

Thanks.

On Mon, Dec 21, 2020 at 11:58 AM Patrick Heyer notifications@github.com wrote:

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.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/obsproject/obs-browser/issues/209#issuecomment-749080821, or unsubscribe https://github.com/notifications/unsubscribe-auth/AG2XE5TQAHBB3RZ5DDKZ7XDSV55CVANCNFSM4LRT7CWQ .

marcelomoyano commented 3 years ago

I got this error when using FFMPEG

frame= 79 fps=2.7 q=0.0 Lsize= 12953kB time=00:00:02.23 bitrate=47499.8kbits/s speed=0.0753x video:12850kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.801644%

on frame 79... for some reason.

the video file has a few more frames than that.

please let me know what you think?

Thanks

On Mon, Dec 21, 2020 at 11:58 AM Patrick Heyer notifications@github.com wrote:

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.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/obsproject/obs-browser/issues/209#issuecomment-749080821, or unsubscribe https://github.com/notifications/unsubscribe-auth/AG2XE5TQAHBB3RZ5DDKZ7XDSV55CVANCNFSM4LRT7CWQ .

PatTheMav commented 3 years ago

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 commented 3 years ago

Thanks Patrick. I’ll try that.

Sent on the go.


From: Patrick Heyer notifications@github.com Sent: Monday, December 21, 2020 12:49:14 PM To: obsproject/obs-browser obs-browser@noreply.github.com Cc: Marcelo Moyano marcemoyano@gmail.com; Comment comment@noreply.github.com Subject: Re: [obsproject/obs-browser] Browser Source not playing WebRTC videos on MacOS only (#209)

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.

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/obsproject/obs-browser/issues/209#issuecomment-749107955, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AG2XE5ROJRQU2T3CBVU6J3TSV6DBVANCNFSM4LRT7CWQ.