Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux: Improve Rendering Performance #26

Open
trin94 opened this issue Jul 30, 2022 · 7 comments
Open

Linux: Improve Rendering Performance #26

trin94 opened this issue Jul 30, 2022 · 7 comments

Comments

@trin94
Copy link
Member

trin94 commented Jul 30, 2022

The rendering performance issue is caused by us rendering into the same framebuffer as Qt renders its UI. When playing 24 fps videos, this reduces the framerate being rendered to 24 fps. And therefore menu animations and GUI interactions result in a bad user experience.

We tried playing around with mpv not blocking for the next frame but that leads to frame drops mpvqc/mpvQC-dev#61.

We need to find a different way to improve performance.

Ideas:

  • Use two framebuffers (1x onscreen for Qt, 1x offscreen for mpv)
@trin94
Copy link
Member Author

trin94 commented Dec 15, 2022

Check #27 if this issue is necessary.

@trin94
Copy link
Member Author

trin94 commented Dec 22, 2022

@trin94 trin94 transferred this issue from another repository Jan 11, 2023
@trin94 trin94 added the Python label Jan 11, 2023
@trin94 trin94 added this to the 0.9.0 milestone Jan 11, 2023
@trin94
Copy link
Member Author

trin94 commented Jan 15, 2023

Maybe using something like this helps: https://doc-snapshots.qt.io/qt6-6.5/qtquick-itemvariablerefreshrate-example.html

@trin94
Copy link
Member Author

trin94 commented Sep 18, 2023

cN3rd pushed a commit to cN3rd/mpvQC that referenced this issue Feb 24, 2024
* Implement key event handler
* Implement key event listener
* Implement e key press
* Add command generator stub
* Call command generator
* Add more special mappings
* Implement command generator
* Refactor minor things
* Refactor minor things
* Restructure key event processing
* Execute custom player commands
* Make ignore keys more explicit
* Make return key edit comments
@barribarrier
Copy link

barribarrier commented Mar 12, 2024

Hi @trin94

I've tested this with 24fps and 5fps videos but the UI seems unaffected? I don't notice any lag or slowdowns when interacting with the UI.

Tested on linux.

Edit: nvm you're right

@trin94 trin94 moved this from 🔖 Ready to 🏗 In progress in mpvQC Mar 25, 2024
@trin94
Copy link
Member Author

trin94 commented Apr 26, 2024

This rendering issue only applies for Linux on both x11 and Wayland. On Windows, we now (f6e7cde) do hWnd embedding instead of libmpv rendering. Unless someone has a clever idea, I don't think we can do much about it until there's a Wayland protocol including common compositor support for this.

@trin94 trin94 added the Linux label Nov 5, 2024
@trin94
Copy link
Member Author

trin94 commented Nov 9, 2024

For Linux users, a temporary fix is to adjust the video-timing-offset setting in mpv (OptionsEdit mpv.conf...):

By default, video-timing-offset is set to 0.050. On a 120 Hz monitor, we want the video to match the refresh rate, which is 120 frames per second (fps). This means each frame should appear every 1000 / 120 ≈ 8.3 ms. By lowering the video-timing-offset (e.g., to 0.008), mpvQC will reduce the maximum frame delay from 50 ms (default) to about 8 ms, keeping video and monitor refresh rates in sync.

Here are suggested values for different frame rates:

Target Frame Rate Frame Time Calculation Recommended Offset
60 fps 1000 ms / 60 ≈ 16.6 ms video-timing-offset=0.016
120 fps 1000 ms / 120 ≈ 8.3 ms video-timing-offset=0.008
240 fps 1000 ms / 240 ≈ 4.2 ms video-timing-offset=0.004

Note: This requires powerful hardware, and even with adjustments, you might still see frame drops or audio sync issues. You can check for any audio-video drift in mpvQC by pressing i to display video stats. If you experience frame drops, consider lowering the target frame rate.

@trin94 trin94 pinned this issue Nov 9, 2024
@trin94 trin94 changed the title Improve Rendering Performance Linux: Improve Rendering Performance Nov 9, 2024
@trin94 trin94 removed this from the 0.9.0 milestone Nov 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 📋 Backlog
Development

No branches or pull requests

2 participants