https://bugs.kde.org/show_bug.cgi?id=524129

            Bug ID: 524129
           Summary: PipeWire screencasting has uneven frame timing with
                    120Hz display / 60 FPS capture combo
    Classification: Plasma
           Product: kwin
      Version First 6.7.4
       Reported In:
          Platform: Arch Linux
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: screencasting
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

Created attachment 195048
  --> https://bugs.kde.org/attachment.cgi?id=195048&action=edit
hack patch

DESCRIPTION
When I record my 120Hz display with OBS at 60 FPS using PipeWire, the capture
doesn't appear to sample frames evenly; instead it looks stuttery.

I did some digging, and I think it could be caused by the fact that
https://invent.kde.org/plasma/kwin/-/blob/6c523e20d1280b397d2437246ee86649fd8b0bbb/src/plugins/screencast/screencaststream.cpp#L529
uses whole milliseconds (where 120Hz is ~8.333 ms but it ends up rounding to
8?) which might not be precise enough. Additionally, the deadline appears to be
measured from when the previous frame finished being sent rather than a fixed
schedule and thus the delay might be adding up constantly.

I hacked it so that nanoseconds are used now and a fixed one-interval deadline
is applied each time instead of restarting it and capture got a lot better on
my setup. I attached that hack to this ticket.

STEPS TO REPRODUCE
1. Set your display to 120Hz
2. Run a vsynced client, ideally one that shows a different color/image for
odd/even frames (I use this: https://gitlab.com/fililip/vulkan-vsync-tester)
and make sure it's stable on the actual display without any frame drops caused
by something else
3. Capture the screen at 60 FPS with OBS

OBSERVED RESULT
There are mistimed frames (colors go crazy) when playing back the recording
using mpv and VRR (or when exporting all frames to image files), which means
the capture interval somehow always shifts.

EXPECTED RESULT
All frames are the same in the recording when played back since the app is 120
FPS and the recording is 60 FPS, so either the odd or even field makes up each
captured image.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 6.7.4
KDE Frameworks Version: 6.28.0
Qt Version: 6.11.1
Kernel Version: 7.1.7-arch1-1 (64-bit)
Graphics Platform: Wayland
Processors: 16 × AMD Ryzen 7 5800X 8-Core Processor
Memory: 64 GiB of RAM (62.7 GiB usable)
Graphics Processor: AMD Radeon RX 9070

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to