Skip to content

Windows desktop capture performance #2003

Description

@bp2008

Hi. First of all, thank you so much for building MeshCentral. I just discovered it today, and I am in awe of what you have accomplished. In 2016, I started a much less ambitious project with remarkably similar goals and design choices, but I never got very far due to a lack of time and motivation. I am thrilled to see so many of my goals fully realized by MeshCentral, and so much more. With such active development too! ❤️❤️❤️

So, I set up a MeshCentral server in an Ubuntu 20.04 VM (which went fine following instructions for 18.04) and installed the agent software on two Windows machines. Something I noticed right away is that the desktop capture performance is (I'm sorry) terrible. To be specific, I mean the "fast" frame rate is quite slow, it makes the local mouse pointer flicker, and it consumes significant CPU time when nothing is changing on screen. Based on earlier issues (#1237, #1208, #357) it seems you are open to improving all of this.

The solution is to use DXGI Desktop Duplication which is an API available in Windows 8 and newer. This API tells you about regions of the screen that have moved and changed in a very efficient manner. The frame rate is limited mainly by your encoding, data streaming, and decoding pipeline. When I used this several years ago, I was able to achieve 60+ FPS when dragging a small window around on a 4K desktop. I would send the moved region information straight to the browser where there are HTML5 canvas operations to easily handle moving image data regions. For the changed regions, I'd encode them with libjpeg-turbo and have the browser decode them and draw them in the appropriate spots on the canvas. This jpeg approach won't handle full screen video amazingly well, but for most desktop usage this approach performs pretty well. To do any better I suspect it would be necessary to use a hardware-accelerated video encoder.

Some caveats about DXGI Desktop Duplication that I recall from when I was messing with it:

  • Requires Windows 8 and newer
  • It failed when no user was logged in, forcing me to fall back to other capture methods. I'd have my agent program occasionally try to restart the DXGI code so that the full efficiency and frame rate could be restored after a user login.

I'm not sure, maybe I should have posted this in the MeshAgent repo?

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions