Chromium-based Browser on Linux: HEVC / H.265 Hardware Acceleration Setup
Are you on Linux, using a Chromium-based browser? And you somehow find out certain video doesn't play on your browser, because it's HEVC / H.265 ? Windows and Mac users look away now, you're stuck lol
I'm writing this guide to show you how to enable full hardware video decoding for HEVC (including 10-bit) in the Brave Browser (which is a Chromium-based browser) using VA-API and Vulkan. This should also work with SwagCollections. I can't confirm if it will work for 'all' chromium-based browser, but it SHOULD - read through this and you should know what to change.
Note: If you're using Firefox, on Linux, it should just work as long as you have all the graphic drivers installed properly.
Pre-Requisite
- A modern Linux distribution
In this example, I'm using Debian, but any should work - just be mindful of the commands you're executing (e.g. if it's a distribution such as Fedora, rpm would be your package manager, so the command should be 'dnf' instead of 'apt') - Compatible Hardware:
Intel CPU? Gen7+ please. AMD CPU? well any AMD CPU with integrated GPU should work.
Dedicated GPUs by AMD, Intel, or Nvidia should also work, as long as it supports HEVC decoding (I think for Nvidia, that should at least be GTX 10xx series with NVENC features - go do your research for NVENC if you're using Nvidia) - Correct GPU Drivers:
The necessary MESA or proprietary drivers (unfortunately) for that graphics must be installed and up-to-date.
Also note, some distribution already have these pre-installed, but just run the commands to install the drivers below anyway, as it doesn't hurt - if it's already installed, your package manager would tell you.
Step 1: Install Browser (If not already installed)
Note: Don't install apps based on Snap, AppImage or Flatpak - use the official source that supports your package manager. It's not that it won't work, but these other package manager extensions usually require certain system permission to be given before it can work. Again, in this example, I'm installing the Brave browser, in Debian.
So.. first, install curl (if you don't already have it):
sudo apt install curl
Then, add the Brave repository to your package manager sources - for Debian it would be something like this (you can search the web or check the browser's website for official source):
echo "deb [signed-by=/usr/share/keyrings/brave-browser-archive-keyring.gpg arch=amd64] https://brave-browser-apt-release.s3.brave.com/ stable main" | sudo tee /etc/apt/sources.list.d/brave-browser-release.list
And don't forget its GPG key.. which is also why you need curl:
sudo curl -fsSLo /usr/share/keyrings/brave-browser-archive-keyring.gpg https://brave-browser-apt-release.s3.brave.com/brave-browser-archive-keyring.gpg
Update the package list and install Brave
sudo apt update
sudo apt install brave-browser
Note: While updating your repository, be careful not to add duplicate sources or you might get some errors. If you did, all you need to do is to remove or hash-out (#) one of the sources (if you're new to it and not sure on how to cancel out duplicate sources, the web is your friend - use it)
Step 2: Install VA-API and Vulkan Drivers
You need to install the drivers or libraries that allow the browser to reach to your GPU's decoding hardware.
Install these VA-API and Vulkan drivers: mesa-vulkan-drivers | mesa-va-drivers | libva-drm2 | libva-x11-2
So for Debian, it would be something like this:
sudo apt install libva-drm2 libva-x11-2 mesa-vulkan-drivers mesa-va-drivers
Note for Intel CPU Users: If you have 8th Gen Intel or newer with integrated graphics, you might also need the specific Intel driver called intel-media-va-driver
Step 3: Let's do a Temporary Test - Launch the browser with HEVC and Vulkan Flags enabled
This is crucial - Before making permanent changes, verify the flags work by launching Brave (or your other chromium-based browser) from the terminal, using some specific flags.
Close Brave completely, and re-launch it from the Terminal with these command & flags:
brave-browser-stable --enable-features=DefaultANGLEVulkan,VaapiIgnoreDriverChecks,Vulkan,VulkanFromANGLE
Once Brave is open, navigate to this address: brave://gpu
Note: Again that's for Brave - if you're using any other browser, the address might be different. For example, in Google Chrome, the address would be chrome://gpu
Verify the following features show as Enabled or Hardware accelerated:Vulkan
: EnabledVideo Decode
: Hardware accelerated
Important Note: While on that specific page (brave://gpu)...........
→ If the browser's window starts flashing a few times and stops, but you do get the above result (hardware accelerated), don't worry about it, move on below.
→ If the browser's window starts flashing numerous times and just never stop, and you can't click on anything other than closing it completely - then you might have a problem <– This means the browser is not able to communicate to the graphics decoding hardware - check Step 2 (graphics drivers) & check Pre-requisite (that may involve proprietary drivers)
→ If the browser's window doesn't flash at all, and the page shows 'hardware accelerated' as above - you're good to move on.
→ If the page results in 'using software' instead of 'hardware accelerated' for decoding, well, the good news is it's likely not the driver. But the bad news is the browser never actually launch with those flags. You're going to need a bit of tinkering and web-searching for this to find out why.
Moving on...
Test playing a HEVC Video:
Try playing any HEVC video within the browser.
My favourite is one particular web page - go to this address - it's got all kinds of HEVC video samples embedded:
https://lf-tk-sg.ibytedtos.com/obj/tcs-client-sg/resources/video_demo_hevc.html
If successful, congratulations! Well you're just one step away now from making that flags permanent. Which is on the last step, Step 4.
Step 4: Make the Flags Permanent
Step 3 was a temporary method, which only works for that session. Obviously we'd want to the browser to be launch with those flags permanently, every time it launches (unless you really don't).
So, you need to find the browser's ".desktop" file.
Because we're going to edit some lines there to make sure this is permanent.
In Debian, it is most likely in this location (based on current Brave example):
/usr/share/applications/brave-browser.desktop
If you can't find it, use some creativity - Linux is superb when it comes to searching.
Search for ".desktop" file with the word "brave" - and you should be able to find it!
And once you have, use your favourite text-editor like Kate, nano, vim etc to open it.
I personally prefer Kate, and I have Kate installed, so what I would do is:
kate /usr/share/applications/brave-browser.desktop
In the past, before I was even introduce to Kate, my favourite text-editor was always nano.
One of the reason why I don't use nano anymore is because we have to specify 'who we are' before opening a file to be able to make changes.
Obviously, these changes require sudo.
So doing "nano brave-browser.desktop" would open it, but then I can't save the changes.
And I have to remember to put sudo every single time before opening it.
But if you don't have Kate and prefer using nano anyway, it should be something like this:
sudo nano /usr/share/applications/brave-browser.desktop
Anyway - once you have that file open - there are two lines you're looking for to edit.
Both looks very similar but for different purposes, with slightly different default flags.
You can probably guess what these flags are for, when looking at the below.
So with me sticking to this Brave browser as an example, the two lines I'm looking for are these two - along with its changes:
Look for this line - the first one:
Exec=/usr/bin/brave-browser-stable %U
Change it or replace it to:
Exec=/usr/bin/brave-browser-stable --enable-features=DefaultANGLEVulkan,VaapiIgnoreDriverChecks,Vulkan,VulkanFromANGLE %U
Then, look for this line - the second one:
Exec=/usr/bin/brave-browser-stable --incognito
Change it or replace it to:
Exec=/usr/bin/brave-browser-stable --enable-features=DefaultANGLEVulkan,VaapiIgnoreDriverChecks,Vulkan,VulkanFromANGLE --incognito
Save that file after making the changes - if it's nano, CTRL+O, Enter, Ctrl+X.
If it's Kate - just click Save or CTRL+S and put your sudo password to confirm.
Make sure to close the browser and re-launch, and it's all done & happy days!