Skip to content

Linux: obs-ffmpeg-mux inherits V4L2 device file descriptors, so Virtual Camera can't restart while recording #14054

Open

Description

@Avasam

Operating System Info

Ubuntu 26.04

Other OS

No response

OBS Studio Version

32.2.2

OBS Studio Version (Other)

No response

OBS Studio Log URL

https://obsproject.com/logs/eYGldi62H2Ufdxx0

OBS Studio Crash Log URL

No response

Expected Behavior

Stopping and starting the Virtual Camera again works while a recording is in progress.

Current Behavior

Restarting the Virtual Camera fails with "Starting the output failed. Please check the log for details."

Image

The log only shows:

Starting Virtual Camera output to Source : <source>
Failed to start virtual camera

The Virtual Camera can be started again as soon as the recording is stopped.

Steps to Reproduce

  1. Start Virtual Camera
  2. Start Recording
  3. Stop Virtual Camera
  4. Start Virtual Camera: fails
  5. Stop Recording, then Start Virtual Camera: works

Anything else we should know?

Disclaimer: I used an LLM to search for similar issues and help fill in this section. Figured it's better than just leaving it mostly empty.


obs-ffmpeg-mux inherits the V4L2 file descriptors that OBS has open, and it keeps them open for the whole recording. After step 3, with no other consumer of the loopback device:

$ fuser -v /dev/video4
                     USER        PID ACCESS COMMAND
/dev/video4:         avasam    35094 F.... obs-ffmpeg-mux

With exclusive_caps=1, v4l2loopback still sees an open handle from the old producer, so OBS can't reopen the device as an output. The same muxer process was also holding /dev/video0 and /dev/video2, the V4L2 Video Capture Device sources in my scenes. This probably explains the comment in #12506 about not being able to close and reopen a webcam while recording.

Cause: V4L2 devices are opened without O_CLOEXEC, and os_process_pipe_create uses posix_spawn, which only marks its own pipes close-on-exec (#10574). Any other descriptor leaks into the child.

Suggested fix: add O_CLOEXEC to these open / v4l2_open calls. Closing all non-stdio fds in the child after spawning would be a broader option.

Not the same root cause as #12506 (fixed by #12510), even though the symptom is the same.

Environment:

  • OBS 32.2.2, Flatpak, X11
  • v4l2loopback 0.15.3 (DKMS) with the options OBS uses by default (exclusive_caps=1)
  • kernel 7.0.0-38-generic
  • Not tested without exclusive_caps=1

Activity

  1. changed the title [-]Linux: `obs-ffmpeg-mux` inherits V4L2 device file descriptors , so Virtual Camera can't restart while recording[/-] [+]Linux: `obs-ffmpeg-mux` inherits V4L2 device file descriptors, so Virtual Camera can't restart while recording[/+] on Oct 19, 2026
  2. tiberium-v commented on Oct 19, 2026

    @tiberium-v

    I can't reproduce that - but I'm on Arch linux and kernel 6.18 LTS.

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

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions