0

I am using the desktop duplication API right now to record my desktop. I want it to record at at least 30FPS. I noticed that AcquireNextFrame would often return DXGI_ERROR_WAIT_TIMEOUT if I set the time out period to be 33 (33ms is approximately equal to 30FPS) while there is nothing happening on the screen (or even very little). What I have been doing to avoid this is I draw a pixel to the bottom left hand corner of the screen every 30FPS. Like so:

HDC hdc = GetDC(0);
SetPixel(hdc, 0, height, (light_black) ? 0x2 : 0x4);
light_black = !light_black;
ReleaseDC(0, hdc);

This works actually fairly well, but it will still occasionally return DXGI_ERROR_WAIT_TIMEOUT, which is hurting my performance. Considering my solution to this problem is a bit hacky, and it is not even quite working I'd like to figure out how I can resolve this. How can I force AcquireNextFrame to return successfully at a minimum rate of 30FPS?

ktb92677
  • 407
  • 4
  • 16
  • Just keep previous frame and use it in case of timeout. This is reliable compared to inverting a pixel. – Roman R. Feb 15 '19 at 19:04
  • I am already doing that, but this isn't sufficient. I am experiencing latency because due to keeping the previous frame. Without inverting a pixel the success rate of AcquireNextFrame goes even lower, especially while not doing much on the desktop screen like typing in notepad. – ktb92677 Feb 15 '19 at 19:16

0 Answers0