From: Theo Buehler Subject: Re: Enable VA-API in graphics/ffmpeg To: Rafael Sadowski , ports Cc: landry@openbsd.org Date: Fri, 26 Jul 2024 14:35:28 +0200 On Wed, Jul 24, 2024 at 03:15:55PM +0000, Lucas Gabriel Vuotto wrote: > On Wed, Jul 24, 2024 at 07:59:23AM GMT, Rafael Sadowski wrote: > > On Sun Jul 21, 2024 at 04:58:15PM GMT, Lucas Gabriel Vuotto wrote: > > > On Sat, Jul 20, 2024 at 11:32:29AM GMT, Rafael Sadowski wrote: > > > > OK to enable VA-API? It only depends on xenocara libva. Since libva > > > > builds on almost all arches, I see no reason to restrict it by CPU > > > > architectures any further. > > > > > > This worked well with mpv but is giving me issues in Firefox: > > > > I can confirm that it works well with mpv(1) but not in ff. In my last > > test I only tested WebGL and simple youtube stuff. > > > > I have not noticed taht playing youtube run on my CPU. That's because up > > to 1080p60 always runs smoothly. But 2160p60 is the end of the line > > here. > > > > What I cannot confirm, any disadvantages with enabling or disabling > > VAAPI. > > Did you try Twitch? It indeed stops working ,and I wouldn't consider it > as niche as viewing YouTube thru Invidious (OT: I believe it's becoming > less and less niche.) > > > > > > > - Invidious instances (YouTube alternative frontend) give me "No > > > compatible source was found for this media" > > > - Twitch gives a similar message > > > - Couldn't test in YouTube because it thinks I'm a bot > > > > WTF! > > It doesn't like my VPS provider. After connecting from my home, I saw > the same thing as you: it runs on the CPU. > > > > - Some meme pages show webms just fine > > > > I don't see it, I'll test it with a new profile. Can you give me a test > > example? > > https://9gag.com/gag/avynegn > https://9gag.com/gag/amoz10j > > Raw media links: > > https://img-9gag-fun.9cache.com/photo/amoz10j_460svvp9.webm (VP9) > https://img-9gag-fun.9cache.com/photo/avynegn_460svav1.mp4 (AV1) > > According to about:support, both VP9 and AV1 decoding are supported > (tried with the Tiger Lake, i7-1165G7, Intel iRIS Xe-LP). > > Downloading the video and playing it with MPV works wonders. Playing it > in Firefox makes the CPU usage raise. Enabling > media.ffmpeg.vaapi.enabled made no difference, even after a restart. > > Basically, it seems that having an VA-API enabled ffmpeg doesn't make > a difference in Firefox right now. > If it's only about enabling va-api in ffmpeg without breaking the sites and links above in firefox, I think a patch to firefox's unveil.utility adding '/usr/X11R6/lib r' would enough. There are numerous issues that will need to be fixed before va-api in firefox will actually work. Some of them are pledge/unveil related, others are firefox hardcoding specific library versions for dlopen without fallback. With the symlinks below and various additions to pledge and unveil, I get sound to play in what looks like hardware decoded video. Unfortunately, the player remains dark... I also frobbed a few knobs in about:config, but I don't exactly remember what. setting media.ffmpeg.vaapi.enabled to true and gfx.webrender.all are a good start. Studying the output of env MOZ_LOG="FFmpegVideo:5, Dmabuf:5" firefox helps. $ ls -al /usr/X11R6/lib | grep @ lrwxr-xr-x 1 root bin 9 Jul 26 05:41 libXaw.a@ -> libXaw7.a lrwxr-xr-x 1 root bin 15 Jul 26 05:41 libXaw.so.16.0@ -> libXaw7.so.16.0 lrwxr-xr-x 1 root wheel 29 Jul 25 12:59 libdrm.so@ -> /usr/X11R6/lib/libdrm.so.7.13 lrwxr-xr-x 1 root wheel 29 Jul 26 14:21 libdrm.so.2@ -> /usr/X11R6/lib/libdrm.so.7.13 lrwxr-xr-x 1 root wheel 28 Jul 25 12:59 libgbm.so@ -> /usr/X11R6/lib/libgbm.so.0.6 lrwxr-xr-x 1 root wheel 28 Jul 26 12:19 libgbm.so.1@ -> /usr/X11R6/lib/libgbm.so.0.6 lrwxr-xr-x 1 root wheel 32 Jul 24 21:21 libva-drm.so.2@ -> /usr/X11R6/lib/libva-drm.so.2.22 lrwxr-xr-x 1 root wheel 28 Jul 24 21:21 libva.so.2@ -> /usr/X11R6/lib/libva.so.2.22 Only in /usr/local/lib/firefox/browser/defaults/preferences: all-openbsd.js diff -pu -r /usr/local/lib/firefox/browser/defaults/preferences/pledge.rdd /etc/firefox/pledge.rdd --- /usr/local/lib/firefox/browser/defaults/preferences/pledge.rdd Thu Jul 25 14:54:59 2024 +++ /etc/firefox/pledge.rdd Fri Jul 26 14:16:14 2024 @@ -1,6 +1,10 @@ stdio rpath # gtk tries to access /usr/local/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache +wpath +cpath tmppath recvfd sendfd unix # getsockopt +drm +prot_exec diff -pu -r /usr/local/lib/firefox/browser/defaults/preferences/unveil.rdd /etc/firefox/unveil.rdd --- /usr/local/lib/firefox/browser/defaults/preferences/unveil.rdd Thu Jul 25 14:54:59 2024 +++ /etc/firefox/unveil.rdd Fri Jul 26 14:07:14 2024 @@ -1,2 +1,8 @@ # shm files /tmp rwc +/dev/dri rw +/usr/lib r +/usr/X11R6/lib r +/usr/local/lib r + +~/.Xauthority r diff -pu -r /usr/local/lib/firefox/browser/defaults/preferences/unveil.utility /etc/firefox/unveil.utility --- /usr/local/lib/firefox/browser/defaults/preferences/unveil.utility Thu Jul 25 14:54:59 2024 +++ /etc/firefox/unveil.utility Fri Jul 26 12:51:28 2024 @@ -1,3 +1,4 @@ /usr/lib r +/usr/X11R6/lib r /usr/local/lib r /tmp rwc