johnboiles / obs-mac-virtualcam

ARCHIVED! This plugin is officially a part of OBS as of version 26.1. See note below for info on upgrading. 🎉🎉🎉Creates a virtual webcam device from the output of OBS. Especially useful for streaming smooth, composited video into Zoom, Hangouts, Jitsi etc. Like CatxFish/obs-virtualcam but for macOS.
GNU General Public License v2.0
4.06k stars 160 forks source link

Skewed Output #160

Open tejasthy opened 4 years ago

tejasthy commented 4 years ago

Describe the issue When I run the OBS Virtual Camera for Mac, I get some weird output.

To Reproduce Steps to reproduce the behavior:

  1. I downloaded the package with the latest version
  2. I went to OBS and selected "Start Virtual Camera"
  3. I went to Google Meet and switched my camera input to the virtual camera

Behavior The virtual camera is showing a weird image in Google Meet.

Screenshots

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

gxalpha commented 4 years ago

Uhhmm... That should have been fixed 😄 Are you sure you are running 1.2.0? If so, it should show "1.2.0" at the bottom of the test card. Please report back if it does.

Bildschirmfoto 2020-06-03 um 21 33 11
tejasthy commented 4 years ago

I don't see the test card either since it is also showing a skewed image. How do I totally uninstall it totally? I tried uninstalling using what was online but I am wondering if I am missing something. Here's a screenshot of what my test card looks like: Screen Shot 2020-06-03 at 1 06 48 PM

tejasthy commented 4 years ago

I don't see the test card either since it is also showing a skewed image. How do I totally uninstall it totally? I tried uninstalling using what was online but I am wondering if I am missing something. Here's a screenshot of what my test card looks like: Screen Shot 2020-06-03 at 1 06 48 PM

Is there another way to check the version?

gxalpha commented 4 years ago

Insert this command into Terminal.app: cat /Library/CoreMediaIO/Plug-Ins/DAL/obs-mac-virtualcam.plugin/Contents/Info.plist | grep -a1 CFBundleVersion and post the results. It should say the version number in there

tejasthy commented 4 years ago

image Here’s what I got

gxalpha commented 4 years ago

Have you rebooted your mac?

tejasthy commented 4 years ago

Yes I tried that.

gxalpha commented 4 years ago

Could you attach an OBS log of when the problem occurred? That would help understand the problem

tejasthy commented 4 years ago

Yeah sure. Here it is: 2020-06-03 13-06-27.txt

johnboiles commented 4 years ago

Very interesting. I thought we had this solved. I see this in the logs

13:06:27.539:   base resolution:   1440x900
13:06:27.539:   output resolution: 860x538

If you change both resolutions to 1280x720 does that fix things?

image

To be clear, any resolution should work. So this is definitely a bug.

tejasthy commented 4 years ago

Very interesting. I thought we had this solved. I see this in the logs

13:06:27.539:     base resolution:   1440x900
13:06:27.539:     output resolution: 860x538

If you change both resolutions to 1280x720 does that fix things?

image

To be clear, any resolution should work. So this is definitely a bug.

I tried changing the resolution as well. Here's what I got:

Screen Shot 2020-06-04 at 2 40 17 PM

2020-06-04 14-38-13.txt

Thanks for your help by the way.

johnboiles commented 4 years ago

Hmm. I also see

14:38:13.948: NV12 texture support not available

Could you try using a different format (I think this is in the advanced settings page iirc.

tejasthy commented 4 years ago

It worked! Thanks a lot for your help!

Screen Shot 2020-06-04 at 3 44 26 PM
johnboiles commented 4 years ago

Very interesting I wonder if this is an obs bug or if I'm doing something wrong with converting pixel formats. @dodgepong have you seen anything like this in other issues on OBS? Seems like @tejasftc had the format set to NV12 even though his computer reported that it wasn't supported. This then seemed to break the pixel format conversion to yuv422 that my plugin does

dodgepong commented 4 years ago

I've never heard of any issue like this before, no.

jp9000 commented 4 years ago

The NV12 texture not supported message is for whether full NV12 textures are supported, which is a Windows-specific thing at the moment. It doesn't affect OBS' usage of NV12. OBS will just use shaders to implement NV12 if NV12 textures aren't available, and if there was a bug with that, then you would see it in all outputs because it's the default format.

For format conversion, we usually use FFmpeg. So that shouldn't be in our territory either.

When the base and output resolutions don't match, it uses the GPU to scale, but there isn't any known issue with that either, otherwise it would affect all outputs and not just virtualcam.

Without having a full grasp on all your code I can't really say anything substantive, but I don't think OBS would be giving bad NV12 data, because NV12 is a very high frequency code path (it's the default). It would also produce on Windows in that case. Personally, I'd just check the memory of the data at all parts of the pipeline after you download it from the GPU to figure out where it's coming from. I'd recommend using a test image that would make comparing scanlines of the image more simple when checking for errors.

It looks like a bad linesize/pitch value somewhere.

tejasthy commented 4 years ago

Do the other formats cause the output use more CPU Power? It really slowed down my computer so I couldn’t really use it.

gxalpha commented 4 years ago

OBS takes a lot of power in general, I'm afraid a dual core i5 processor (according to your log file) may not be enough to do lot of things simultaneously. I'd like to put your log into the OBS analyzer and look if it is a problem, but I don't know how to :D

jp9000 commented 4 years ago

NV12 probably uses the least amount of CPU processing. It uses the least data.

tejasthy commented 4 years ago

Ok. Thanks Tejas Thiyagarajan tejas.thiyagarajan@gmail.com

On Sat, Jun 6, 2020 at 3:40 PM Jim notifications@github.com wrote:

NV12 probably uses the least amount of CPU processing. It uses the least data.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/johnboiles/obs-mac-virtualcam/issues/160#issuecomment-640127280, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKI6YGSI43FVFBWGQ6SWMZTRVLAUXANCNFSM4NR52XYA .

johnboiles commented 4 years ago

@jp9000 thank you for chiming in! This is the whole of my pixel format conversion code in the plugin:

    obs_get_video_info(&videoInfo);
    struct video_scale_info conversion = {};
    conversion.format = VIDEO_FORMAT_UYVY;
    conversion.width = videoInfo.output_width;
    conversion.height = videoInfo.output_height;
    obs_output_set_video_conversion(output, &conversion);
    if (!obs_output_begin_data_capture(output, 0)) {
        return false;
    }

That should make it so that the output's raw_video method always gets a framebuffer with the pixel format VIDEO_FORMAT_UYVY right? Is it correct to say that this shouldn't depend on the current 'Color Format' setting? I'm trying to understand what about the OBS 'Color Format' setting could mess up the framebuffer I receive since I have this conversion in place.

jp9000 commented 4 years ago

Are you able to reproduce this @johnboiles?

johnboiles commented 4 years ago

Unfortunately no, so im flying blind

jp9000 commented 4 years ago

Hm, I wonder what's going on. At some point I'll test this myself and try to debug. My guess is that the client application itself is using the wrong format or seeing it as the wrong format. I'm just kind of overburdened with my own stuff at the moment (and let's not forget the 115 pull requests on main) so I don't really feel comfortable spending time on this right at the moment.

By the way, is there a reason why you're converting to UYVY rather than just using NV12?

gxalpha commented 4 years ago

@jp9000 to my knowledge UYVY is used because it worked and others didn't, but that was back when this was just a proof of concept and it just stayed.

johnboiles commented 4 years ago

@jp9000 yes not urgent at all; this doesn't seem to be a widespread problem. Your time is probably best spent working on main! Feel free to drop off the conversation here and we won't be offended :)

What @gxalpha says is correct, UYVY was the first thing I was able to make work and I just ran with it. I spent a little bit of time investigating further in https://github.com/johnboiles/obs-mac-virtualcam/issues/102 and I don't think Apple's Core Media APIs support NV12 as a camera format. I also tried to get I444 to work (using kCMVideoCodecType_AppleProRes4444) but that didn't seem to work either. Perhaps RGB could be made to work. Obviously if I can match a pixel format that OBS supports natively with a format that works directly as a Core Media IO DAL plugin format then we can avoid the pixel format conversion which should significantly lower CPU usage I think. This is the list of formats I think I have to pick from on the CoreMedia side. It might also be possible to use something from this list of pixel formats though I'm not exactly sure how.

TayKangSheng commented 4 years ago

I am also facing the same problem. It only started maybe 2 weeks - 1 month back.

  1. This is supposed to be the test card

    Screen Shot 2020-06-29 at 2 05 28 PM
  2. and this is when the virtual cam is started.

    Screen Shot 2020-06-29 at 2 05 11 PM

I am using a mac, but not sure how to get to the logs. if someone can let me know how to get to the logs, i would love to provided it here.

I tried changing the resolution and also color format in advanced settings. Both didn't work. The warpping looks a bit different though.

gxalpha commented 4 years ago

@TayKangSheng There are two logs needed:

Also please insert cat /Library/CoreMediaIO/Plug-Ins/DAL/obs-mac-virtualcam.plugin/Contents/Info.plist | grep -a1 CFBundleVersion into Terminal.app and post the result here.

mgw-sbex commented 4 years ago

I'm having a similar thing, just trying it today. It was working fine initially. I wanted more virtual cams, so I duplicated OBS.app to OBS1.app and turned on both virtual cameras. Now, the video is always like the others. Even after stopping an restarting both OBS and Chrome. Is there a separate process running to implement the virtual camera, or some settings file it relies on that could be corrupted when trying two virtual cams?

cat /Library/CoreMediaIO/Plug-Ins/DAL/obs-mac-virtualcam.plugin/Contents/Info.plist | grep -a1 CFBundleVersion

1.2.0
<key>CFBundleVersion</key>
<string>1.2.0</string>

One of the system.log entries: Jun 30 14:07:55 Michaels-Mac-Pro com.apple.xpc.launchd[1] (com.apple.xpc.launchd.domain.user.501): Service "com.obsproject.obs-studio.28124" tried to register for endpoint "com.johnboiles.obs-mac-virtualcam.server" already registered by owner: com.apple.xpc.launchd.oneshot.0x10000005.obs

gxalpha commented 4 years ago

Due to the way the virtual camera works, only one virtual camera can be used.

Could you try uninstalling and then reinstalling the virtual camera? (https://github.com/johnboiles/obs-mac-virtualcam/wiki/Installing)

mgw-sbex commented 4 years ago

Due to the way the virtual camera works, only one virtual camera can be used.

Could you try uninstalling and then reinstalling the virtual camera? (https://github.com/johnboiles/obs-mac-virtualcam/wiki/Installing)

I didn't know how to uninstall so I just reinstalled, with no effect.

gxalpha commented 4 years ago

Just reinstalling often times does nothing with the DAL-Plugin. The uninstalling tutorial is here: https://github.com/johnboiles/obs-mac-virtualcam/wiki/Installing#uninstalling

mgw-sbex commented 4 years ago

OK I uninstalled (thanks for the help!) and reinstalled, the title card is skewed as the others: Screen Shot 2020-06-30 at 2 37 24 PM

One of the system.log entries: Jun 30 14:07:55 Michaels-Mac-Pro com.apple.xpc.launchd[1] (com.apple.xpc.launchd.domain.user.501): Service "com.obsproject.obs-studio.28124" tried to register for endpoint "com.johnboiles.obs-mac-virtualcam.server" already registered by owner: com.apple.xpc.launchd.oneshot.0x10000005.obs

mgw-sbex commented 4 years ago

When I turn on the virtual camera I get: Screen Shot 2020-06-30 at 2 39 59 PM

TayKangSheng commented 4 years ago

I didn't do anything.. but its fixed now 🤔 🤷

jp9000 commented 4 years ago

@johnboiles I haven't looked at your code but make sure to check for race conditions. "I didn't do anything but it magically fixed itself" and "I can't seem to reproduce" is a big sign of race conditions. I initially had a race condition in my Windows implementation with the memory two processes would share and it caused some incorrect output. Not saying that is the problem, but just throwing it out there as an item for your checklist.

jp9000 commented 4 years ago

The output these people are reporting makes me think the sender/receiver processes have desynchronized dimension values. Not entirely sure if that's the case but it's another thing for the checklist.

jp9000 commented 4 years ago

For the people experiencing this problem: see how changing OBS' resolution affects the skew, and report back. Larger resolutions versus smaller resolutions. You'd want to change the "Output/Scaled Resolution" in OBS' video settings to test that.

johnboiles commented 4 years ago

@TayKangSheng @mgw-sbic what version of macOS are y'all on? Can y'all attach the log from OBS (from the OBS help menu) as well?

@jp9000 thanks for thinking about this. Certainly does seem like the resolutions are somehow desynchronized, especially because the colors seem to be intact (which rules out pixel format differences I think). It's weird though because I send the resolution along with every frame, so I'm not sure how it could have gotten out of sync.

saipanman95 commented 4 years ago

Hi All, I just downloaded this plugin and it worked momentarily and now it doesn't. It is producing the same errors but it only happened after I closed down my google meet stream and attempted to reopen it. It worked fine with video format initially now nothing.

wesalvaro commented 4 years ago
  1. I changed the base resolution from 1920x1080 to 1080x1080
  2. Enabled the virtual camera
  3. Virtual cam showed up cropped in Hangouts
  4. I quit Chrome
  5. I started Chrome
  6. Virtual cam showed up skewed in Hangouts
wesalvaro commented 4 years ago

I opened Snap Camera and set its input to the OBS virtual camera... This seems like it may be a clue: The snap camera preview accurately shows the demo card.

Screen Shot 2020-07-09 at 12 36 35 PM

wesalvaro commented 4 years ago

Based on that, I restored the resolution to 1920x1080 and restarted.
Hangouts in Chrome now accurately shows OBS.

TayKangSheng commented 4 years ago

@gxalpha Now I have this problem with one macbook and don't have this problem with my other macbook. I hope the details below help..

These are the logs from starting OBS + starting virtualcam. console-obs.txt

These are the logs when i am at google meet before starting virtualcam and after starting virtual cam. console-chrome.txt

This is what it looks like before virtualcam is started

Screen Shot 2020-07-16 at 5 55 04 PM

This is what it looks like after virtualcam is started

Screen Shot 2020-07-16 at 5 55 10 PM

This is the output from cat /Library/CoreMediaIO/Plug-Ins/DAL/obs-mac-virtualcam.plugin/Contents/Info.plist | grep -a1 CFBundleVersion

    <string>1.2.0</string>
    <key>CFBundleVersion</key>
    <string>1.2.0</string>

This is the Video settings screen

Screen Shot 2020-07-16 at 5 57 12 PM

This is the Advanced settings screen

Screen Shot 2020-07-16 at 5 57 06 PM

This is my macOS version

Screen Shot 2020-07-16 at 5 58 27 PM

Update

Literally 25 minutes later after I put my mac to sleep.. and now its working..

  1. I had OBS, camera live and chrome (google meet waiting screen) open,
  2. Put my mac to sleep (close the lid)
  3. Open my mac again
  4. open chrome again.. now its working.
stevewww commented 4 years ago

I had the same issue with the OBS virtual camera displaying in Google Meet (Chrome browser). I tried multiple resolution settings within OBS to change the behavior and a full uninstall and reinstall of both OBS and the virtual camera and rebooting the Mac. None of those steps resolved things. In the end I followed @wesalvaro lead and installed Snap Camera to experiment with a different application and it did not exhibit the issue at all. I then went back to test again in Google Meet and the skew problem was gone. I'll be on the look out for this resurfacing and better prepared to identify any triggers. HTH.

truncj commented 4 years ago

I had the same issue with the OBS virtual camera displaying in Google Meet (Chrome browser). I tried multiple resolution settings within OBS to change the behavior and a full uninstall and reinstall of both OBS and the virtual camera and rebooting the Mac. None of those steps resolved things. In the end I followed @wesalvaro lead and installed Snap Camera to experiment with a different application and it did not exhibit the issue at all. I then went back to test again in Google Meet and the skew problem was gone. I'll be on the look out for this resurfacing and better prepared to identify any triggers. HTH.

Same exact situation on my side. Changing OBS resolution, restarting Chrome, restarting MacOS... none of these fixed the problem. Installing Snap Camera fixed the issue even when it isn't running.

mdmarein commented 4 years ago

Hello everyone, I had the same problem. Here are the steps that I followed to correct it:

  1. Close chrome
  2. open OBS.
  3. Verify that Virtual camera is off.
  4. Go to Preferences in OBS> Video.
  5. Base (canvas) and Output (sacled) resolution have to be the same.
  6. Apply.
  7. Close all, restart OSX

It worked for me.

dmckinno commented 4 years ago

I can confirm that @mdmarein's steps fixed the same issue for me as well. I'm pulling a video stream from a Sony a6300 through the Sony Remote app and streaming that window. 640x480 and 1280x720 both work for me.

@gxalpha, maybe the team automatically match base and output resolutions when virtual camera is triggered?

wengzilla commented 4 years ago

Confirmed that @mdmarein's steps fixed my issue as well...

MarkusTiede commented 4 years ago

I'm also affected by this issue - things I've noticed so far: