mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
28.78k stars 2.93k forks source link

Multi-monitor with different refresh rates causes dropped frames. #9686

Open kaitoux1412 opened 2 years ago

kaitoux1412 commented 2 years ago

mpv 0.34.1 Arch Arch Official repositories Kwin Nvidia 495.46

Reproduction steps

While using multiple monitors with different refresh rates, use display-resample, starting the video and going into or out of fullscreen repeats the issue.

Expected behavior

mpv will pick up the refresh rate of the monitor where the window is and have no significant amount of dropped, mistimed and delayed frames.

Actual behavior

mpv picks the wrong refresh rate, and shows a lot of mistimed/delayed and dropped frames during the first few seconds, it gets stable after some time but the estimated refresh rate continues to show the refresh rate of the other monitor. The issue happens every time in the 144Hz monitor, but i only saw the issue in the 60Hz monitor once while testing on KDE. I was also able to replicate this issue on GNOME Wayland and Xorg, on Wayland the 60Hz monitor would have the issue more often. This is similar or possibly identical to #9339 but on Linux.

Log file

output.txt

Sample files

Anything that I've tested caused the issue.

Dudemanguy commented 2 years ago

There's multiple things going on here. First of all, on Wayland this should actually work. So it could be a compositor bug. On Xorg, the situation is more complicated. I think the latest xorg actually fixed a lot of multi-monitor issues so maybe this can work now (haven't checked myself though). Another wildcard is that you are using nvidia which does who knows what.

kaitoux1412 commented 2 years ago

That's the reason why I tested Wayland, I expected that I would have completely different issues when using it because Nvidia, so I was really surprised to see what seems to be the same bug as on Xorg, with some other bugs as bonus like flickering, black screens and more while testing. On Wayland the estimated refresh rate did change between the 60Hz and 144Hz randomly multiple times while I moved the mouse. Due to what seems to be the same bug being present on both Xorg and Wayland, I think it might be something weirdness with the Nvidia driver. Is there some way I could try to diagnose where the issue is?

kaitoux1412 commented 2 years ago

Just tried to replicate the bug in the same system but with the monitor plugged into the motherboard(Intel iGPU), and it played perfectly, no issues at all. So this should be a confirmation that it is Nvidia only.

edit:Also playing with one monitor in the GPU and one in the motherboard solves the issue with mpv picking the refresh rate of the other monitor, but the performance is abysmal(the same as it is without the second monitor), estimated refresh rate and Vsync Jitter are all but stable, and it gets a lot worse if I set scaling to something heavier, with only display-resample the estimated refresh rate seems to stay between 140 and 144(jitter between 0.010 and 0.050), with scale=ewa_lanczossharp and cscale=ewa_lanczos added it drops to 120 after sometime and stays mostly between 140 and 130(jitter between 0.020 and 0.600). The number of mistimed and delayed frames also increases pretty fast, on an 1m30s long video it goes up to 30 mistimed and 20 delayed without scaling and over 300 mistimed and 600 delayed with the mentioned scaling.

Dudemanguy commented 2 years ago

On xorg at least, NVIDIA has a __GL_SYNC_DISPLAY_DEVICE environment variable which should let you choose which device to sync too.

Dragoonstorm1 commented 6 months ago

This is still not resolved as of today. I have a 144hz primary monitor, and MPV jitters hard (oddly never says dropped frames, only Mistimed & Delayed, but it's bad) on my 60hz bigger monitor. If i set the 60hz screen as the primary monitor, then MPV drops frames sooooo hard (yes literally drops frames) when playback is on the 144hz screen.

Saddeningly, moving the playing window between monitors shows clearly which display it is on (in debug shift+I) as well as the monitor's SPECIFIED Refresh Rate accurately! But for unknown reasons it is failing hard at the ESTIMATED Refresh Rate, and creating problems based on that.

Yes, i have video-sync=display-resample Yes, video playback actually works perfectly fine if i comment out that line.