ben-grande / qusal

Salt Formulas for Qubes OS.
14 stars 6 forks source link

Improve MPV performances #19

Closed peakunshift closed 4 months ago

peakunshift commented 4 months ago

Commitment

I confirm that I have read the following resources:

Current problem (if any)

The current installation of MPV in disp-media is not optimized. Playing video uses too many resources because it's not configured correctly.

Proposed solution

As explained in this post from QubesOS Forum, creating /etc/mpv/mpv.conf and setting two properties drastically improves performances. That's all needed. There are probably other settings that can help (de-interlacing?), I still have some flickering sometimes but it's way better than the current state. I also have sound delay. Setting a -300ms delay fixes it, but I don't really understand where it comes from. Finally, should we increase max memory and vcpu settings to have more power? Can it help?

The value to a user, and who that user might be

Better performances when playing video with MPV in disp-media.

ben-grande commented 4 months ago

I agree that MPV needs a better performance and the reports and the MPV Debian manpage does convince me to do it. However, Salt is not meant to be scriptable and the problem is that MPV does not have a configuration directory (it does have, but for different configuration file types, different purpose), in other words, I have to be careful to not overwrite user configuration in /etc/mpv/mpv.conf or $XDG_CONFIG_HOME/mpv/mpv.conf.

MPV can load Lua scripts and maybe, just maybe, this would facilitate the proccess.

peakunshift commented 4 months ago

Ok, thanks for your quick answer!

Maybe add this info in the README to manually do it can be an easy first step? It only needs to be done once during installation in the template so it's probably the simplest and is enough.

ben-grande commented 4 months ago

Maybe add this info in the README to manually do it can be an easy first step? It only needs to be done once during installation in the template so it's probably the simplest and is enough.

For now, I will add to the README, but I do believe it should be the default as it makes the experience at least usable, so I will keep this open until I come up with a solution, or maybe you, if you want to contribute, depending on your knowledge of Salt.

peakunshift commented 4 months ago

I'm just beginning to learn Salt so probably not the best task for me.

Finally, should we increase max memory and vcpu settings to have more power? Can it help?

Also, what about this? Can it be necessary to give more power to the VM to handle the video decoding?

ben-grande commented 4 months ago

I'm just beginning to learn Salt so probably not the best task for me.

Don't mind Salt know, just test the load and available memory with changes to maxmem and vcpus.

Also see this comment about video output with enough memory and CPU.

Also, what about this? Can it be necessary to give more power to the VM to handle the video decoding?

I haven't tested, but you can try increasing the qubes maxmem and vcpus preference. The qube needs to be rebooted for changes to take affect.

Watch the memory usage:

free -h -s 5

Watch the CPU load:

while true; do uptime; sleep 5; done

Watch both:

while true; do
  uptime
  free -h
  sleep 5
done

You might need other tools for better analysis, but you can find them via search engines.

ben-grande commented 4 months ago

I also have sound delay. Setting a -300ms delay fixes it, but I don't really understand where it comes from.

Qubes Audio implementation, follow https://github.com/QubesOS/qubes-issues/issues/8955.

ben-grande commented 4 months ago

mpv and the Debian package of mpv does not ship the configuration to /etc/mpv/mpv.conf, this is good news, we can write to it.