FFmpeg on Clear Linux including H.264 and VP9 acceleration

Sadly, am not sure how long but there was an incorrect setting for Firefox preventing it from decoding using hardware acceleration using NVIDIA graphics. The following was false in the documentation for some time. It must remain enabled (default) or decoding via hardware acceleration will not work.

media.rdd-process.enabled          true

I now verify libraries used. In the case of Firefox, I look for vdpau_drv_video.so or nvidia_drv_video.so while playing a video. Depending on using the vdpau-va-driver-v9 or the nvdec-enabled-vaapi driver, respectively.

$ lsof | egrep -e 'dri/vdpau_drv_video' -e 'dri/nvidia_drv_video'
2 Likes

To be clear - the documentation you’re talking about is https://github.com/marioroy/ffmpeg-on-clear-linux

2 Likes

Correct.

I appreciate that you reach out @pixelgeek. There is another sadness of it all and it’s the swupd tool. It can break the NVIDIA driver installation. For that reason, I do not mention Clear Linux to my friends using NVIDIA graphics.

Otherwise if one doesn’t update (likely not recommended), the desktop experience is awesome. Even more so due to utilizing the video engine on the GPU. I enable ForceCompositionPipeline which rids of any jitters.

$ cat /etc/X11/xorg.conf.d/nvidia-screen-opt.conf 
Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    Option         "Stereo" "0"
    Option         "nvidiaXineramaInfoOrder" "DFP-2"
    Option         "metamodes" "nvidia-auto-select +0+0 {ForceCompositionPipeline=On, ForceFullCompositionPipeline=On}"
    Option         "SLI" "Off"
    Option         "MultiGPU" "Off"
    Option         "BaseMosaic" "off"
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

There is happiness (what an amazing desktop experience) and sadness (dislike the swupd tool breaking the NVIDIA driver installation). I haven’t had the time to investigate ignore files.

Hopeful; ++ for the day the swupd tool is mindful of the NVIDIA driver installation.

4 Likes

Well, it’s a moment of celebration. :slight_smile: :sunny:

2 Likes

Any updates ?


Nothing that I can talk about yet :wink:

3 Likes

I downloaded the developer Chrome and automatically came with ffmpeg support and can watch youtube and such.

I ran the installation BASH and got one error this:

`ERROR: cuvid requested, but not all dependencies are satisfied: ffnvcodec
`

Hi! I’m chiming in to let folks know that Hardware Acceleration is broken in Firefox 102 using NVIDIA graphics. Hardware acceleration was previously working in Firefox 101. Fortunately, the issue is resolved in the upcoming Firefox 103 release.

I have switched to Ubuntu some time ago. I no longer worry about OS updates breaking the NVIDIA installation. Updates to Brave, Google Chrome, and like browsers are automatic as well. The experience has been great. Well, I still have Clear Linux installed on a separate drive.

The guide for Ubuntu was tested on Ubuntu 20.04 and 22.04.
https://github.com/marioroy/nvidia-acceleration-on-ubuntu

Thanks for the updates :wink:

AV1 decode acceleration is working in Firefox Beta on Clear Linux and Ubuntu 20.04, 22.04 for NVIDIA 3000+ series graphics. As mentioned above hardware acceleration is broken in Firefox 102 and the reason using Beta.
https://github.com/marioroy/ffmpeg-on-clear-linux

https://github.com/marioroy/nvidia-acceleration-on-ubuntu

1 Like

beat this! (you can’t)

ffmpeg version git-2022-07-13-6f1b144 Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 12 (Clear Linux OS for Intel Architecture)
configuration: --prefix=/usr/local --extra-cflags=-I/usr/local/include --extra-ldflags=ā€˜-L/usr/local/lib -L/opt/nvidia/lib64 -L/opt/nvidia/lib -Wl,-rpath=/usr/local/lib:/opt/nvidia/lib -flto=auto -fuse-linker-plugin’ --extra-libs=ā€˜-lpthread -lm’ --ar=gcc-ar --enable-hardcoded-tables --arch=x86_64 --enable-x86asm --disable-podpages --disable-static --enable-shared --enable-pthreads --enable-avcodec --enable-bzlib --enable-gcrypt --enable-gmp --enable-gnutls --enable-fontconfig --enable-libaom --enable-libass --enable-libdav1d --enable-libdrm --enable-libfdk-aac --enable-libfreetype --enable-libmfx --enable-libmp3lame --enable-libopus --enable-libpulse --enable-librsvg --enable-libspeex --enable-libsvtav1 --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libopenjpeg --enable-opengl --enable-postproc --enable-sdl2 --enable-vaapi --enable-vulkan --enable-libglslang --enable-zlib --enable-ffplay --enable-gpl --enable-nonfree --enable-version3 --enable-lto --enable-opencl --enable-openal --disable-amd3dnow --disable-avx512 --enable-libzimg --enable-libjxl --enable-lcms2 --enable-libplacebo --enable-librubberband
libavutil 57. 28.100 / 57. 28.100
libavcodec 59. 37.100 / 59. 37.100
libavformat 59. 27.100 / 59. 27.100
libavdevice 59. 7.100 / 59. 7.100
libavfilter 8. 44.100 / 8. 44.100
libswscale 6. 7.100 / 6. 7.100
libswresample 4. 7.100 / 4. 7.100
libpostproc 56. 6.100 / 56. 6.100

i beat it!

ffmpeg version 2720715 Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 12 (Clear Linux OS for Intel Architecture)
configuration: --prefix=/usr/local --extra-cflags=-I/usr/local/include --extra-ldflags=ā€˜-L/usr/local/lib -L/usr/local/lib64 -L/opt/nvidia/lib64 -L/opt/nvidia/lib -Wl,-rpath=/usr/local/lib:/opt/nvidia/lib -flto=auto -fuse-linker-plugin’ --extra-libs=ā€˜-lpthread -lm’ --ar=gcc-ar --enable-hardcoded-tables --arch=x86_64 --enable-x86asm --disable-podpages --disable-static --enable-shared --enable-pthreads --enable-avcodec --enable-bzlib --enable-gcrypt --enable-gmp --enable-gnutls --enable-fontconfig --enable-libaom --enable-libass --enable-libdav1d --enable-libdrm --enable-libfdk-aac --enable-libfreetype --enable-libmfx --enable-libmp3lame --enable-libopus --enable-libpulse --enable-librsvg --enable-libspeex --enable-libsvtav1 --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libopenjpeg --enable-opengl --enable-postproc --enable-sdl2 --enable-vaapi --enable-vulkan --enable-libshaderc --enable-zlib --enable-ffplay --enable-gpl --enable-nonfree --enable-version3 --enable-lto --enable-opencl --enable-openal --disable-amd3dnow --disable-avx512 --enable-libzimg --enable-libjxl --enable-lcms2 --enable-libplacebo --enable-librubberband
libavutil 57. 28.100 / 57. 28.100
libavcodec 59. 37.100 / 59. 37.100
libavformat 59. 27.100 / 59. 27.100
libavdevice 59. 7.100 / 59. 7.100
libavfilter 8. 44.100 / 8. 44.100
libswscale 6. 7.100 / 6. 7.100
libswresample 4. 7.100 / 4. 7.100
libpostproc 56. 6.100 / 56. 6.100

1 Like

Hello, i have tried playing avc1 or vp9 video running smoothly on firefox. it can even play 4K 24fps vp9 with 30 dropped frames. but when I look at intel_gpu_top, only Render/3D is used. is this normal?
i use old i3-3217U with Intel HD 4000

use vainfo command to check gpu capabilties. (in package libva-utils)
install software-defined-cockpit for necessary drivers and software

2 Likes

installed software-defined-cockpit and then i check vainfo

$ vainfo
libva info: VA-API version 1.15.0
libva info: Trying to open /usr/lib64/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_1_15
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.15 (libva 2.15.0)
vainfo: Driver version: Intel i965 driver for Intel(R) Ivybridge Mobile - 2.4.1
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            :	VAEntrypointVLD
      VAProfileMPEG2Simple            :	VAEntrypointEncSlice
      VAProfileMPEG2Main              :	VAEntrypointVLD
      VAProfileMPEG2Main              :	VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline:	VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:	VAEntrypointEncSlice
      VAProfileH264Main               :	VAEntrypointVLD
      VAProfileH264Main               :	VAEntrypointEncSlice
      VAProfileH264High               :	VAEntrypointVLD
      VAProfileH264High               :	VAEntrypointEncSlice
      VAProfileH264StereoHigh         :	VAEntrypointVLD
      VAProfileVC1Simple              :	VAEntrypointVLD
      VAProfileVC1Main                :	VAEntrypointVLD
      VAProfileVC1Advanced            :	VAEntrypointVLD
      VAProfileNone                   :	VAEntrypointVideoProc
      VAProfileJPEGBaseline           :	VAEntrypointVLD

stil use Render/3D while watching 1080p video(avc1) on Youtube with h264ify add-ons enabled

1 Like

did u follow the rulez?!!
https://github.com/marioroy/ffmpeg-on-clear-linux/blob/19450591a7010aa3800e837133606b8c3ffded55/doc/Firefox-Config-File-And-Settings.md

can decode

can encode

1 Like

Thank you @dunaaja for the report. The issue is with ~/.config/firefox.conf. Comment out or remove the line export LIBVA_DRIVER_NAME=auto. I updated the GitHub repo with the following.

# Optionally uncomment one of the following matching your configuration.
# export LIBVA_DRIVER_NAME=iHD
# export LIBVA_DRIVER_NAME=i965
# export LIBVA_DRIVER_NAME=r600
# export LIBVA_DRIVER_NAME=radeonsi

Firefox plays videos using the video engine quite well on my Intel NUC box, supporting h264 but not VP9 nor AV1. So I install the enhanced-h264ify extension to block VP8, VP9, and AV1. Here are the 5 steps.

1. Install FFmpeg
2. Install ~/.config/firefox.conf
3. Install the enhanced-h264ify extension
4. Go to about:config and set media.ffmpeg.vaapi.enabled to True
5. Restart Firefox

Default enhanced-h264ify settings.

[ ]  Block 60fps video
[ ]  Block h264
[x]  Block VP8
[x]  Block VP9
[x]  Block AV1
[ ]  Disable Loudness Normalization

My ~/.config/firefox.conf. FFmpeg is install under /usr/local.

export FONTCONFIG_PATH=/usr/share/defaults/fonts
export LD_LIBRARY_PATH=/usr/local/lib

if [[ $XDG_SESSION_TYPE == wayland ]]
then
    export EGL_PLATFORM=wayland
    export MOZ_ENABLE_WAYLAND=1
else
    export MOZ_DISABLE_WAYLAND=1
    export MOZ_X11_EGL=1
fi

export MOZ_ACCELERATED=1
export MOZ_DISABLE_RDD_SANDBOX=1
export MOZ_USE_XINPUT2=1
export MOZ_WEBRENDER=1

The above is all I did minimally to enable hardware acceleration. The following resets Firefox back to default including removing the config file.

rm -fr ~/.firefox ~/.mozilla ~/.cache/mozilla
rm ~/.config/firefox.conf
2 Likes

Thanks for your explaantion. Maybe because I use outdated .conf from January. I will update the .conf

Thanks, I use enhanced-h264ify but still uses Render/3D.

Update:
Found that gfx.webrender.software is true, but unfortunately I also changed other settings causing Firefox to run with problems.

I tried to download the video and play it with mpv, but still Video Section is not active.

the mpv from the swupd repo is not going to use the ffmpeg libraries that you compiled.

i compile mpv myself with:

meson --prefix=/usr/local -Db_lto=true --buildtype=release \ 
-Dstrip=true -Dx11=disabled -Dopenal=enabled \
-Drubberband=enabled -Dlibmpv=true \
-Dlibplacebo=enabled -Dvaapi-wayland=enabled \
-Dvaapi-drm=enabled build
1 Like