Fixed duplicate Video Capture Device listing on Linux#344
Conversation
|
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. |
|
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. 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. I changed the source code in order to check for this. |
|
Tested with my Logitech C920 + some generic USB Video stick and both seemed fine ! Items deduplicated from list.
I don't mind it being slower, but I remember previously having a similar approach on Windows (request a frame from each iterated item) and it would cause the device to freeze if it was already in use ! See the comment under Luckily I still have my GV-USB2, which had that behaviour. So I'll go test with that.
Looking at the code change, I agree I don't see any reason this would affect Windows. |
|
Thanks! I've pushed some (I think) improvements. Feel free to challenge them or open a new PR if you think I missed something ! |
|
Thanks for the merge and glad it helped. I'll have a try on the new code, but it seems to be great! |
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_devicesto properly list every folders.As a side effect, I had to set
enumerateintoget_input_devicesinstead ofget_all_video_capture_devicesPlease 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.