AMD PRO CPU/GPU packages to enable video encoding/decoding HW support?

Hello,
i am looking for a suggestion on which packages to install in order to enable ffmpeg to use hardware video decoding/encoding functions of the AMD Ryzen 7 PRO 4000 Series processor like 3750GE.

i have already installed packages that i have found suggested:
$ pacman -Q|grep -E “amd|vdp|mesa|cuda”|sort -h

amd-ucode 20210211.r1830.f7915a0-1
lib32-libva-mesa-driver 20.3.4-3
lib32-libva-vdpau-driver 0.7.4-6
lib32-libvdpau 1.4-1
lib32-mesa 20.3.4-3
lib32-mesa-demos 8.4.0-2
lib32-mesa-vdpau 20.3.4-3
libva-mesa-driver 20.3.4-3
libva-vdpau-driver 0.7.4-5
libvdpau 1.4-1
libvdpau-va-gl 0.4.2-3
mesa 20.3.4-3
mesa-demos 8.4.0-4
mesa-vdpau 20.3.4-3
mhwd-amdgpu 19.1.0-1
vdpauinfo 1.4-1
xf86-video-amdgpu 19.1.0-2

https://wiki.archlinux.org/index.php/Hardware_video_acceleration
https://wiki.archlinux.org/index.php/AMDGPU_PRO

$ pamac install libva-utils
$ vainfo

vainfo: VA-API version: 1.10 (libva 2.10.0)
vainfo: Driver version: Mesa Gallium driver 20.3.4 for AMD RENOIR (DRM 3.40.0, 5.10.19-1-MANJARO, LLVM 11.1.0)
vainfo: Supported profile and entrypoints
VAProfileMPEG2Simple : VAEntrypointVLD
VAProfileMPEG2Main : VAEntrypointVLD
VAProfileVC1Simple : VAEntrypointVLD
VAProfileVC1Main : VAEntrypointVLD
VAProfileVC1Advanced : VAEntrypointVLD
VAProfileH264ConstrainedBaseline: VAEntrypointVLD
VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
VAProfileH264Main : VAEntrypointVLD
VAProfileH264Main : VAEntrypointEncSlice
VAProfileH264High : VAEntrypointVLD
VAProfileH264High : VAEntrypointEncSlice
VAProfileHEVCMain : VAEntrypointVLD
VAProfileHEVCMain : VAEntrypointEncSlice
VAProfileHEVCMain10 : VAEntrypointVLD
VAProfileHEVCMain10 : VAEntrypointEncSlice
VAProfileJPEGBaseline : VAEntrypointVLD
VAProfileVP9Profile0 : VAEntrypointVLD
VAProfileVP9Profile2 : VAEntrypointVLD
VAProfileNone : VAEntrypointVideoProc

$ ffmpeg -hwaccels

ffmpeg version n4.3.1 Copyright © 2000-2020 the FFmpeg developers
built with gcc 10.2.0 (GCC)
configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-amf --enable-avisynth --enable-cuda-llvm --enable-lto --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libmfx --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librav1e --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-nvdec --enable-nvenc --enable-shared --enable-version3
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Hardware acceleration methods:
vdpau
cuda
vaapi
qsv
drm

$ ffmpeg -encoders 2>/dev/null |grep -E “vdpau|cuda|vaapi|qsv|drm”

V… h264_qsv H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (Intel Quick Sync Video acceleration) (codec h264)
V… h264_vaapi H.264/AVC (VAAPI) (codec h264)
V… hevc_qsv HEVC (Intel Quick Sync Video acceleration) (codec hevc)
V… hevc_vaapi H.265/HEVC (VAAPI) (codec hevc)
V… mjpeg_qsv MJPEG (Intel Quick Sync Video acceleration) (codec mjpeg)
V… mjpeg_vaapi MJPEG (VAAPI) (codec mjpeg)
V… mpeg2_qsv MPEG-2 video (Intel Quick Sync Video acceleration) (codec mpeg2video)
V… mpeg2_vaapi MPEG-2 (VAAPI) (codec mpeg2video)
V… vp8_vaapi VP8 (VAAPI) (codec vp8)
V… vp9_vaapi VP9 (VAAPI) (codec vp9)
V… vp9_qsv VP9 video (Intel Quick Sync Video acceleration) (codec vp9)

So i have tried command
ffmpeg -i sourcefile -vcodec libx265 destination.mp4
which is the only one that works (at around 70fps), other codecs shows following errors:

[nvenc_hevc @ 0x55785b157e40] This encoder is deprecated, use ‘hevc_nvenc’ instead
[nvenc_hevc @ 0x55785b157e40] Cannot load libcuda.so.1
Error initializing output stream 0:0 – Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

[hevc_nvenc @ 0x55a5404b1e40] Cannot load libcuda.so.1
Error initializing output stream 0:0 – Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

[hevc_amf @ 0x55fa90e21680] DLL libamfrt64.so.1 failed to open
Error initializing output stream 0:0 – Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

[hevc_qsv @ 0x5586ba679e40] Failed to create a VAAPI device.
Error initializing output stream 0:0 – Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

[hevc_v4l2m2m @ 0x5555859d9e40] Could not find a valid device
[hevc_v4l2m2m @ 0x5555859d9e40] can’t configure encoder
Error initializing output stream 0:0 – Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

hevc_vaapi:
Impossible to convert between the formats supported by the filter ‘Parsed_null_0’ and the filter ‘auto_scaler_0’
Error reinitializing filters!
Failed to inject frame into filter network: Function not implemented
Error while processing the decoded data for stream #0:0

::

My aim is to encode to H265 or H264 format using ffmpeg with minimum computing overhead/impact. I was looking for some script that would estimate available accelerators and test its performance, but can not find.

UPDATES:

  1. following command apparently WORKS:
    ffmpeg -vaapi_device /dev/dri/renderD128 -i input.mp4 -vf 'format=nv12,hwupload' -c:v hevc_vaapi -f mp4 -rc_mode 1 -qp 25 output.mp4
    source (Arch wiki); FPS is not 70, but 360 and CPU usage monitor does not show any additional CPU usage…! The question is how to tweak these parameters and how to apply it to every H265 encoding of every app on the system.
    ffmpeg -help encoder=hevc_vaapi show some parameters details, rc_mode (rate control) seems not needed.

LMGFTY

Oh, and turn off those stupid smartquotes.

1 Like