英文:
Desktop Duplication - Limiting the Framerate
问题
使用Windows桌面复制API,我想将监视器的捕获限制在不超过60fps。我知道AcquireNextFrame()
有一个'wait'参数,所以也许可以用它来限制帧率,尽管我不确定如何操作。我还注意到,至少当我连接了额外的监视器时,该监视器的帧率会上升到主监视器的帧率。例如,我的外部60Hz监视器据称从桌面复制中获取200fps。
我没有看到这个网站上有其他问题提供了如何在这个API上实现FPS限制的答案,所以任何帮助将不胜感激。
我尝试将等待参数指定为16毫秒,以及在AcquireNextFrame之间休眠。后者的问题在于休眠会导致它错过帧更新。
英文:
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.
答案1
得分: 1
API不提供帧速率限制。您可以仅减慢轮询速度并在使用AcquireNextFrame
之前进行休眠,以在实际请求之前在后台收集桌面更新。
后者的问题在于休眠会导致丢失帧更新。
您可以请求更高精度的计时器服务(参见timeBeginPeriod
及相关)和/或使用实时工作队列API(Microsoft Media Foundation API建立在其上),以获取更精细的执行时间片,以请求下一帧。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论