Intel Arc GPU, ffmpeg AV1 hardware encoding

Splitting out topics from this thread

I got an Intel Arc A750 which I intend to use for gaming and AV1 encoding using ffmpeg.

It works fine out of the box, apart from issues mentioned in the other post, and ffmpeg does not use it for encoding yet.

Normal libsvtav1 runs on the CPU only. Will have to see how I can get it to run on the GPU, or if I use a different encoder.

I found online that VAAPI or QSV should be used. I am not sure yet what these are and how they compare. Afaik VAAPI would be preferred on Linux?

I found this (portuguese) resource, which uses QSV. out of the box it produces errors, will see if I need the runtime vpl-gpu-rt.

As QSV is “higher tier” (or as some people might say “Just VAAPI with proprietary things added to it”), performance has been reported as up to 50% better.

I think adding vpl-gpu-rt to the hardware.graphics.extraPackages caused my system to compile the kernel from scratch, so well I am doing that now and will see.

From my short research and ffmpeg -h encoder=av1_qsv, I assembled this command for encoding

ffmpeg -i "$input_file" \
        -c:v av1_qsv \
			-preset veryslow \
			-global_quality 24 \
			-adaptive_i 1 -adaptive_b 1 -b_strategy 1 \
			-extbrc 1 -look_ahead_depth 100 \
            -vf "hqdn3d" \
		-sn \
		-an \
        -map_metadata 0 \
        -map 0 \
        "$output_file"

to my knowledge, these encoders exist

# Software
libaom-av1 # first proof of concept, quite inefficient on my CPU
libsvtav1 # way faster on my CPU, 1.5x at max, I used this until now

# Hardware
av1_vaapi # standard VAAPI, simpler and open (I suppose) but less efficient than qsv
av1_qsv # QuickSync, supported by Intel and AMD, more advanced than just VAAPI

Denoising

Seems as if the GPU can use hqdn3d but not nlmeans (which is better). Using nlmeans immediately killed the speed completely!

I used no denoising at all and found -global_quality 22 to achieve near transparency, even when encoding 2K to 1080p! AV1 is amazing (even though AV2 soon being out makes me want to wait with the encoding, but well, hardware support will take time)

Today I tried playing a video through MPV with hwdec=auto and this is the output I got,

[qp@db:~]$ mpv video.webm
● Video  --vid=1               (av1 1920x1080 23.976 fps) [default]
● Audio  --aid=1  --alang=eng  (opus 2ch 48000 Hz) [default]
MESA-INTEL: warning: ../src/intel/vulkan/anv_formats.c:981: FINISHME: support more multi-planar formats with DRM modifiers
[ffmpeg/video] av1: Device does not support the VK_KHR_video_decode_queue extension!
[ffmpeg/video] av1: Your platform doesn't support hardware accelerated AV1 decoding.
[ffmpeg/video] av1: Failed to get pixel format.
[ffmpeg/video] av1: Get current frame error
Error while decoding frame (hardware decoding)!
Cannot load libcuda.so.1
Using hardware decoding (vaapi).
AO: [pipewire] 48000Hz stereo 2ch floatp
VO: [gpu-next] 1920x1080 vaapi[nv12]
AV: 00:00:02 / 00:06:14 (1%) A-V: -0.000
Exiting... (Quit)

I then checked with hwdec=vaapi and it works fine. This is the output I got of vainfo,

[qp@db:~]$ nix-shell -p libva-utils --run vainfo
this path will be fetched (0.49 MiB download, 3.45 MiB unpacked):
  /nix/store/yj3ymvw27w55s13miqlmlafwa8vi95nx-libva-utils-2.22.0
copying path '/nix/store/yj3ymvw27w55s13miqlmlafwa8vi95nx-libva-utils-2.22.0' from 'https://cache.nixos.org'...
Trying display: wayland
Trying display: x11
libva info: VA-API version 1.22.0
libva info: User environment variable requested driver 'iHD'
libva info: Trying to open /run/opengl-driver/lib/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_22
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.22 (libva 2.22.0)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 25.3.4 ()
vainfo: Supported profile and entrypoints
      VAProfileNone                   :	VAEntrypointVideoProc
      VAProfileNone                   :	VAEntrypointStats
      VAProfileMPEG2Simple            :	VAEntrypointVLD
      VAProfileMPEG2Main              :	VAEntrypointVLD
      VAProfileH264Main               :	VAEntrypointVLD
      VAProfileH264Main               :	VAEntrypointEncSliceLP
      VAProfileH264High               :	VAEntrypointVLD
      VAProfileH264High               :	VAEntrypointEncSliceLP
      VAProfileJPEGBaseline           :	VAEntrypointVLD
      VAProfileJPEGBaseline           :	VAEntrypointEncPicture
      VAProfileH264ConstrainedBaseline:	VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:	VAEntrypointEncSliceLP
      VAProfileHEVCMain               :	VAEntrypointVLD
      VAProfileHEVCMain               :	VAEntrypointEncSliceLP
      VAProfileHEVCMain10             :	VAEntrypointVLD
      VAProfileHEVCMain10             :	VAEntrypointEncSliceLP
      VAProfileVP9Profile0            :	VAEntrypointVLD
      VAProfileVP9Profile0            :	VAEntrypointEncSliceLP
      VAProfileVP9Profile1            :	VAEntrypointVLD
      VAProfileVP9Profile1            :	VAEntrypointEncSliceLP
      VAProfileVP9Profile2            :	VAEntrypointVLD
      VAProfileVP9Profile2            :	VAEntrypointEncSliceLP
      VAProfileVP9Profile3            :	VAEntrypointVLD
      VAProfileVP9Profile3            :	VAEntrypointEncSliceLP
      VAProfileHEVCMain12             :	VAEntrypointVLD
      VAProfileHEVCMain422_10         :	VAEntrypointVLD
      VAProfileHEVCMain422_10         :	VAEntrypointEncSliceLP
      VAProfileHEVCMain422_12         :	VAEntrypointVLD
      VAProfileHEVCMain444            :	VAEntrypointVLD
      VAProfileHEVCMain444            :	VAEntrypointEncSliceLP
      VAProfileHEVCMain444_10         :	VAEntrypointVLD
      VAProfileHEVCMain444_10         :	VAEntrypointEncSliceLP
      VAProfileHEVCMain444_12         :	VAEntrypointVLD
      VAProfileHEVCSccMain            :	VAEntrypointVLD
      VAProfileHEVCSccMain            :	VAEntrypointEncSliceLP
      VAProfileHEVCSccMain10          :	VAEntrypointVLD
      VAProfileHEVCSccMain10          :	VAEntrypointEncSliceLP
      VAProfileHEVCSccMain444         :	VAEntrypointVLD
      VAProfileHEVCSccMain444         :	VAEntrypointEncSliceLP
      VAProfileAV1Profile0            :	VAEntrypointVLD
      VAProfileAV1Profile0            :	VAEntrypointEncSliceLP
      VAProfileHEVCSccMain444_10      :	VAEntrypointVLD
      VAProfileHEVCSccMain444_10      :	VAEntrypointEncSliceLP

I don’t know how to fix the first issue I encountered.

1 Like

Have you followed the thread I link above? Btw your post might fit better there as this is about encoding and ffmpeg. Manually adding the iHD driver should not be needed, but intel-media-driver likely will be

1 Like