Improve video playback performance including YouTube (ytfzf)

I said almost :wink: :smile:

As stated, I’m perfectly happy with mpv, which has all the functions and controls I need right now and appeals to me with its minimalist UI. For me it’s just unnecessary hassle to install smplayer, as I’d have to

  1. change the mime types, since upon installation when I tested it, it did not actually become the default (mpv was still the mime default)
  2. find a theme that I can tolerate, while there probably isn’t a comparable one to the mpv default look, where all of the UI autohides (and if there is that’s yet more time spent on finding it).
  3. deal with the settings to make sure everything works as desired, which for mpv is already the case now

And of course it’s yet more packages installed in the template, while the benefit, for now, seems to be exactly zero…so excuse me, but I’ll stick with mpv only.

If smplayer is Qt based like VLC, then you can tell it to use the native GTK theme.

Add these as a global environment variable, or set the variable before the program runs.

export QT_QPA_PLATFORMTHEME="gtk2"
export QT_STYLE_OVERRIDE="gtk2"

Source: Uniform look for Qt and GTK applications - ArchWiki

2 Likes

Just a side note about smplayer:

Testing on a very very old 1-core laptop running GNU/Linux (not Qubes OS) , I had noticed that smplayer doesn’t give the same performance as “naked” mpv or mplayer. So, it makes me think that smplayer’s UI may be adding certain burden to the CPU.

I have not tested this in Qubes OS because I am happy with mpv itself. Just wanted to share this, in case someone is interested in making any actual detailed benchmarks.

1 Like

Thanks for information, burt I am using KDE-based template and smplayer has no appearance issues for me, it looks similar to screenshots I provided above.

I personally try to avoid GTK and Gnome software as I consider it to be not great for advanced users.

I also had numerous trials and erros in order to provide smooth playback of videos, only to get the best results with VLC under whonix-ws.

But, the true answer came later: in order to get best performance all I needed was to buy new, stock, recent generation machine (not older than 3 years). SInce then no problem with any distro, Windows, qube, HVM, standalone, player…

1 Like

Sure, but as someone running Qubes on a pretty new machine where videos will run under any template with a variety of players, it’s still nice to reduce CPU load from 50% in a VM with 8 cores to 10% when watching a full HD video, especially on laptops (battery life, fan noise, heat), but also on desktop computers I imagine since it means you have more resources for other computationally intensive stuff you may want to do while watching your vids and electricity is not as cheap as it used to be anyway (lower load should also reduce wear on some HW components).

@everyone:

I created a patched version of ytfzf that fixes the two issues I mention in my OP:
files.log (34.1 KB)

Note that this is a zip archive (I uploaded as *.log because of the upload restrictions…if that’s not ok then mods please advise how to handle it otherwise); the archive includes an updated script (from the one in the Bonus section of my OP) and ytfzf executable; copy the file to your dvm template’s home folder and run (type y if it asks you to replace existing files):

unzip files.log
rm files.log
chmod +x update-yt-dlp-and-ytfzf.sh ytfzf_fixed_copy
./update-yt-dlp-and-ytfzf.sh

The updated script will, after trying to update yt-dlp and ytfzf as the original script in the OP does, check the ytfzf version; if the version hasn’t changed from the current 2.6.1 then it will replace the existing executable with the patched one; the patched executable fixes the annoying misalignment bug and adds the feature to hide the info panel completely; for the latter to work you need to put preview_window_width=0% into ~/.config/ytfzf/conf.sh, which will enable the feature so that more of the screen real estate is used for the more useful and much denser info that is the title list.

1 Like

These tools are great.

I have just created an MIT License repo fro the community with the SaltStack files to configure this automatically and a setp-by-setp of how to use it.

Please update in the initial message.

My motivation is help those whostruggle with SaltStack, and have more Salt code and less visual/bash step-by-steps in the forum.

1 Like

I don’t have time to test your solution right now, but if you’ve tested it and it works, feel free to edit the OP to include it (it’s a wiki post, so any forum member can edit it). Thank you for your contribution!

1 Like

Please rewrite your bash scripts following shellcheck guidance.

Currently they have major issues, like not-quoting variables, that can lead to huge problems in case paths have spaces, start with - and etc.

Bash is a dangerous animal.

2 Likes

Thank you @balko, this is done now.

1 Like

Script prints error for me:
No internet connection or cannot reach github.com!
despite taking the correct steps.

It also ask to download jq.

Unfortunately, I get much better performance via browser.
And still can’t play smoothly 4k youtube videos in fullscreen mode.

Thank for the guide.

Can you print the output of which nc for me, please?

It’s possible that nc is not installed in the template of the VM you’re running the script in…otherwise there may actually be a connection problem. You could try installing nc in the template or just remove the check in the script (i.e. delete all lines beginning with echo, else, if and fi).

1 Like

I doubt there is any user PC that will be able to play even 1080p video in Qubes OS smoothly.

You can try to watch this video in 1080p or 1440p to find out that it is played a bit jumpy during panning.

2 Likes

I have reasonably modern Intel CPU, and even 360p, even in a small frame inside the forum webpage is jumpy, e.g. very noticeable after 0m20s.
360p is not smooth!

I think it is related to how Xen is poorly rending media using Xorg or something.

That was it.

Indeed. Same at my end.

I was under impression that some people like yourself actually got it working and I just need to tweak things out: What is the best way to play blu-ray / BDMV movies? - #13 by balko

Some points to note:

  • Top Gun’s dogfight scene with the same frame size as yours above plays smoothly even with 4k, especially at 0:15 and 1:06
  • There’s definitely something with how Qubes/Xen renders video. I see significant difference between non-Qubes and Qubes versions of these tests:

1 Like

I doubt there is any user PC that will be able to play even 1080p video in Qubes OS smoothly.

Why would you doubt a fact which we already discussed?

So, even 360p lags for you during panning part (from 0m20s)?

Well, I made it tolerable to watch. In fact, I do not notice this issue much. Only when I see the same content played on different OS, the smoothness there is noticeable.

And having modern Intel 11/12 Gen+ CPU helps any way. Not perfect, but watchable.

Can you elaborate, what is the so called “fact”? That youtube 1080p (even 360p) is jumpy even on modern Intel CPUs? Because there are people who do not notice the problem and do not believe the reality. Luckily, @Zeno does see the lack of smoothness themself.

Yes.

1 Like

I downloaded the panning city youtube video in different resolutions and tried to play it on modern CPU with a lot of VCPUs, 16GiB+ RAM in mpv/smplayer/mplayer with different options.

And in all cases the video output lags during panning and other moments.

That’s why I think the issue is in Xen+Xorg interaction. I believe CPU is able to decode the stream on fly for sure.

=> So, the problem probably lies in Xen/Xorg/QubesOS not good video output architecture.

Yes, same here.
I’ve tried to add 6 CPUs and 10 GB of RAM – same result.

Could be related to video specifics/codecs too, perhaps.

I didn’t notice many differences in two blu-rays(~50 GB each) in terms of smoothness on lower frame(~720p) sizes compare to other OS.