GPUOpen-LibrariesAndSDKs / AMF

The Advanced Media Framework (AMF) SDK provides developers with optimal access to AMD devices for multimedia processing
Other
611 stars 152 forks source link

[Bug]: AMF encoding does not work on Linux past driver version 21.30 #334

Open hannesmann opened 2 years ago

hannesmann commented 2 years ago

Describe the bug Using any version of Radeon Software for Linux newer than 21.30 causes AMF to fail when attempting to encode video on an RX 6700 XT. This issue also occurred on an RX 590.

I usually use the unofficial AUR package for AMF to stream with OBS, but I can also reproduce the issue on Ubuntu 20.04 LTS which is a supported distro for AMF.

To Reproduce Steps to reproduce the behavior:

  1. Install any version of Radeon Software past 21.30.
  2. Use the h264_amf encoder in FFmpeg or run the SimpleEncoder sample included in this repository.

Setup:

Tests were done with AMD's proprietary Vulkan driver and not RADV. Using RADV causes a segfault on startup.

Debug Log: When running ffmpeg -loglevel verbose -i input.mp4 -c:v h264_amf -log_to_dbg true output.mp4

[h264_amf @ 0x562bcbe259c0] AMF initialisation succeeded via Vulkan.
0122-06-06 23:09:34 BE10E040 [AMFEncoderCoreH264]   Error: ../../../../../runtime/src/components/EncoderCore/EncoderCoreH264Impl.cpp(187):Assertion failed:Failed to create service!
0122-06-06 23:09:34 BE10E040 [AMFEncoderCoreH264]   Error: ../../../../../runtime/src/components/EncoderCore/EncoderCoreH264Impl.cpp(319):AMF_ERROR 1 : AMF_FAIL: Failed to create encode service!
0122-06-06 23:09:34 BE10E040 [AMFEncoderCoreH264] Warning: CreateServices failed.
[h264_amf @ 0x562bcbd6b740] CreateComponent(AMFVideoEncoderVCE_AVC) failed with error 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

When running SimpleEncoder input.mp4

0122-06-06 23:02:48 E743F740 [AMFEncoderCoreH264]   Error: ../../../../../runtime/src/components/EncoderCore/EncoderCoreH264Impl.cpp(187):Assertion failed:Failed to create service!
0122-06-06 23:02:48 E743F740 [AMFEncoderCoreH264]   Error: ../../../../../runtime/src/components/EncoderCore/EncoderCoreH264Impl.cpp(187):Assertion failed:Failed to create service!
0122-06-06 23:02:48 E743F740 [AMFEncoderCoreH264]   Error: ../../../../../runtime/src/components/EncoderCore/EncoderCoreH264Impl.cpp(319):AMF_ERROR 1 : AMF_FAIL: Failed to create encode service!
0122-06-06 23:02:48 E743F740 [AMFEncoderCoreH264]   Error: ../../../../../runtime/src/components/EncoderCore/EncoderCoreH264Impl.cpp(319):AMF_ERROR 1 : AMF_FAIL: Failed to create encode service!
0122-06-06 23:02:48 E743F740 [AMFEncoderCoreH264] Warning: CreateServices failed.
0122-06-06 23:02:48 E743F740 [AMFEncoderCoreH264] Warning: CreateServices failed.
0122-06-06 23:02:48 E743F740 [SimpleEncoder]   Error: ../../../../public/samples/CPPSamples/SimpleEncoder/SimpleEncoder.cpp(177):AMF_ERROR 1 : AMF_FAIL: CreateComponent(AMFVideoEncoderVCE_AVC) failed
0122-06-06 23:02:48 E743F740 [SimpleEncoder]   Error: ../../../../public/samples/CPPSamples/SimpleEncoder/SimpleEncoder.cpp(177):AMF_ERROR 1 : AMF_FAIL: CreateComponent(AMFVideoEncoderVCE_AVC) failed
SimpleEncoder: ../../../../public/samples/CPPSamples/SimpleEncoder/SimpleEncoder.cpp:177: int main(int, char**): Assertion `0' failed.

Expected behavior AMF should be able to encode the video successfully.

MikhailAMD commented 2 years ago

It looks like you have an installation issue, some mismatch between AMF/EncodeCore and VCN FW. What is your driver install command line?

hannesmann commented 2 years ago

some mismatch between AMF/EncodeCore and VCN FW

Output from dmesg:

[    5.285797] [drm] VCN(0) decode is enabled in VM mode
[    5.285798] [drm] VCN(0) encode is enabled in VM mode
[    7.368579] [drm] Found VCN firmware Version ENC: 1.20 DEC: 2 VEP: 0 Revision: 5
[    7.368582] amdgpu 0000:06:00.0: amdgpu: Will use PSP to load VCN firmware
[    8.063896] [drm] VCN decode and encode initialized successfully(under DPG Mode).

What is your driver install command line

I used a fresh install when testing on Ubuntu. All I did was download the 22.10.2 deb package from amd.com and run:

sudo amdgpu-install --usecase=workstation --vulkan=pro
sudo apt install amf-amdgpu-pro
GloriousEggroll commented 2 years ago

just dropping a note here to verify the same thing -- tested on both an rx 6600, 6700 XT, and 6900 XT, 21.40.2 with amf version 1.4.23 is the last version that works with these cards. I -did- also test 22.10.2 with an RX 5500 and an RX 580 -- both worked but none of the 6000 series worked.

I will test the 22.10.3 and 22.20 drivers on the RX 5500 and RX 580 and report back -- these also did -not- work for the 6000 series.

Another note/different bug -- the 6600 came up with an unidentified name in the 22.10.2 vulkan pro drivers. (the 6700 XT and 6900 XT were fine)

GloriousEggroll commented 2 years ago

more progress!

if i keep the vulkan-pro files from 21.40.2: https://repo.radeon.com/amdgpu/21.40.2/ubuntu/pool/proprietary/v/vulkan-amdgpu-pro/vulkan-amdgpu-pro_21.40.2-1350683_amd64.deb https://repo.radeon.com/amdgpu/21.40.2/ubuntu/pool/proprietary/v/vulkan-amdgpu-pro/vulkan-amdgpu-pro_21.40.2-1350683_i386.deb

and use the amf and libamdenc from 22.20: https://repo.radeon.com/amdgpu/22.20/ubuntu/pool/proprietary/a/amf-amdgpu-pro/amf-amdgpu-pro_1.4.26-1438747~22.04_amd64.deb https://repo.radeon.com/amdgpu/22.20/ubuntu/pool/proprietary/liba/libamdenc-amdgpu-pro/libamdenc-amdgpu-pro_1.0-1438747~22.04_amd64.deb

-- encoding works on my 6000 series cards! -edit- can confirm this method works on polaris and 5000 series cards also -- so the problem is whatever changed between amf and the vulkan-pro drivers after 21.40.2

MikhailAMD commented 2 years ago

In general, mixing components from different drivers is dangerous. One thing I noticed: the correct AMF install command; would be: sudo amdgpu-install --usecase=workstation,amf --vulkan=pro I am not sure what happens when you install amf explicitly via apt.

Trillon008 commented 2 years ago

I believe I've been able to make both h264 & hevc work with latest 22.20.1

ffmpeg -i re3_speedrun_orig.webm -vf format=nv12 -c:v hevc_amf -c:a copy re3_amfhevc.mp4

Stream mapping:
  Stream #0:0 -> #0:0 (vp9 (native) -> hevc (hevc_amf))
  Stream #0:1 -> #0:1 (copy)

encoder         : Lavf59.16.100
  Stream #0:0(eng): Video: hevc (hev1 / 0x31766568), nv12(tv, bt709/unknown/unknown, progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 2000 kb/s, 30 fps, 15360 tbn (default)
    Metadata:
      DURATION        : 02:53:07.965000000
      encoder         : Lavc59.18.100 hevc_amf
  Stream #0:1(eng): Audio: opus (Opus / 0x7375704F), 48000 Hz, stereo, fltp (default)
    Metadata:
      DURATION        : 02:53:08.041000000
frame= 4747 fps=658 q=-0.0 Lsize=   40912kB time=00:02:38.62 bitrate=2112.9kbits/s speed=  22x    
video:38099kB audio:2688kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.306913%

ffmpeg -i re3_speedrun_orig.webm -c:v h264_amf -c:a copy re3_amf.mp4

Stream mapping:
  Stream #0:0 -> #0:0 (vp9 (native) -> h264 (h264_amf))
  Stream #0:1 -> #0:1 (copy)

    encoder         : Lavf59.16.100
  Stream #0:0(eng): Video: h264 (avc1 / 0x31637661), yuv420p(tv, bt709/unknown/unknown, progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 2000 kb/s, 30 fps, 15360 tbn (default)
    Metadata:
      DURATION        : 02:53:07.965000000
      encoder         : Lavc59.18.100 h264_amf
  Stream #0:1(eng): Audio: opus (Opus / 0x7375704F), 48000 Hz, stereo, fltp (default)
    Metadata:
      DURATION        : 02:53:08.041000000
frame= 3131 fps=714 q=-0.0 Lsize=   27281kB time=00:01:44.72 bitrate=2134.1kbits/s speed=23.9x    
video:25431kB audio:1767kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.305157%

Maybe one of you can retry to confirm. I've used glorious's method for installing AMF

GloriousEggroll commented 2 years ago

I believe I've been able to make both h264 & hevc work with latest 22.20.1

ffmpeg -i re3_speedrun_orig.webm -vf format=nv12 -c:v hevc_amf -c:a copy re3_amfhevc.mp4

Stream mapping:
  Stream #0:0 -> #0:0 (vp9 (native) -> hevc (hevc_amf))
  Stream #0:1 -> #0:1 (copy)

encoder         : Lavf59.16.100
  Stream #0:0(eng): Video: hevc (hev1 / 0x31766568), nv12(tv, bt709/unknown/unknown, progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 2000 kb/s, 30 fps, 15360 tbn (default)
    Metadata:
      DURATION        : 02:53:07.965000000
      encoder         : Lavc59.18.100 hevc_amf
  Stream #0:1(eng): Audio: opus (Opus / 0x7375704F), 48000 Hz, stereo, fltp (default)
    Metadata:
      DURATION        : 02:53:08.041000000
frame= 4747 fps=658 q=-0.0 Lsize=   40912kB time=00:02:38.62 bitrate=2112.9kbits/s speed=  22x    
video:38099kB audio:2688kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.306913%

ffmpeg -i re3_speedrun_orig.webm -c:v h264_amf -c:a copy re3_amf.mp4

Stream mapping:
  Stream #0:0 -> #0:0 (vp9 (native) -> h264 (h264_amf))
  Stream #0:1 -> #0:1 (copy)

    encoder         : Lavf59.16.100
  Stream #0:0(eng): Video: h264 (avc1 / 0x31637661), yuv420p(tv, bt709/unknown/unknown, progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 2000 kb/s, 30 fps, 15360 tbn (default)
    Metadata:
      DURATION        : 02:53:07.965000000
      encoder         : Lavc59.18.100 h264_amf
  Stream #0:1(eng): Audio: opus (Opus / 0x7375704F), 48000 Hz, stereo, fltp (default)
    Metadata:
      DURATION        : 02:53:08.041000000
frame= 3131 fps=714 q=-0.0 Lsize=   27281kB time=00:01:44.72 bitrate=2134.1kbits/s speed=23.9x    
video:25431kB audio:1767kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.305157%

Maybe one of you can retry to confirm. I've used glorious's method for installing AMF

22.20.1 amdgpu-pro-vulkan is still not compatible with 6000 series when installing just the amdgpu-pro and amf packages. Only 21.40.2's amdgpu-pro-vulkan works. I have -not- tried this method yet:

sudo amdgpu-install --usecase=workstation,amf --vulkan=pro
DiarrheaMcgee commented 2 years ago

i have the same [h264_amf @ 0x562bcbd6b740] CreateComponent(AMFVideoEncoderVCE_AVC) failed with error 1 problem

GloriousEggroll commented 2 years ago

From AUR, install vulkan-amdgpu-pro-fix amf-amdgpu-pro-fix and AMF works on RX 6000 series graphics cards!

Look at the PKGBUILD. They are doing the same thing I recommended -- using 21.40.2 vulkan:

https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=amdgpu-pro-installer-fix#n14 https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=amdgpu-pro-installer-fix#n54 https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=amdgpu-pro-installer-fix#n55

As mentioned -- this is not a proper fix, it's a hacky workaround

DiarrheaMcgee commented 2 years ago

that works perfectly

jarrard commented 2 years ago

I still get freeze or seg fault with these amf 21-40-2 drivers using pkgbuild provided. Not sure whats wrong.

VK_ICD_FILESNAMES=/usr/share/vulkan/icd.d/amd_pro_icd64.json:/usr/share/vulkan/icd.d/amd_pro_icd32.json OBS_USE_EGL=1 obs

liamtay07 commented 2 years ago

@jarrard I recommend you to simplify things and use Vulkan Prefixes. Install from AUR amd-vulkan-prefixes Launch OBS with: OBS_USE_EGL=1 vk_pro obs

And your games with vk_radv https://wiki.archlinux.org/title/Vulkan#Selecting_via_AMD_Vulkan_Prefixes

Does this change anything? Does it work for you now?

jarrard commented 2 years ago

Cheers it does appear to work now. I just test it by recording the desktop.

I've been using obs_vkcapture for games which I think still works but i'll toss in vk_radv also to ensure radv gets used.

Seems OBS_USE_EGL=1 vk_pro obs works in terminal but not in desktop exec=OBS_USE_EGL=1 vk_pro obs env/export makes no difference. Seems desktop shortcuts can't pass multiple commands.

Yeah OBS_USE_EGL=1 vk_pro obs works in terminal but won't work in .desktop or sh/bash script... puzzling!

wallcarpet40 commented 2 years ago

@jarrard If you are using KDE, try adding env to your .desktop file like this:

env VK_ICD_FILENAMES=/opt/amdgpu-pro/vulkan/icd/amd_pro_icd64.json obs

I have my json files moved out of /usr/share/vulkan/icd.d/ folder, so that no other program will try to start with the pro drivers.

jarrard commented 2 years ago

Cheers, thought for some reason it works now. I'm using a sh script.

kik4444 commented 2 years ago

So now we have some hacky workarounds to at least restore h264_amf, but has anyone figured out how to restore hevc_amf?

Almost everywhere I look, people say that hevc_amf does not work on Linux, yet there was a very short period between March and April of this year when it did work with version 21.50 of the proprietary driver.

I have a 6xxx GPU with Arch Linux, and during this one month period I used this package https://aur.archlinux.org/packages/amf-amdgpu-pro to install the proprietary AMD driver and AMF. This also pulled in rocm-opencl-runtime, which took a long time to compile locally, but I didn't care, cause at the end of the day everything worked. I was able to encode in hevc_amf with both ffmpeg and OBS (with the StreamFX plugin). It's also mentioned here https://github.com/GPUOpen-LibrariesAndSDKs/AMF/issues/250#issuecomment-1047215474 that hevc_amf did work with version 21.50

Everything worked fine for a short time, but then in early April version 22.10 came out and suddenly AMF stopped working completely. Ever since then I've been trying to get back my hevc_amf with only initial success. At the beginning I simply downgraded amf-amdgpu-pro lib32-vulkan-amdgpu-pro vulkan-amdgpu-pro and added them to my IgnorePkg in /etc/pacman.conf to stop these 3 packages from updating and hevc_amf continued to work for a time. But in around June or something (I don't remember clearly anymore), hevc_amf stopped working once again and this time no manner of downgrading helped me. This is where I'm at now.

  1. I've tried using the older PKGBUILD for version 21.50 (https://aur.archlinux.org/cgit/aur.git/commit/?h=amdgpu-pro-installer&id=0b96b26d151573777391c20882bf9be0b375b123), but it doesn't work anymore.
  2. I've tried this package https://aur.archlinux.org/pkgbase/amdgpu-pro-installer-fix which keeps vulkan-pro files from 21.40.2 and uses the rest of files from the latest version. Although this does restore h264_amf, hevc_amf still does not work. Although one thing I did notice is that the AUR package depended on rocm-opencl-runtime for version 21.50, but not 22.10. Regardless, hevc_amf doesn't work anymore with or without rocm-opencl-runtime so I decided to remove it.
  3. I've tried GloriousEggroll's solution manually (https://github.com/GPUOpen-LibrariesAndSDKs/AMF/issues/334#issuecomment-1181396676), but it works like the above and only restores h264_amf, not hevc_amf.
  4. I've tried modifying GloriousEggroll's solution by using the amf and libamdenc from 22.20 and then the vulkan-pro files from 21.50, (from http://repo.radeon.com/amdgpu/21.50.2/ubuntu/pool/proprietary/v/vulkan-amdgpu-pro/vulkan-amdgpu-pro_21.50.2-1384495_amd64.deb and http://repo.radeon.com/amdgpu/21.50.2/ubuntu/pool/proprietary/v/vulkan-amdgpu-pro/vulkan-amdgpu-pro_21.50.2-1384495_i386.deb), but this breaks both h264_amf and hevc_amf.

I would really love to get hevc_amf back, because I want to record videos at 4K 60fps, but vaapi turns the video into a slideshow at anything above 1080p 60fps, and h264_amf only produces a blurry mess even at a 30Mbit recording. Basically hevc_amf is the only option I had for recording video. CPU encoding at x264 works for less demanding cases, but it introduces a slight stutter to my entire desktop which is not visible in the recording or in mangohud, but I can clearly see it.

So... any word yet of hevc_amf?

For the record, this is the error that ffmpeg gives when I try to use hevc_amf with the amdgpu-pro-installer-fix AUR package:

VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/amd_pro_icd64.json ffmpeg -hwaccel auto -vaapi_device /dev/dri/renderD128 -y -loglevel verbose -i 'input.webm' -t 10 -map 0:v -c:v hevc_amf test.mkv 
ffmpeg version n5.1 Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 12.1.1 (GCC) 20220730
  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-librsvg --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --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-libzimg --enable-nvdec --enable-nvenc --enable-shared --enable-version3
  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
[AVHWDeviceContext @ 0x55649e271c80] libva: VA-API version 1.15.0
[AVHWDeviceContext @ 0x55649e271c80] libva: Trying to open /usr/lib/dri/radeonsi_drv_video.so
[AVHWDeviceContext @ 0x55649e271c80] libva: Found init function __vaDriverInit_1_15
[AVHWDeviceContext @ 0x55649e271c80] libva: va_openDriver() returns 0
[AVHWDeviceContext @ 0x55649e271c80] Initialised VAAPI connection: version 1.15
[AVHWDeviceContext @ 0x55649e271c80] VAAPI driver: Mesa Gallium driver 22.1.6 for AMD Radeon RX 6900 XT (sienna_cichlid, LLVM 14.0.6, DRM 3.42, 5.15.62-1-lts).
[AVHWDeviceContext @ 0x55649e271c80] Driver not found in known nonstandard list, using standard behaviour.
Input #0, matroska,webm, from 'input.webm':
  Metadata:
    ENCODER         : Lavf59.27.100
  Duration: 01:20:50.10, start: -0.007000, bitrate: 1240 kb/s
  Stream #0:0(eng): Video: vp9 (Profile 0), 1 reference frame, yuv420p(tv, bt709), 1920x1080, SAR 1:1 DAR 16:9, 29.97 fps, 29.97 tbr, 1k tbn (default)
    Metadata:
      DURATION        : 01:20:50.079000000
  Stream #0:1(eng): Audio: opus, 48000 Hz, stereo, fltp, delay 312 (default)
    Metadata:
      DURATION        : 01:20:50.101000000
[vp9 @ 0x55649e3c82c0] Using auto hwaccel type vaapi with existing device vaapi0.
Stream mapping:
  Stream #0:0 -> #0:0 (vp9 (native) -> hevc (hevc_amf))
Press [q] to stop, [?] for help
[graph 0 input from stream 0:0 @ 0x55649e4b2f00] w:1920 h:1080 pixfmt:nv12 tb:1/1000 fr:30000/1001 sar:1/1
[hevc_amf @ 0x55649e3a1ec0] AMF initialisation succeeded via Vulkan.
[hevc_amf @ 0x55649e3bb100] CreateComponent(AMFVideoEncoderHW_HEVC) failed with error 11
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
[AVIOContext @ 0x55649e3c3a00] Statistics: 0 bytes written, 0 seeks, 0 writeouts
[AVIOContext @ 0x55649e40aa80] Statistics: 65536 bytes read, 0 seeks
Conversion failed!

When using h264_amf instead of hevc_amf for -c:v it works without a problem.

Now when I try to launch OBS with the StreamFX plugin with VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/amd_pro_icd64.json:/usr/share/vulkan/icd.d/amd_pro_icd32.json OBS_USE_EGL=1 obs and record video with AMD AMF H.265/HEVC (via FFmpeg), I get the following entry in the logs:

10:19:12.458: Switched to profile 'Game 4K AMF' (Game_4K_AMF)
10:19:12.458: ------------------------------------------------
10:19:56.861: [StreamFX] [hevc_amf] Configuration:
10:19:56.861: [StreamFX] [hevc_amf]   FFmpeg:
10:19:56.861: [StreamFX] [hevc_amf]     Custom Settings: 
10:19:56.861: [StreamFX] [hevc_amf]     Standard Compliance: Normal
10:19:56.861: [StreamFX] [hevc_amf]     Threading: None (with 1 threads)
10:19:56.861: [StreamFX] [hevc_amf]   Video:
10:19:56.861: [StreamFX] [hevc_amf]     Input: 3840x2160 nv12 BT.709 Partial
10:19:56.861: [StreamFX] [hevc_amf]     Output: 3840x2160 nv12 BT.709 Partial
10:19:56.861: [StreamFX] [hevc_amf]     On GPU Index: -1
10:19:56.861: [StreamFX] [hevc_amf]     Framerate: 60/1 (60.000000 FPS)
10:19:56.861: [StreamFX] [hevc_amf]   Keyframes: 
10:19:56.861: [StreamFX] [hevc_amf]     Distance: 120 frames
10:19:56.861: [StreamFX] [hevc_amf]   AMD AMF:
10:19:56.861: [StreamFX] [hevc_amf]     Usage: transcoding <Default>
10:19:56.861: [StreamFX] [hevc_amf]     Preset: quality
10:19:56.861: [StreamFX] [hevc_amf]     Rate Control: vbr_peak
10:19:56.862: [StreamFX] [hevc_amf]       Look-Ahead: Disabled <Default>
10:19:56.862: [StreamFX] [hevc_amf]       Frame Skipping: Disabled <Default>
10:19:56.862: [StreamFX] [hevc_amf]       Filler Data: Disabled <Default>
10:19:56.862: [StreamFX] [hevc_amf]       Bitrate:
10:19:56.862: [StreamFX] [hevc_amf]         Target: 30000000 bits/sec
10:19:56.862: [StreamFX] [hevc_amf]         Maximum: 30000000 bits/sec
10:19:56.862: [StreamFX] [hevc_amf]         Buffer: 12000000 bits
10:19:56.862: [StreamFX] [hevc_amf]       Quantization Parameters:
10:19:56.862: [StreamFX] [hevc_amf]         I-Frame: -1  <Default>
10:19:56.862: [StreamFX] [hevc_amf]         P-Frame: -1  <Default>
10:19:56.862: [StreamFX] [hevc_amf]     Other:
10:19:56.862: [StreamFX] [hevc_amf]       Reference Frames: -1 Frames
10:19:56.862: [StreamFX] [hevc_amf]       Enforce HRD: Disabled <Default>
10:19:56.862: [StreamFX] [hevc_amf]       VBAQ: Disabled <Default>
10:19:56.862: [StreamFX] [hevc_amf]       Access Unit Delimiter: Disabled <Default>
10:19:56.862: [StreamFX] [hevc_amf]         Maximum Size: 0  <Default>
10:19:56.862: [StreamFX] [hevc_amf]       Half-Pel Motion Estimation: Enabled <Default>
10:19:56.862: [StreamFX] [hevc_amf]       Quarter-Pel Motion Estimation: Enabled <Default>
10:19:56.862: [StreamFX] [hevc_amf]     H.265/HEVC:
10:19:56.862: [StreamFX] [hevc_amf]       Profile: main <Default>
10:19:56.862: [StreamFX] [hevc_amf]       Level: auto <Default>
10:19:56.862: [StreamFX] [hevc_amf]       Tier: <Error: Operation not permitted>
10:19:57.003: [StreamFX] Unexpected exception in function '_create': Encoder not found.

Notice the last 2 lines. Of course, AMD AMF H.264/AVC works, but it does not produce good results.

MikhailAMD commented 2 years ago

In general, AMF supports only distros supported by AMD GFX driver and driver installation script: Driver: https://www.amd.com/en/support/linux-drivers Installation: https://amdgpu-install.readthedocs.io/en/latest/install-installing.html#installing-the-workstation-use-case Command line adding AMF would be: $ amdgpu-install -y --usecase=workstation,amf From the log it seems you have older AMF SO lib without AMF HEVC component or older Vulkan driver. Note, that mix and match different versions of driver, Vulkan and AMF is not a good idea. Also latest scripts and AMF made OpenCL stack optional.

DiarrheaMcgee commented 2 years ago

hevc doesnt work for me either but give it a few months and it will likely fix itself unfortunately there is no guarantee that it will work at all because there is only "official support" for well known distros like ubuntu and rhel and such although that doesnt make sense because arch is very popular

aruraune commented 2 years ago

I apologize if this doesn't fit here but if mixing components from different drivers is dangerous and not a good idea, shouldn't we all try to work towards a solution that doesn't require this rather than dismissing the problem as user fault?

For starters, is this just specific to Arch Linux or is it happening even under officially supported distros?

Have anyone actually tested and could confirm if hevc_amf on 6000 series actually works on the officially supported setup? 4k recording is already niche enough on top of doing that under Linux with expensive-ish (AMD) hardware.

If it works, is there any way we could run OBS in a systemd-nspawn or similar and get HEVC_AMF to work? Or are only host systems supported?

Also, for someone willing to test: Are there any live cd or similar that is officially supported or compatible that I could use to test if HEVC_AMF works on my GPU and give feedback here?

MikhailAMD commented 2 years ago

Obviously, AMD tests AMF on all supported distros. Please report issues here.

aruraune commented 2 years ago

Quoting OP who seems to have tested the install script on a supported distro.

but I can also reproduce the issue on Ubuntu 20.04 LTS which is a supported distro for AMF.

Along with your reply. I understand that we can take it as the bug is acknowledged and being investigated then?

bluestang2006 commented 2 years ago

Obviously, AMD tests AMF on all supported distros. Please report issues here.

Any plans to support other distros - i.e. Fedora?

The OP mentioned that this specific issue was duplicated on a supported distro...yet his issue has not been resolved and instead has been ignored.

Besides AMF, the latest proprietary drivers do not work for certain games. i.e. - DoomEternal, Control

The installation script installs a bunch of unnecessary files if someone just wants the pro vulkan drivers only, which is an option within the script.

MikhailAMD commented 2 years ago

This place is dedicated to AMF SDK support. AMF is part of the driver, rely on the driver parts so the distro support is beyond AMF team to decide.

GloriousEggroll commented 2 years ago

Good news -- issue resolved!

We (Nobara) dug around the packaging and found that libdrm-amdgpu libraries are needed in addition to the libamf, libamdfrt, libamdenc, and vulkan libraries. Additionally on fedora the opencl-filesystem package was needed. After this I now have fully working H264 and H265 encode on two different RDNA2 systems with the most up-to-date driver stack (no more vulkan legacy drivers for 6000+ series).

jarrard commented 2 years ago

Until mainline packages are fixed; it still broken.

GloriousEggroll commented 2 years ago

Until mainline packages are fixed; it still broken.

its not broken in AMD's driver stack when the full stack is used, and they dont provide packages for fedora or arch so this isn't their problem. As they mentioned its a problem when you start disecting and using parts of the stack without others. We had to find the missing parts (libdrm and the opencl-filesytem package). It should be noted on Fedora the opencl-filesystem package just creates an empty directory needed for opencl applications at /etc/OpenCL/vendors -- this can be done within the pre-existing packaging for other distros.

jarrard commented 2 years ago

Ok, well hopefully somebody can update those Arch repo's (and/or AUR) to have it fully working without manually copying files around to fix problems.

hannesmann commented 2 years ago

Tried out the latest driver on Arch again and the issue seems to have fixed itself (without using libdrm from AMD). I'm not sure why, but I suspect it's because linux-firmware got an update that picked up this commit: amdgpu: update navy flounder to release 22.20. Mikhail mentioned something about a mismatch between the driver and VCN firmware version, so maybe I was running outdated firmware.

its not broken in AMD's driver stack when the full stack is used

Strange, I wonder why it was broken when I tested it on Ubuntu 20.04. I was running it off a USB but I'm pretty sure I restarted the system after installing Radeon Software.

kerriganx commented 2 years ago

Tried out the latest driver on Arch again and the issue seems to have fixed itself (without using libdrm from AMD). I'm not sure why, but I suspect it's because linux-firmware got an update that picked up this commit: amdgpu: update navy flounder to release 22.20. Mikhail mentioned something about a mismatch between the driver and VCN firmware version, so maybe I was running outdated firmware.

its not broken in AMD's driver stack when the full stack is used

Strange, I wonder why it was broken when I tested it on Ubuntu 20.04. I was running it off a USB but I'm pretty sure I restarted the system after installing Radeon Software.

Could you help what packages are you using? I have no sucess with amf-amdgpu-pro from aur.

hannesmann commented 2 years ago

Could you help what packages are you using? I have no sucess with amf-amdgpu-pro from aur.

Hmm, seems 22.10 is still broken... I think this issue was fixed by a combination of the 22.20 driver and the recent firmware update.

I submitted a PR so that the AUR package can be updated: https://github.com/Ashark/archlinux-amdgpu-pro/pull/78. To build it yourself download this and run makepkg in the extracted directory.

If others aren't still having issues I think this can be closed now.

jarrard commented 2 years ago

does launching OBS with _OBS_USE_EGL=1 vkpro obs still work fine?

doesn't appear to work for me.

NVM: Obs is broken for me, something must have broke in update. Damn

Got it working again. Had to ditch obs-studio from aur as it uses Qt6 now which no plugins support. But unfortunately AMFx265 doesn't exist for me, only AMF264. I seem to get all the problems nobody else has.

Well got the AUR of OBS studio working again, had to recompile several things it seems. However only AMD AMF H.264/AVC via FFmpeg shows up in the list. No 265. :(

I think its because obs-hevc-vaapi-git is broken (fix doesn't work) and thus I have that missing. Think I'll just steer clear of this WHOLE AMD AMF stuff and go nvidia whenever I get the chance, this is just too much to deal with.

kik4444 commented 2 years ago

does launching OBS with _OBS_USE_EGL=1 vkpro obs still work fine?

doesn't appear to work for me.

NVM: Obs is broken for me, something must have broke in update. Damn

Got it working again. Had to ditch obs-studio from aur as it uses Qt6 now which no plugins support. But unfortunately AMFx265 doesn't exist for me, only AMF264. I seem to get all the problems nobody else has.

Well got the AUR of OBS studio working again, had to recompile several things it seems. However only AMD AMF H.264/AVC via FFmpeg shows up in the list. No 265. :(

I think its because obs-hevc-vaapi-git is broken (fix doesn't work) and thus I have that missing. Think I'll just steer clear of this WHOLE AMD AMF stuff and go nvidia whenever I get the chance, this is just too much to deal with.

Are you using OBS with this StreamFX plugin https://github.com/Xaymar/obs-StreamFX ? That's the only way I've ever been able to get OBS to use AMF of either kind.

jarrard commented 2 years ago

EDIT: Not going to bother figuring it out.

tedliosu commented 2 years ago

Tried out the latest driver on Arch again and the issue seems to have fixed itself (without using libdrm from AMD). I'm not sure why, but I suspect it's because linux-firmware got an update that picked up this commit: amdgpu: update navy flounder to release 22.20. Mikhail mentioned something about a mismatch between the driver and VCN firmware version, so maybe I was running outdated firmware.

its not broken in AMD's driver stack when the full stack is used

Strange, I wonder why it was broken when I tested it on Ubuntu 20.04. I was running it off a USB but I'm pretty sure I restarted the system after installing Radeon Software.

It's the firmware at least on my system; after I sudo -H cp --verbose -t /lib/firmware/amdgpu /usr/src/amdgpu-5.16.9.22.20-1462319~20.04/firmware/amdgpu/*, sudo -H update-initramfs -u -k all, and rebooted the machine the AMF samples started working on my Ubuntu 20.04 machine!! Everything I tried before that failed to make a difference so I'm pretty sure the firmware "update" that I forced fixed it :D

IDK about the full extent of the consequences of tampering with system firmware though... :eyes:

jarrard commented 2 years ago

Think I managed to fix my AMF issues by using the default OBS studio... I was using OBS-studio-browser from AUR which is meant to incorporate twitch chat and some other plugins (they worked). Guess I'll just need to look for another solution at getting those missing windows OBS features on Linux....

PS. I WISH Twitch would support x265 or VP9 already! man that be nice!

kerriganx commented 2 years ago

It looks like recent Arch linux-firmware update just broke it again. Anyone experience the same?

tedliosu commented 2 years ago

It looks like recent Arch linux-firmware update just broke it again. Anyone experience the same?

I know this links to deb packages which aren't natively supported by Arch, but you might want to have a go at the packages beginning with "amdgpu-dkms-firmware" hosted here; the link is to a directory containing the second-latest firmware distributed directly by AMD as of the time I'm writing this (I didn't link the latest version as they were just released today and I haven't tested them on my machine yet). Hopefully once you extract the firmware files from the deb package (try the one for Ubuntu 20.04 first as that's what I'm running and works for me), place them in the appropriate directory (sorry I'm not sure what it is on Arch all I know is Ubuntu), and then reboot things will be fixed for you. 😄

EDIT: Also sorry I almost forgot to mention that one might have to "update-initramfs" before rebooting for the firmware to be loaded properly into the OS upon reboot.

tedliosu commented 2 years ago

It looks like recent Arch linux-firmware update just broke it again. Anyone experience the same?

Yep, I just tried using the latest firmware distributed directly by AMD through "repo.radeon.com" and it broke AMF again on my machine :confused: So I reverted back to the firmware that I linked to above and everything was peachy again :smile: So yea just stick to the firmware that I previously linked to in my previous comment here for now and you hopefully should be good :+1:

CosmicFusion commented 2 years ago

It looks like recent Arch linux-firmware update just broke it again. Anyone experience the same?

Yep, I just tried using the latest firmware distributed directly by AMD through "repo.radeon.com" and it broke AMF again on my machine confused So I reverted back to the firmware that I linked to above and everything was peachy again smile So yea just stick to the firmware that I previously linked to in my previous comment here for now and you hopefully should be good +1

the firmware in 22.20.3 works like a charm, do not use the 5.3 repos it's a weird test repo , and it also lacks proprietary packages including amf , so there's no incentive over there to ship amf firmware, stick to relases that can be found on their website, and also they will 100% fix it sooner or later as NAVI3 GPUs need newer firmware , and by not fixing new relases they will break their own official distros

CosmicFusion commented 1 year ago

It looks like recent Arch linux-firmware update just broke it again. Anyone experience the same?

Yep, I just tried using the latest firmware distributed directly by AMD through "repo.radeon.com" and it broke AMF again on my machine confused So I reverted back to the firmware that I linked to above and everything was peachy again smile So yea just stick to the firmware that I previously linked to in my previous comment here for now and you hopefully should be good +1

the firmware in 22.20.3 works like a charm, do not use the 5.3 repos it's a weird test repo , and it also lacks proprietary packages including amf , so there's no incentive over there to ship amf firmware, stick to relases that can be found on their website, and also they will 100% fix it sooner or later as NAVI3 GPUs need newer firmware , and by not fixing new relases they will break their own official distros

and as i said sooner or later everything is gonna be fixed, AMD finally made the 5.X.X repositories complete and with proprietary packages, and as expected the firmware there works on all devices perfectly