Skip to content

bug: linux-v4l2: saved camera controls override an external PTZ controller on every start and reconnect (follow-up of #363) #385

Closed

Description

@rdoupe

Follow-up of #363 / PR #364, raised by alerque on #363. Since #364, a Video Capture Device (V4L2) source writes its saved camera controls to the camera whenever the device opens (OBS starts, the source restarts, the camera is replugged or comes back from suspend) and on every settings update. Someone who drives the camera with an external PTZ controller gets the pan, tilt or zoom last set in OBS's Properties written back over the controller's position every time OBS starts or the camera reconnects. Before #364 OBS never did this, so that setup worked; there is no way to turn it off.

#364 only writes controls that have a saved value (ones changed in this source's Properties at some point) and that differ from what the camera reports. Controls never touched in OBS are left alone, and relative pan/tilt is never replayed. So the problem is only with absolute controls the user once set in OBS and now drives from elsewhere.

Location

  • plugins/linux-v4l2/v4l2-input.c v4l2_init() (line 918) calls v4l2_apply_controls() unconditionally (line 991), on create, restart and reconnect (device_added(), line 766). v4l2_update() (line 1067) calls it again when the capture keeps running (line 1101).
  • plugins/linux-v4l2/v4l2-controls.c v4l2_apply_controls() (line 226) writes every saved control that differs from the device.

Class

Regression for one workflow (external PTZ control): a setting change from #364 that the user cannot opt out of.

How it is reached

  • Set "Zoom, Absolute" (or pan/tilt) once in the source's Properties, then move the camera with an external PTZ controller. Restart OBS or replug the camera: the camera jumps back to the zoom saved in OBS.
  • With the camera moved by the controller, change any other setting of the source (for example "Use Buffering", or a script/obs-websocket SetInputSettings): the saved zoom is written again.

Reproduced headlessly with the test_v4l2_controls harness from #364 (the real v4l2-input.c and v4l2-controls.c against a fake UVC webcam and fake udev): with a saved zoom of 300 and the camera at 250, creating the source, a replug and an update of another setting each write the zoom back.

Proposed fix and failing test

Fix: a per-source checkbox, "Restore camera controls when the camera connects", as the first item of the Camera Controls group in the source's Properties, with a tooltip that names external PTZ controllers.

RED test (cmocka, extends test_v4l2_controls; no camera, kernel module or display). The test now creates sources with the source's defaults, as OBS does, and adds six cases:

  • the option exists, is on by default, has a tooltip, and stays in the Camera Controls group after the group is rebuilt for the device;
  • unchecked: no saved control is written when the source is created, when the camera is replugged, or when another setting is updated after an external controller moved the zoom;
  • unchecked: a control changed in the Properties window is still written, and only that one;
  • ticking or unticking the checkbox writes no control.

6 of 14 fail today; the 8 cases from #364 still pass with the default.

Activity

  1. rdoupe commented on Oct 12, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: this issue.

    1. RED: 6 new cases in test_v4l2_controls (fake UVC webcam and udev): with "Restore camera controls when the camera connects" off, no saved control may be written on create, reconnect or a settings update; a control changed in Properties is still written; ticking the option writes nothing; it defaults to on.
    2. GREEN: the per-source option, first in the Camera Controls group, with a tooltip naming external PTZ controllers.
      PR today.
  2. added a commit that references this issue on Oct 12, 2026
    7975a38
  3. alerque commented on Oct 16, 2026

    @alerque

    This is not universally fixed. I see the new checkbox for restoring settings for some cameras but not others. Unfortunately the relationship to relevance vs. controls is backwards for me.

    • My generic USB webcams (e.g. logitec, builtin laptop, etc.) show the new "restore camera controls" checkbox.

    • My fancy external PTZ camera with absolute and relative PTZF controls does not show the box. This can be seen in the screenshot I just reported for bug: gui: source property sliders practically unusable #827:

      Image
  4. zackees commented on Oct 16, 2026

    @zackees
    Member

    Thanks, this explains it. The checkbox is in the V4L2 source ("Video Capture Device (V4L2)"), added by #895/#976. It is not tied to the camera model or a capability check. Your generic webcams are in V4L2 sources. Your PTZ camera is in a "Video Capture Device (PipeWire)" source (that is what your #827 screenshot shows), and the PipeWire source has no such option in the code on master. #1054 only fixed greying out manual controls there.

    So #385 is only fixed for the V4L2 source. I filed #1067 for adding the option to the PipeWire source and asked rdoupe, who owns the camera controls work, to take it. Workaround until then, not tested by me: add the camera as a V4L2 source instead.
    This issue stays open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions