1

Using the Windows Desktop Duplication API, I want to limit the capture of the monitor to no more than 60fps. I know the AcquireNextFrame() has a 'wait' parameter, so maybe this can be used to limit the framerate although I am unsure how. I also noticed that at least when I have an additional monitor connected, that monitor's framerate will go up to the framerate of my main monitor. For example, my external 60hz monitor is reportedly pulling 200fps from desktop duplication.

I do not see any other questions on this site that give an answer on how to achieve the FPS limitation on this API, so any help would be appreciated.

I tried specifying 16ms in as the wait parameter as well as sleeping between AcquireNextFrame. The issue with the later is the fact that sleeping will cause it to miss frame updates.

unstuckkk
  • 13
  • 2

1 Answers1

1

The API does not offer you frame rate limitations. You can just throttle your polling and sleep between AcquireNextFrame having desktop updates collected on background before you actually get them with your next request.

The issue with the later is the fact that sleeping will cause it to miss frame updates.

You can request higher precision timer service (see timeBeginPeriod and friends) and/or use Real-Time Work Queue API (which Microsoft Media Foundation API is built on) to get finer grained execution time slices to request your next frame.

Roman R.
  • 68,205
  • 6
  • 94
  • 158
  • Hello and thank you for your response! So you are suggesting to have a timer go off, say every 16ms for example and pull the frame that way? – unstuckkk Feb 27 '23 at 18:59
  • You receive updates in irregular way, and then desktop and pointer update are mixed. So yes, when you don't need next frame soon, you continue with timer callback and when it's time to get it you call `AcquireNextFrame` with zero or non-zero timeout as you prefer. – Roman R. Feb 27 '23 at 20:40