obsproject / obsproject/obs-studio

[Windows 10] Poor frame pacing with WGC window capture

Open
#13,893 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
76.4k
Forks
10.2k
Avg merge
4d 23h
Merged PRs (30d)
12

Description

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
  1. 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)
  2. Wait for it to start stuttering
  3. ...
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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked OBS log and the WGC window-capture path, then reproduce the issue on Windows 10 with a 60 FPS source and a high-refresh or adaptive-sync display. Compare the captured output's pacing with the source under the reported conditions; done means consistent frame pacing without the reported duplicate and dropped frames.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
desktop, operating-systems, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.