schellingb / UnityCapture

Streams Unity rendered output to other Windows applications as virtual capture device
420 stars 65 forks source link

Can't get it to work in Firefox #7

Open Straafe opened 5 years ago

Straafe commented 5 years ago

So I've tested the project in OBS and it works flawlessly and easily, however there seems to be some issue preventing it from working in any firefox web page. I've tested the older project this is based on (UnityCam, https://github.com/mrayy/UnityCam), and it works in firefox (using various webcam testing sites and also on roll20.net). I did test this project out in chrome and it does work there.

When I go to webcam testing sites in firefox I get various errors (which may or may not be valid and helpful), usually it is along the lines of "Webcam already in use, please close any other programs using the webcam and try again" (although no other programs are using it) or "Camera not authorized, please check permissions." I think the most accurate/valid error is:

NotReadableError: Failed to allocate videosource

Which I got here.

I've tried to identify and eliminate any local circumstances to cause something like this to happen, but it's still possible this is user error. Has anyone else used this with firefox successfully? The webcam was not being used elswhere when I tried to use it in firefox. To make complete sure of this, I tried it after restarting both the workstation and browser and got same errors.

Edit: I don't know the first thing about C++, but I downloaded both the source code for this and UnityCam to see if I could compare/contrast them but they are structured differently enough I couldn't determine anything. I'd much prefer to use this one considering all the performance benefits and extra features it has.

schellingb commented 5 years ago

I tried and tried but I just can't get the new features offered by UnityCapture to OBS like both 24 bit (XRGB) and 32 bit (ARGB with alpha channel) support and custom resolutions to continue to work while also supporting newer Firefox.

It works fine in old Firefox 56 and also in all Chrome versions that I have.

I'm inclined to say that it's a problem with Firefox but seeing that the format negotiation of DirectShow filters is an incomprehensible hellscape with no usable documentation that I could find so I can't blame anyone but Microsoft.

How important is it to you? :-) The only solution I can come up without spending multiple days on this is to offer two separate Installs which is less than ideal...

Straafe commented 5 years ago

Well, it isn't the end of the world if it doesn't support Firefox, as I can just use the older version (especially if this is beginning to eat up all of your spare time). The project I'm working on is a personal one, and I could get away with using the older version (UnityCam) since even though all the features you added are phenomenal, I really just need a basic feed from Unity.

If it's easy enough to create a separate version that removes some features to support the newer Firefox, great! If not, no problem. The main thing I will miss is the feature you recently added, the ability to change the device's name, which UnityCam does not have.

Edit: I think I may have found where the capture name is set in UnityCam, line 6 of Globals.h. Problem is, the scripts are littered with errors and I'm not sure if it's because the project is old or if my environment is not properly set up for C++ (I'm just using Visual Studio 2017 with 'Desktop development with C++' installed, maybe I am missing some references), but it prevents me from recompiling UnityCam to test changing that global variable.

Straafe commented 5 years ago

So I was able to get the original UnityCam project to compile, and if I change that line in Globals.h, it does change the device name. Since I don't need the device name to be dynamic, I don't mind hardcoding in a new name and rebuilding the DLL's for this project, it works perfectly fine for me.

To get it to compile I had to download some old Windows SDK's including the some Windows 7 directshow stuff, and add "legacy_stdio_definitions.lib" to Linker input. Took a bit of troubleshooting but in the end it worked!

I'd still prefer to use UnityCapture, but UnityCam should work well enough for my project too.