mpv-player / mpv

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

Render video ONLY if player is in focus #10829

Closed ice051128 closed 1 year ago

ice051128 commented 1 year ago

Why is this not a feature in mpv? Most browsers do it natively to save power. If you are streaming a youtube video in mpv but the player is not in focus, it should only decode audio.

CounterPillow commented 1 year ago

Pretty sure it does this under wayland already, if by "in focus" you mean "not hidden".

Why is this not a feature in mpv?

because you didn't implement it.

christoph-heinrich commented 1 year ago

I'm pretty sure it continues decoding the video, but it doesn't get rendered.

natural-harmonia-gropius commented 1 year ago
[background]
profile-cond=not focused and get("current-tracks/video/albumart") == false
profile-restore=copy-equal
vid=0
Dudemanguy commented 1 year ago

In wayland, it only renders if the mpv window isn't hidden as mentioned above. x11 actually does this too as well although most WMs in practice will only send _NET_WM_STATE_HIDDEN when the window is minimized.

dexeonify commented 1 year ago
[background]
profile-cond=not focused and get("current-tracks/video/albumart") == false
profile-restore=copy-equal
vid=0

That's probably not what the OP wants, and it's not the behaviour of browsers either. "Focus" is the wrong word here. Maybe they are looking for the term "minimize" or window occlusion.

Traneptora commented 1 year ago

Refusing to decode video when the window isn't in focus doesn't make sense, as you create latency when you re-focus on the window.

However, mpv doesn't render the video if it wouldn't make it to the screen. At least on wayland, and I believe on x11 as well if the player is minimized.

ice051128 commented 1 year ago

profile-cond=not focused and get("current-tracks/video/albumart") == false profile-restore=copy-equal vid=0

This code has introduced significant stuttering in audio when mpv is not in focus, why is that?