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
60.11k stars 7.96k forks source link

v4l2 properties not set when changing device in video capture device #3865

Closed janakelarsson closed 2 weeks ago

janakelarsson commented 3 years ago

Platform

Operating system and version: Ubuntu Linux 20.04 OBS Studio version: 26.0.2, installed via snap package

Expected Behavior

When I switch camera in a Video Capture Device I expect the settings in the Video Capture Device dialogs to be applied on the camera.

Current Behavior

I need to manually select each option I need to apply (resolution, zoom, manual focus, power line frequency, ...), change the setting away from the setting I want and then change it back to /set/ the value.

I think this only happens if I disconnect hardware and re-insert it. Perhaps also on sleep/resume

Steps to Reproduce

  1. Disconnect camera from laptop
  2. Re-connect camera, this will now appear as different device
  3. Select new camera device in Video Capture Device
  4. Start re-applying settings

Additional information

Fenrirthviti commented 3 years ago

Maybe I'm misunderstanding here, but if the system is treating this as a new device, sounds normal? I wouldn't want to apply previous device settings to a new device that might not be the same one, that sounds like a bad idea.

janakelarsson commented 3 years ago

If I wanted different settings, I would have created (two different scenes with) two different Video Capture Devices.

Plus, that this gets reset if the computer wakes up from suspend really is a hassle. Or if I remove the computer from the dock, run to a meeting without the camera, and then return to my office, I then need to reset all of the settings I thought I had fixed.

Also, my ambient light won't magically shift from 50 Hz to 60 Hz for example.

If this really was intentional, then why do the settings remain in the UI (without being applied to the new --- in reality same --- device)?

Scrxtchy commented 3 years ago

It sounds lik but these are the device configurations that are provided by the driver of the camera, and not the properties that are controlled by by OBS. There have been a plethora of discussions that people have in regards to their logitech webcams not persisting settings at all, more specifically for a single device, but these UVC controls are isolated to that device so I don't expect them to be have any sync capability. https://obsproject.com/forum/threads/why-does-my-webcam-settings-in-obs-keep-resetting-configure-video-setting.107243/ As mentioned in this forum thread, device settings are not ccontrolled by OBS by any capacity, it is only a dialogue exposed by the device driver, and the vendor is responsible for its functionality.

janakelarsson commented 3 years ago

You mean to say, the dialog itself is displayed by the driver, not by OBS Studio? On a linux system? Forgive me if I doubt that, but this makes me curious. Can you point to where in the source I would find the call to open the driver dialogue?

Scrxtchy commented 3 years ago

I have found the fatal flaw in my point of view. I was under the assumption that dshow is platform agnostic and that's what I had made by basis off of, this isn't the case as it is purely Microsoft APIs. The dshow code is still a little complicated but I still understand how it works. Now that I'm looking at the code responsible for linux capture, it is a bit more complicated that I'm willing to sink time into.

janakelarsson commented 3 years ago

That sounds more like what I expect. Can you link to where in the code to look?

Fenrirthviti commented 3 years ago

There was a PR recently that added support to these controls for v4l2 (which is what Linux uses, dshow is windows-only).

You can see the PR (and references to codepaths which are controlling theses settings) here: https://github.com/obsproject/obs-studio/pull/1815

janakelarsson commented 3 years ago

That helps explain the situation. I'll try to follow the discussion there (also).

Fenrirthviti commented 3 years ago

Sorry, I say recently but this was about a year ago, there was one a few months back that fixed up some issues with the controls (unrelated to this specific issue), but hopefully helps point you in the right direction.

While not 100% the same thing, there's been a lot of discussion historically on the Windows dshow side of things where we should save those driver-specific settings and just apply them if the same device is detected. There's documentation that seems to indicate there is some expectation for an application to be saving those settings individually, rather than system-wide (which, when you think about it, makes sense as you might have different settings for different applications). I'd say the same expectation applies here, given the current behavior. I'm unsure what the best solution is, though.

janakelarsson commented 3 years ago

I saw it was a year ago and thought recent meant different things to you and me, no real problem.

For devices, trouble is to keep track of what was set before. I would be fine with using different scenes with different settings for different cameras.

I'd expect the following behavior: either 1) When I insert a new device I get the defaults displayed in the dialog. I then need to re-set everything. Or (preferred) 2) When I insert a device I get the settings I have specified, which are displayed in the dialog. (Settings not available for the new device, that I changed, get greyed out. Or something.)

As it is now I get 0) When I insert a device it has default settings but the ones displayed in the dialog is what I set before. I need to change them and then re-set to get the value I want. Every time I connect to the office dock.

Fenrirthviti commented 2 weeks ago

Closing as stale. If this is still an issue please open a new issue with updated reproduction steps on the latest version of OBS.