ublue-os / main

OCI base images of Fedora with batteries included
https://universal-blue.org/images/main/
Apache License 2.0
505 stars 51 forks source link

Should ublue-os/main include intel-media-driver for hardware accelerated codecs? #97

Closed castrojo closed 1 year ago

castrojo commented 1 year ago

Discussed in https://github.com/ublue-os/main/discussions/96

Originally posted by **murphym18** April 1, 2023 Hey everyone! I'm pretty new to ublue and Kinoite, but I've been really impressed with how well everything runs on my laptop. And I've been trying to learn as much as I can. I noticed that the `libva-intel-driver` package is included in the ublue-os/main repository. Would it be helpful to also include the `intel-media-driver` package for anyone with an Intel CPU released after Oct 2014? While studying the ublue project, I found [the multimedia guide at rpmfusion.org](https://rpmfusion.org/Howto/Multimedia) and It says `intel-media-driver` is for "Intel (recent)" and `libva-intel-driver` is for "Intel (older)." I also found the [Supported Platforms list](https://github.com/intel/media-driver#supported-platforms) in the `intel-media-driver` repo. I think it supports Broadwell CPUs (5th gen) and newer. I'm still learning about ublue and the Silverblue/Fedora ecosystem, but I'm eager to experiment. Has anyone tried installing the `intel-media-driver`? Have you noticed any improvements? For reference, I have a Framework Laptop with a 12th Gen Intel chip released in 2022. Thanks for reading, and I'm looking forward to hearing your thoughts!
castrojo commented 1 year ago

(Transferred this from discussions for more visibility): It seems as though both intel packages can be installed without conflicting. I am not familiar with how these packages are laid out but we should look at enabling this, let's get more feedback from people who have experience in this area.

murphym18 commented 1 year ago

I discovered that Firefox is a great tool for testing codecs with VAAPI. To check if hardware-acceleration is working, I can go to YouTube in Firefox, select a 4k video, and increase the playback speed to 2x. This will put a heavy load on the CPU, making it easy to see if hardware acceleration is working.

After installing the ublue packages, including libva-intel-driver, my CPU usage remained around 100%. However, once I installed intel-media-driver, CPU usage dropped to 10%, and the computer became much quieter.

I needed to make some changes to the ublue scripts to get everything working correctly, and I plan to wipe my machine and try again to confirm everything. But if anyone else wants to test their hardware accelerated codecs, Firefox is a great option. It has a built-in task manager, and the process named "Data Decoder" is responsible for video decoding.

Hope that helps.

castrojo commented 1 year ago

Sorry I messed up the github discussions moving part and your post to the discussion got deleted but we've got the PR in and awaiting for a review.

Thanks for your investigation on this!

murphym18 commented 1 year ago

I had a chance to reset everything and test again, and I can confirm my previous findings. Firefox does indeed use hardware-accelerated video decoding when intel-media-driver is installed, at least on my 12th generation Intel CPU.

However, I discovered that the flathub version of Firefox doesn't seem to work properly with hardware-backed codecs. To check if hardware acceleration is working, the easiest way is to go to about:support in Firefox and look for the "Media" section.

Here are some screenshots

Firefox with Hardware Codecs firefox-with-hw-codecs

Firefox without Hardware Codecs firefox-no-hw-codecs

I'm glad to that the intel-media-driver package has been added in 9af34ec. Hardware-accelerated codecs can be especially beneficial for laptop users, and I think this is a great addition to the project.

Next, I will do a bit more testing with older hardware.

castrojo commented 1 year ago

Hmmm, can you check to see if the ffmpeg-full flatpak was pulled in from Flathub as well? My firefox from flathub has hardware support enabled on all my systems intel without having the intel-media-driver package.

(we'll add the package anyway so we can cover all the bases)

murphym18 commented 1 year ago

Thank you for the tip. I looked into the Firefox flatpak issue and found two ways to enable VAAPI hardware acceleration.

First, I needed to set media.ffmpeg.vaapi.enable=true in about:config. Then, I could choose to do one of the following (or both):

  1. Install intel-media-driver and/or libva-intel-driver with rpm-ostree (I installed both, but I don't think I need both).
  2. Install the org.freedesktop.Platform.ffmpeg-full flatpak runtime. (I installed the newest version)

I'm rather surprised by this outcome. It seems the Firefox flatpak can use "native" media drivers or the ffmpeg-full runtime. However, I don't know what Firefox prioritizes when all-of-the-above are installed. But I can confirm that it still works.

To be completely honest, I had a slightly better first-timer experience using the version of Firefox that came with Fedora Kinoite. This is because it worked out-of-the-box once I installed intel-media-driver. However, I'm still undecided about what version of firefox I want to stick with. It's good to have options.

castrojo commented 1 year ago

We've merged the intel-media-driver package so that'll be available for everyone.

Setting firefox user settings is outside our scope (we really don't want to mess with people's installs in their home directory) , if you're up to whipping up a standalone doc page for folks I'd love to include this on the website, if you wouldn't mind filing an issue here of what you want the text to look like I can do the legwork: https://github.com/ublue-os/website

Your conclusion about the first time user experience is spot on. We don't want to deal with any of this, we'll ship intel-media-driver on the image and also leave instructions for the flatpaks so that none of us have to deal so that we can all move on to more important issues.

murphym18 commented 1 year ago

Sure! I would be more than happy to create the GitHub issue and work on a pull request.