[Windows 10] Poor frame pacing with WGC window capture
Operating System Info
Windows 10
Other OS
No response
OBS Studio Version
32.2.2
OBS Studio Version (Other)
No response
OBS Studio Log URL
https://obsproject.com/logs/ZQNfTwhFQPAlz90C
OBS Studio Crash Log URL
No response
Expected Behavior
I expect consistent frame pacing from window capture sources using the Windows.Graphics.Capture API.
Current Behavior
Switches between being fine and dropping & duplicating frames. Recording from OBS shows the poor frame pacing (3 good frames, 1 duplicate frame).
https://github.com/user-attachments/assets/88165286-29d4-48bf-a2ea-66035d314a03
Steps to Reproduce
- Capture a window producing 60fps content using WGC on a 360hz display (or any other refresh rate, I think adaptive sync is what truly matters here)
- Wait for it to start stuttering
- ...
Anything else we should know?
I am using window capture on my own program, which does low latency capture card presentation. It uses MediaFoundation + DirectComposition to shovel frames from the capture card directly into a DXGI media swapchain in NV12 format. Maximum frame latency on the swapchain is set to 1, and swapchain present duration is set to match the expected frame rate from the capture card. Presentation uses DXGI_PRESENT_ALLOW_TEARING with a sync interval of 0. And on a display with adaptive sync, the display refresh rate and timing will adjust to the same timing as the capture card (verified with DXGI_FRAME_STATISTICS_MEDIA's SyncQPCTime on the media swapchain. the timing between the capture card sample and display vsync minimizes automatically).
Anyways, when displayed on any monitor at any refresh rate with and without adaptive sync the result is smooth as butter.
Except OBS' window capture of it.
My current hypothesis is that OBS is just taking the latest frame received through WGC at the time of its own capture vsync, which mismatches as WGC produces frames at the monitor's (or maximum monitor's?) refresh rate, 360hz in my case. There is one updated frame from my program every 6 WGC frames. However, if OBS ends up syncing where it jitters between every 5 WGC frames and every 6/7 WGC frames, the result will have poor frame pacing.
In the gameplay footage I uploaded (where it displays 3 good frames, 1 duplicate) this could manifest if the capture pacing from OBS were slightly misaligned to capture 3 60fps frames every 23 WGC frames (at 360hz), but other misalignments are possible. What here matters is that OBS is not capturing at a smooth rate, because both of my capture cards and therefore my program are producing frames at a smooth rate and I cannot see any frame drops at all and I am absolutely cracked at visually detecting frame drops.
If needed, I can loopback record my computer with OBS through one capture card at 60fps and show my program displaying a second capture card, if needed. It isn't that much CBT to set up if it'll help diagnose this issue.
I can also provide private access to my GitHub repository for my program, tiger. Unfortunately I am not ready to open source it yet.
I have tested OBS 32, 31, 30, and 29. All eventually display the same issue.
Also question for OBS devs. How does OBS pace its own recording internally? I really hope it's based on either display vsync or preferably audio clock/timing, when available.
Source: obsproject/obs-studio