tl;dr: add the --avcodec-hw=vaapi
option on the command line or to the Exec
option in the .desktop file.
It’s stupid, I know, but it’s been bothering me for a while now. Especially when I want to watch conference talks that are available in the AV1 video format (e.g. FOSDEM) the video always seems to hang (show an old frame indefinitely), have broken decoding (shows alternating weirdly colored blocks), de-sync from audio or just stay black. This is happening on both Intel and AMD integrated graphics for years now, and I somehow decided that VDPAU must be the culprit. I also definitely know that VA-API works on my machines, because I’ve tested it … so that can’t be the problem. 😇
VLC (generally) supports both VA-API (mainly for Intel and AMD hardware) and VDPAU (for Nvidia) libraries for hardware accelerated video decoding, but on my Ubuntu desktop machines prefers VDPAU on any hardware for some reason. The settings don’t even show support for anything else: “Simple Preferences” -> “Input/Codecs” tab -> “Hardware-accelerated decoding” only shows “Automatic”, “VDPAU video decoder” and “Disable” options. 😵💫 The only “variant” that correctly uses VA-API automatically on my machines is the VLC Flatpak. I checked which backend was used via the “Modules Tree” tab in the “Tools” -> “Messages” dialog. It will show “vdpau”-something in the “video output” subtree (or not).
The Solution
So I dug through weird forums and tried different suggested options, of those many weren’t even supported until I found the right incantation: --avcodec-hw=vaapi
.
Fixing the .desktop file
To make your desktop always call VLC with the right options we have to edit VLC’s so-called .desktop file. Mine was located in /usr/share/applications/vlc.desktop.
The relevant line looked like this: Exec=/usr/bin/vlc --started-from-file %U
.
Copy the vlc.desktop file to either the $HOME/.local/share/applications/ directory if you want to change the behavior only for you. Alternatively if you have root privileges you can update vlc.desktop for all users of that machine by copying it to /usr/local/share/applications/ . NOTE: you may need to create those directories first.
Then edit the Exec
= line to look like this: Exec=/usr/bin/vlc --avcodec-hw=vaapi --started-from-file %U
Or if you want to just copy the relevant commands:
# create the directory for personal .desktop files
mkdir -p $HOME/.local/share/applications/
# copy the original vlc.desktop to this directory
cp /usr/share/applications/vlc.desktop $HOME/.local/share/applications/
# edit the copied vlc.desktop by changing its "Exec" option to include the relevant VLC option
desktop-file-edit --set-key=Exec --set-value="/usr/bin/vlc --avcodec-hw=vaapi --started-from-file %U" $HOME/.local/share/applications/vlc.desktop
Enjoy!