Skip to content

bug: linux-v4l2: Virtual Camera can't restart during a recording because the muxer inherits its device fd (upstream #14054) #2278

Closed

Description

@rdoupe

Upstream OBS bug, reported in obsproject/obs-studio#14054 (Linux): Virtual Camera can't be restarted while a recording is running.

Cause (master)

plugins/linux-v4l2/v4l2-output.c.h: try_connect() (around line 147, open(device, O_RDWR)) and the probe loop in loopback_module_available() (around line 107) open the v4l2loopback device without O_CLOEXEC.

  • os_process_pipe_create() (C posix_spawn, and the Rust Command in rust/obs-util/src/platform/unix/pipe.rs) closes only its own pipe fds.
  • So obs-ffmpeg-mux, started for the recording, inherits the device fd and keeps it open for the whole recording.
  • With exclusive_caps=1, v4l2loopback then refuses a new producer when the virtual camera is stopped and started again.

The comment at pipe.rs:35 saying non-stdio fds are closed in the child is wrong. Command keeps any inherited fd that lacks FD_CLOEXEC.

plugins/obs-ffmpeg/vaapi-utils.c.h:24 leaks a render-node fd the same way. #340 fixed only the V4L2 input side.

Plan

  1. RED:
    • Open the loopback output through the virtual camera output, using vivid's output node. Assert that FD_CLOEXEC is set on its fd.
    • End to end: while the virtual camera is active, spawn a child with os_process_pipe_create() and assert the device is not in /proc/<child>/fd.
    • The same check for the VAAPI probe fd.
  2. GREEN: open with O_CLOEXEC in both v4l2-output paths and in vaapi-utils, and correct the pipe.rs comment.

Activity

  1. added
    bug
    on Oct 25, 2026
  2. rdoupe commented on Oct 25, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: #2278.

  3. added
    claimed
    on Oct 25, 2026
  4. added
    ready
    and removed
    claimed
    on Oct 25, 2026
  5. rdoupe commented on Nov 1, 2026

    @rdoupe
    CollaboratorAuthor

    @Avasam The Linux Virtual Camera could not be restarted while a recording was running (upstream obs-studio issue 14054). The cause was that the recording's muxer process inherited the virtual camera's device handle and held it open for the whole recording, so the device refused a new producer. In obs-rust the handle is now kept out of child processes, so stopping and starting the Virtual Camera during a recording works.

    obs-rust is an AI-assisted fork of OBS, based on current OBS master, with extra bug fixes like this one.

    It ships in the OBS-Studio-Rust v1.0.0 release: https://github.com/obs-rust/obs-studio/releases

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

Metadata

Metadata

Assignees

Labels

bugready

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions