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

improve webcam support #1113

Closed
totaam opened this issue Feb 4, 2016 · 9 comments
Closed

improve webcam support #1113

totaam opened this issue Feb 4, 2016 · 9 comments
Labels

Comments

@totaam
Copy link
Collaborator

totaam commented Feb 4, 2016

Follow up from #1030. See Webcam.

  • there is no systray menu for it
  • framerate is low
  • black and white only, low resolution (hardcoded csc dependencies)
  • no support for multiple sessions per server..
  • detecting when devices are added or removed? (dbus?)
  • it uses too much bandwidth (mostly wasted too)
  • Fedora dkms packaging for v4l2loopback?
  • investigate win32 and osx support (shadow server / remote webcam)
@totaam
Copy link
Collaborator Author

totaam commented Feb 4, 2016

We should also add support for native H264: Using the Logitech C920 webcam with Gstreamer

@totaam
Copy link
Collaborator Author

totaam commented Jun 14, 2016

2016-06-14 18:12:04: antoine commented


Updates:

  • finally found the fix for the offset hack: r12822 (will backport)
  • update webcam tray menu when devices are added or removed (linux only via python-inotify): r12819, packaging updates in r12821, fixup in r12820
  • r12823 should now support multiple users: load the kernel module with modprobe v4l2loopback devices=4 and the xpra server will try all devices until it finds one it can use (not fully tested)
  • r12825 makes sure we filter out video devices that cannot do capture

The webcam tool now shows a lot more device information.

Maybe too late for us, but I've just found a python ctypes interface for v4l2: [https://pypi.python.org/pypi/v4l2]

As for v4l2loopback, packaging it for dkms is too hard (dkms always seem to cause more problems that it solves for me too). Why isn't this merged upstream? Can we help push it? The code is stable and does not change much.

Remaining issues:

  • framerate and hardcoded csc dependency
  • win32 and osx support:

This is what the systray now looks like:
[[Image(new-webcam-menu.png)]]

@totaam
Copy link
Collaborator Author

totaam commented Jun 15, 2016

2016-06-15 17:15:54: antoine commented


  • r12827 detects video capture devices on win32 using comtypes. (maybe we could capture to a PIL image more or less directly, and drop the dependency on opencv: [http://pydoc.net/Python/jaraco.video/1.2/jaraco.video.capture/] using ISampleGrabber)
  • r12828 detects device change events using WM_DEVICECHANGE (not specific to video devices... but seems to work nonetheless)

More links on win32 device events API:

OSX:

As for framerate, without going as far as refactoring the window-source code so we can use it for sending webcam frames, maybe we can send frames based on the line latency. (ie: 200ms round trip -> allow 4 frames in flight for a 20fps target)

@totaam
Copy link
Collaborator Author

totaam commented Jun 15, 2016

2016-06-15 17:19:53: antoine uploaded file new-webcam-menu.png (20.2 KiB)

new systray menu shows my webcam as option
new-webcam-menu.png

@totaam
Copy link
Collaborator Author

totaam commented Jun 16, 2016

2016-06-16 12:22:03: antoine uploaded file osx-device-notifications.patch (14.3 KiB)

try to get notifications when USB devices are added or removed

@totaam
Copy link
Collaborator Author

totaam commented Jun 16, 2016

2016-06-16 13:27:31: antoine commented


The patch above attempts to use IOKit.py to get device notifications for OSX, but it has a number of problems:

  • can't re-use the same main loop as GTK, so it uses its own thread and main loop - which may be the cause of other problems..
  • not very stable
  • had to modify IOKit.py
  • can't get the device path (that part crashes if you try to use it)
  • webcams don't work on OSX anyway since we cannot build opencv..

Similar / related code:

Webcam API links:

@totaam
Copy link
Collaborator Author

totaam commented Jun 16, 2016

2016-06-16 17:09:25: antoine commented


r12834 solves the framerate issue over slower links by calculating how many frames-in-flight we should have and try to keep to that number.
It adds XPRA_WEBCAM_FPS means we try to send that many frames per second (ie: the default value of 20 will send a frame every 50 milliseconds), unless the ack packets start coming in late.
Debug output:

may_send_webcam_frame() latency=307, not acked=6, target=6

Not dealing with shadow servers, because I don't see how this would work.

This will do for this release, will follow up in #1231.

@totaam
Copy link
Collaborator Author

totaam commented Sep 23, 2016

@totaam totaam closed this as completed Dec 26, 2016
@totaam
Copy link
Collaborator Author

totaam commented Oct 21, 2019

For win32 and macos see #1231

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant