dev47apps / droidcam-linux-client

GNU/Linux/nix client for DroidCam
http://www.dev47apps.com
GNU General Public License v2.0
1.08k stars 174 forks source link

Fatal: Unable to query video device. errno=22 #242

Closed smidm closed 10 months ago

smidm commented 1 year ago

Describe the bug

First Droidcam connection after fresh boot works fine.

Second fails with:

Fatal: Unable to query video device. errno=22

When running the Droidcam GUI app it just fails silently and the icon doesn't appear. I'm using USB connection to iPhone, but I tried the network connection as well.

Workaround:

Unload and load the v4l2loopback module.

sudo "rmmod v4l2loopback; modprobe v4l2loopback"

After this Droidcam connects properly.

Additional context

uname -a
Linux pmd85 6.1.13-100.fc36.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Feb 22 18:13:06 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

~/.config/droidcam

v4
ip=192.168....
port=4747
audio=0
video=1
size=1920x1080
confirm_close=1
vertical_flip=0
horizontal_flip=0
type=2
aramg commented 1 year ago

Cant seem to reproduce this. Any chance other programs might be trying to use v4l2loopback as well? Does the webcam remain open in between droidcam sessions in other software?

You could try installing v4l2loopback-dc, and see if the droidcam version works as expcted.

AaronVincent6411 commented 1 year ago

First we need to check in cd /tmp/ (i am using linux) whether droidcam folder is there. If it is there remove it and then reinstall droidcam. For windows run .exe file and reinstall.

Reinstalling will fix this issue for both linux and windows.

Initially it was like this for me

[lionex@fedora ~]$ droidcam
Fatal: Unable to query video device. errno=22
[lionex@fedora ~]$ sudo droidcam 
Fatal: Unable to query video device. errno=22
[lionex@fedora ~]$ 

Then i reinstalled. Now it's working fine for me

Screenshot_2022-11-15_12-16-41

brauliobo commented 1 year ago

got the same here with droidcam archlinux aur package

dops7 commented 1 year ago

Same here.

I found the loopback device loosing capability "Video Output" to be causing this. This can be shown by command "v4l2-ctl -d /dev/video0 --all". On first attempt (and after reloading module v4l2loopback) it is set, and with the GUI client it always gets lost. With the command line client droidcam-cli this doesn't happen, but when I query capabilities with v4l2-ctl after running droidcam-cli, the capability also disappears. There is an exact correlation between error "Unable to query video device. errno=22" and this capability not reported.

I patched droidcam to omit setting the formats and then video starts on the device, but consumers don't work and show an error (tested with vlc).

I'm using Debian 12 (Bookworm) with package v4l2loopback-dkms version 0.12.7-2 and parameter exclusive_caps=1 (which I need for the device to be recognized by Chrome and the video conferencing software).

Btw this is also reported for another video creation application here https://github.com/letmaik/pyvirtualcam/issues/61 .

aramg commented 1 year ago
dops7 commented 1 year ago

Thank you for the reply.

  • Try toggling the exclusive_caps=1 option, and see if that helps. Again the v4l2loopback-dc module that comes with the client may work better.

With exclusive_caps=0 there isn't an issue (as anticipated), but as Chrome doesn't like it, not a solution for me. Indeed, the v4l2loopback_dc module doesn't show the issue and also works with Chrome. Then I probably need a script for signing with MOK on my other machine using secure boot to be prepared for the regular kernel updates.

* There is a new DroidCam Client out in beta, that you can experiment with. It's based on OBS Studio, and It will auto-load the v4l2loopback module: https://beta.droidcam.app/ (works with the DroidCam iOS app and the "DroidCam OBS" app on Android)

There was a segmentation fault with the beta client. But anyway, I like the old client way more: With building a Debian package from source, dependencies are 100% under control, only a few files installed and package size approx. 1/600 compared to the OBS approach.

meiser79 commented 11 months ago

Hi, just as a feedback, I still see the error 22 with latest changes.

meiser79 commented 10 months ago

Hmm, maybe a misreading, I don't know why you put a "thumbs up" above. The issue is NOT solved with latest changes.

aramg commented 10 months ago

Just acknowledging the comment... The issue still open. The client now sets both output and capture caps on the module.

What if you use v4l2loopback-ctl set-caps /dev/video "YU12:1280x720" to setup to module?

nilp0inter commented 10 months ago

Hi, @aramg, I am experiencing the same issue.

I tried the command v4l2loopback-ctl set-caps /dev/video "YU12:1280x720" which produced no output and then run droidcam which reported the same error 22. I tried again with sudo but got the same result.

Furthermore, I am unable to test v4l2loopback-dc with my kernel 6.6.1 because of #262.

LaHaine commented 10 months ago

I have the same error message on Ubuntu 22.04 LTS with kernel 6.2.0-39-generic and v4l2loopback dkms 0.12.7. This is strace output from droidcam (latest version):

newfstatat(AT_FDCWD, "/dev/video0", {st_mode=S_IFCHR|0660, st_rdev=makedev(0x51, 0), ...}, 0) = 0
openat(AT_FDCWD, "/dev/video0", O_RDWR|O_NONBLOCK) = 13
ioctl(13, VIDIOC_QUERYCAP, {driver="v4l2 loopback", card="Dummy video device (0x0000)", bus_info="platform:v4l2loopback-000", version=KERNEL_VERSION(6, 2, 16), capabilities=V4L2_CAP_VIDEO_CAPTURE|V4L2_CAP_VIDEO_OUTPUT|V4L2_CAP_EXT_PIX_FORMAT|V4L2_CAP_READWRITE|V4L2_CAP_STREAMING|V4L2_CAP_DEVICE_CAPS, device_caps=V4L2_CAP_VIDEO_CAPTURE|V4L2_CAP_VIDEO_OUTPUT|V4L2_CAP_EXT_PIX_FORMAT|V4L2_CAP_READWRITE|V4L2_CAP_STREAMING}) = 0
ioctl(13, VIDIOC_S_FMT, {type=V4L2_BUF_TYPE_VIDEO_OUTPUT, fmt.pix={width=0, height=0, pixelformat=v4l2_fourcc('Y', 'U', '1', '2') /* V4L2_PIX_FMT_YUV420 */, field=V4L2_FIELD_NONE, bytesperline=0, sizeimage=0, colorspace=V4L2_COLORSPACE_DEFAULT}} => {fmt.pix={width=640, height=480, pixelformat=v4l2_fourcc('Y', 'U', '1', '2') /* V4L2_PIX_FMT_YUV420 */, field=V4L2_FIELD_NONE, bytesperline=640, sizeimage=462848, colorspace=V4L2_COLORSPACE_SRGB}}) = 0
ioctl(13, VIDIOC_S_FMT, {type=V4L2_BUF_TYPE_VIDEO_CAPTURE, fmt.pix={width=640, height=480, pixelformat=v4l2_fourcc('Y', 'U', '1', '2') /* V4L2_PIX_FMT_YUV420 */, field=V4L2_FIELD_NONE, bytesperline=640, sizeimage=462848, colorspace=V4L2_COLORSPACE_SRGB}}) = -1 EBUSY (Device or resource busy)
ioctl(13, VIDIOC_G_FMT, {type=V4L2_BUF_TYPE_VIDEO_CAPTURE}) = -1 EINVAL (Invalid argument)
write(2, "Fatal: Unable to query video dev"..., 62Fatal: Unable to query video device. dev=/dev/video0 errno=22
) = 62
futex(0x7f929825300c, FUTEX_WAKE_PRIVATE, 2147483647) = 0
exit_group(0)                           = ?
+++ exited with 0 +++
aramg commented 10 months ago

Thanks, will look into this some more again..

aramg commented 10 months ago

Ok, I was finally able to reproduce this behavior, and this new update seems to be working correctly: https://github.com/dev47apps/droidcam/releases/tag/v2.1.2

meiser79 commented 10 months ago

Works fine under Ubuntu 22.04 with v4l2loopback module included in kernel 5.15.0-91-generic (not the dkms package). Thanks a lot!

nilp0inter commented 10 months ago

Is also working fine under NixOS unstable. Thank you!