桌面复制 – 限制帧率

huangapple go评论74阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2023年2月27日 03:16:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/75574430.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定