Video playback using mpv

This guide will show you how to install the mpv player and use it with maximum performance (in own tests I saw video performance improvements of up to 600% !). It will assume that you are using debian-12 as a template (other templates should also work, however) and that you play videos in DVMs; I recommend looking into this solution for caching disposables to increase startup time. I also recommend looking into one of these solutions to have files, including video files, always start in DVMs if you "open" them in your file manager.

Since not everyone is interested in YouTube and the YouTube solution presented here is admittedly a bit unpolished due to bugs in mpv and lacking features in ytfzf as well as insufficiently up-to-date packages in debian stable, I will present separately the necessary steps to set up mpv for local video playback only and mpv with ytfzf, which basically lets you search for videos on YouTube and then stream them without having to actually launch a browser and visit the bloated YT page.

In your base template

In your debian-12 template run:

For (additional) YouTube functionality run instead:

sudo apt install mpv fzf make
sudo apt remove yt-dlp
yt-dlp is probably going to get installed together with mpv, but if you're using Debian it will be a very old version that won't work, so we'll have to install a newer one by ourselves (see further down).

In both cases (YouTube or not) we proceed to set mpv to always run with additional options, which will drastically improve playback performance:

sudo vi /usr/share/applications/mpv.desktop
Here edit the line beginning with Exec=, forming it into the following (press 'i' to edit):
Exec=mpv --player-operation-mode=pseudo-gui --vo=x11 --profile=sw-fast -- %U
Save your changes (press Esc and enter ':x' + press Enter) and shut down the template. This completes the guide for those who don't care about YouTube. Enjoy much improved video playback performance!

In your DVM template (YouTube)

First download the latest version of yt-dlp from here in some Internet-connected DVM or AppVM (choose the yt-dlp_linux file and verify the checksum after downloading just in case); then copy this file to your debian-12-dvm using qvm-copy.

In your debian-12-dvm disposable template run (we'll assume that you copied from myAppVm):

chmod +x QubesIncoming/myAppVm/yt-dlp_linux
sudo mv QubesIncoming/myAppVm/yt-dlp_linux /usr/local/bin/yt-dlp
rmdir -p QubesIncoming/myAppVm/
vi .bashrc
In bashrc add the following line just in case:
alias ytfzf='ytfzf --url-handler-opts="--vo=x11 --profile=sw-fast"'
Save and exit and then create a new file:
vi install-update-yt-dlp-and-ytfzf.sh
Into this file copy the following (copy this code into that VM's clipboard and then into Vim, e.g. by using your terminal's paste functionality, e.g. Edit - Paste in the Menu):
#!/bin/bash

echo -e "GET http://github.com HTTP/1.0\n\n" | nc github.com 80 > /dev/null 2>&1

if [ $? -eq 0 ]; then 
    sudo yt-dlp -U &&
    cd Downloads
    rm -rf ytfzf
    git clone https://github.com/pystardust/ytfzf &&
    cd ytfzf &&
    sudo make install doc
else
    echo "No internet connection or cannot reach github.com!"
fi
This will install the latest version of ytfzf as well as update yt-dlp. You should periodically run this script to update both yt-dlp and ytfzf. Run in the dvm-template for persistence or in the DVM itself on every start of that DVM.

Now shut down your dvm-template and don't forget to set its netvm to None if that was the prior setting (e.g. if you only use web-connected named DVMs based on it).

Congratulations! You have completed the guide and can now watch both local videos as well as YouTube videos with probably the best possible performance in QubesOS despite lacking GPU acceleration!

Addendum:

You can use ytfzf simply like this: ytfzf videos I like to watch (use a maximized terminal). Then select one of the titles with the up/down arrow keys and press Enter to play it. You can also press Alt+D to download the video instead (and then play it with mpv video_file_name.webm); see the man page (man ytfzf) for more options, but note that thumbnails (option -t) are buggy and need additional packages to be installed to be displayed in the terminal itself.