Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webcam cannot take image/video at resolutions >= 1280x720 if connected to a USB2 port #1006

Open
stodor89 opened this issue Aug 5, 2024 · 1 comment

Comments

@stodor89
Copy link

stodor89 commented Aug 5, 2024

The usbipd-win server a Windows 11 machine, running the latest version of usbipd-win (4.3.0). I've tried with different cameras and computers to make sure the hardware isn't faulty.

The usbip client is running Linux (Ubuntu 22.04). On it, I'm executing the following command, but it just stays like that and nothing happens:

user@tds:~$ sudo ffmpeg -f v4l2 -input_format mjpeg -video_size 1280x720 -i /dev/video4 -vframes 1 output.jpeg
ffmpeg version 4.4.2-0ubuntu0.22.04.1 Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 11 (Ubuntu 11.2.0-19ubuntu1)
  configuration: --prefix=/usr --extra-version=0ubuntu0.22.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 70.100 / 56. 70.100
  libavcodec     58.134.100 / 58.134.100
  libavformat    58. 76.100 / 58. 76.100
  libavdevice    58. 13.100 / 58. 13.100
  libavfilter     7.110.100 /  7.110.100
  libswscale      5.  9.100 /  5.  9.100
  libswresample   3.  9.100 /  3.  9.100
  libpostproc    55.  9.100 / 55.  9.100

Whether the usbip client is a WSL2 (with custom kernel that has v4l2), a VM, or a separate computer, doesn't seem to matter -- I've tried all of these. I've also tried to open the camera with MPlayer, Cheese, and Google Chrome, too, but nothing has worked so far.

The way I can get the camera to work is:

  • use a Linux machine as the usbip server
  • use a Windows machine, but attach the camera to a USB 3.2 Type-C port (although it's still laggy)

However, most laptops run Windows, and have their integrated cameras connected to a USB2 hub, so I can't get them to work at native resolution.

I can provide more information if needed. Here's a file with the output of lsusb, usbip list, and v4l2-ctl:
specs.txt

@stodor89 stodor89 changed the title Webcam cannot take image/video at resolutions >= 1280x720 if connected to a USB2 port. Webcam cannot take image/video at resolutions >= 1280x720 if connected to a USB2 port Aug 5, 2024
@dorssel
Copy link
Owner

dorssel commented Aug 8, 2024

Unfortunately, the performance of usbipd-win is limited. That's by design. It uses the VirtualBox drivers, which require a roundtrip through user mode for USBIP. So, there is a lot of context switching per URB:

  • (kernel) Windows network driver gets client USBIP request
  • (usermode) usbipd-win receives it and translates it to a VirtualBox driver ioctl
  • (kernel) VirtualBox driver actually sends the URB to the USB stack
  • (kernel) USB stack eventually receives result and sends it to VirtualBox driver, which in turn sends it to usbipd-win
  • (usermode) usbipd-win translates the VirtualBox result into USBIP and sends it to the network
  • (kernel) network stack sends the reply to the client

The only way to get better performance is to handle everything in kernel mode; that's how the Linux usbipd server does it. However, writing such a driver is hard, and getting it signed by Microsoft is expensive. That's why usbipd-win leverages the existing VirtualBox drivers, at the cost of roundtrip performance.

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

No branches or pull requests

2 participants