Skip to content

fix camera listing#344

Open
poulpeit wants to merge 3 commits intoToufool:mainfrom
poulpeit:_fix_linux_cameras
Open

fix camera listing#344
poulpeit wants to merge 3 commits intoToufool:mainfrom
poulpeit:_fix_linux_cameras

Conversation

@poulpeit
Copy link
Copy Markdown

This PR has been made in order to fix an issue on capture device listing in the settings menu on linux.

Video devices are listed in /sys/class/video4linux with "video<ID>".
When adding or removing a new webcam, a new folder video<ID> is created or deleted, but there is some edge cases where ID are not contiguous (example: plug two devices and remove the first one).

As the code is currently a range(0, <number of folder>), in these edge cases, capture devices are not properly detected.

To fix this, I changed get_input_devices to properly list every folders.
As a side effect, I had to set enumerate into get_input_devices instead of get_all_video_capture_devices

Please note that, as I don't have any Windows available, tests were made only on Linux, but these changes should not break Autosplit on Windows.

@Avasam
Copy link
Copy Markdown
Collaborator

Avasam commented Mar 24, 2026

Thanks! I do have a duplicate cam listing issue on my Linux machine, so I can test this. Maybe not now though as I just came back from organising and running a gaming convention + show. Will need some time to recover.

@poulpeit
Copy link
Copy Markdown
Author

OK, I thought duplicate cam listing was an issue on my side, but obsiously no :)

I dug a bit and saw that this is a normal behavior. As explained on https://askubuntu.com/a/1191209 Linux kernel creates a second device for metadata and stuff.
Listing every video devices on /sys/class/video4linux will by design show the second device.

Instead of listing /sys/class/video4linux, I found that we should ask for capabilities for every device. This can be done by using ioctl, asking for VIDIOC_QUERYCAP data and check if the V4L2_CAP_VIDEO_CAPTURE flag is set.
A bit of explaination here: https://www.linuxtv.org/downloads/legacy/video4linux/API/V4L2_API/spec/rn01re56.html

I changed the source code in order to check for this.
It seems to be a bit slower to get every video devices on the settings window, but nothing really annoying.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants