microsoft/Windows.UI.Composition-Win32-Samples

Two frame delay when capturing

nergnezor opened this issue ยท 4 comments

I've played around with the ScreenCaptureForHWND C++ sample project, but I need it to be faster from capture to display. I have tried different framerates (30, 60 & 120 Hz) and there is almost always a two frame delay from the captured window to the app window. Does anyone know where this delay coming from and how to lower it?

Generally the DWM is triple or double buffered, this isn't unique to presenting captured content. There is no way to disable the DWM as of Windows 8. And if you did, the capture API would not be able to return frames to you, as they are rendered by the DWM ๐Ÿ™‚.

Thank you for the quick response! And the DWM only updates the buffers once every monitor refresh i assume? Do you know if I can speed up the buffer copying then? 66 ms (2 x 1000/30 Hz) is a long time to wait if you're in a hurry ๐Ÿ™‚

That's correct, we're locked to the vsync (normally, there are some edge cases given your monitor topology and if you're running a full-screen game). I'm guessing by making a copy of the buffer you're talking about calling CopyResource or CopySubresourceRegion? How are you measuring this?

No, I meant forcing the DWM buffers without waiting for vsync.
I'm measuring by recording the screen area of the source and target and then stepping through the recording frame by frame where there are changes