Desktop Duplication API skip frame issue and slowness issue

Setup Details: Windows 2016, NVIDIA Quadro P4000, Driver Version: 465.89 , CUDA Version: 11.3.

We are trying below example where it captures windows screen using DDA, do h264 encoding using nvenc and output to a video file.

Issue 1:

While recording the video I have a timer on the screen, After screen recording if we watch the video, there is skip of frames. Attaching the video where time from 10.21.53 jump to 10.22.07.
DDATest_0.h264 (4.4 MB)

Issue 2:

While calling AcquireNextFrame with wait time 5 milliseconds, sometime I observer higher accumulated frame.

“frameNo: 108 | Accumulated: 68 | PTS: 8007481246593 | PTSInterval: 13918215000”

Issue 3:

Even with AcquireNextFrame with wait time 5 milliseconds, some time it take more than a second to come out of the function AcquireNextFrame

Any help is this area will be helpful.