h.264 with LibVA (Intel or AMD) not availlable

Started by msta, March 13, 2021, 12:20:07 AM

Previous topic - Next topic

msta

Hello,
I read, Avidemux supports LibVA. I have an Intel Xeon E3-1505M and AMD 7150. vainfo gives me:
xxxxx:/home/Projekte/Cpp/avidemux2$ vainfo --display drm --device /dev/dri/renderD128
libva info: VA-API version 1.7.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_7
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.7 (libva 2.6.0)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 20.1.1 ()
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSliceLP
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSliceLP
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointEncPicture
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
      VAProfileVP8Version0_3          : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileVP9Profile0            : VAEntrypointVLD
      VAProfileVP9Profile2            : VAEntrypointVLD
xxxxx:/home/Projekte/Cpp/avidemux2$ vainfo --display drm --device /dev/dri/renderD129
libva info: VA-API version 1.7.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/radeonsi_drv_video.so
libva info: Found init function __vaDriverInit_1_7
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.7 (libva 2.6.0)
vainfo: Driver version: Mesa Gallium driver 20.2.6 for AMD TONGA (DRM 3.35.0, 5.4.0-66-generic, LLVM 11.0.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
      VAProfileNone                   : VAEntrypointVideoProc

I can use both GPUs in OBS. I tried building avidemux2 on my own using
bash bootStrap.bash --with-system-libass --with-system-liba52 --with-system-libmad

But I still don't get any hardware accelerated option. Only Mpeg4 ASP (ff), Mpeg4 ASP (xvid), Mpeg4 AVC (x264). I think, there should be something like Mpeg4 QVC (InteI) in the list of codecs, right?

What's wrong?

eumagga0x2a

There should be an "Intel H264" encoder in the list. Please post the output of Avidemux when launched in the Terminal.

msta

Good Idea. I attached the output, because it is too long for one post :-/

There are several errors like LibVA Error : <vaGetConfigAttributes(ADM_coreLibVA::display, profile, VAEntrypointVLD, &attrib, 1):the requested VAProfile is not supported:12>

eumagga0x2a

Avidemux looks for VAEntrypointEncSlice being supported, it is not in the list (the list contains VAEntrypointEncSliceLP, however). Apart from that, uploading an image to hw surface fails, so even if encoder were available, we couldn't pass anything to it.

msta

So what's the problem? Is my hardware missing some necessary functions?

What is OBS doing differently?

eumagga0x2a

I was focused on encoding, but hw accelerated decoding should work. Was Intel driving the display as you ran Avidemux, creating the log?

Quote from: msta on March 14, 2021, 07:22:17 AMWhat is OBS doing differently?

Probably it can pass hw surfaces directly to encoder without going through main memory and also use VA-API on a GPU without display. Only guessing here.

msta

#6
Yes, Intel was driving the display but good Idea: I tried running avidemux on the AMD-GPU, but it crashes after just a few milliseconds.

What I should mention: This is a Server-GPU with no display configuration. I cannot activate this GPU in BIOS for direct output, as this would disable all external display connections. This GPU is not fully compatible with my laptop, but I didn't find a compatible GPU. The AMD 7100 is not available. Bought one from China, which doesn't work. An other used one in Germany, which doesn't work, too. The Dell Support want 1500€ for this, so I keep using the server GPU.

eumagga0x2a

According to the log, Avidemux still tried to use the Intel GPU. Probing indirect upload to hw surface (vaPutImage()) triggered a crash in the driver. As indirect operation seems to be not viable anyway, please try whether avoiding it alltogether fixes at least the crash:

diff --git a/avidemux_core/ADM_coreVideoCodec/ADM_hwAccel/ADM_coreLibVA/src/ADM_coreLibVA.cpp b/avidemux_core/ADM_coreVideoCodec/ADM_hwAccel/ADM_coreLibVA/src/ADM_coreLibVA.cpp
index 02d22750c..6b942b91e 100644
--- a/avidemux_core/ADM_coreVideoCodec/ADM_hwAccel/ADM_coreLibVA/src/ADM_coreLibVA.cpp
+++ b/avidemux_core/ADM_coreVideoCodec/ADM_hwAccel/ADM_coreLibVA/src/ADM_coreLibVA.cpp
@@ -134,20 +134,25 @@ static bool checkSupportedFunctionsAndImageFormat(void)
    // Check direct upload/Download works
    ADM_info("--Trying direct operations --\n");
    ADM_coreLibVA::directOperation      =tryDirect("direct",admSurface, image1,  image2);
+#if 0
    ADM_info("-- Trying indirect (YV12) --\n");
    ADM_coreLibVA::indirectOperationYV12=tryIndirect(0,admSurface, image1 ,image2);
    ADM_info("-- Trying indirect (NV12) --\nSKIPPED\n");
    ADM_coreLibVA::indirectOperationNV12=false; //tryIndirect(1,admSurface, image1, image2 );
-
+#endif
    ADM_info("Direct          : %d\n",ADM_coreLibVA::directOperation);
+#if 0
    ADM_info("Indirect NV12    : %d\n",ADM_coreLibVA::indirectOperationNV12);
    ADM_info("Indirect YV12    : %d\n",ADM_coreLibVA::indirectOperationYV12);
+#endif
    if(ADM_coreLibVA::directOperation)
        ADM_coreLibVA::transferMode=admLibVA::ADM_LIBVA_DIRECT;
+#if 0
    else if(ADM_coreLibVA::indirectOperationYV12)
        ADM_coreLibVA::transferMode=admLibVA::ADM_LIBVA_INDIRECT_YV12;
    else if(ADM_coreLibVA::indirectOperationNV12)
        ADM_coreLibVA::transferMode=admLibVA::ADM_LIBVA_INDIRECT_NV12;
+#endif
    else
    {
          ADM_warning("Did not find a usable way to transfer images to/from LibVA\n");

eumagga0x2a

Regarding probing for VA-API encoding capabilities, please try whether

diff --git a/avidemux_core/ADM_coreVideoEncoder/ADM_hwAccelEncoder/ADM_coreLibVAEnc/src/ADM_coreLibVA_encodingContext.cpp b/avidemux_core/ADM_coreVideoEncoder/ADM_hwAccelEncoder/ADM_coreLibVAEnc/src/ADM_coreLibVA_encodingContext.cpp
index 28b6e0337..ef108a8f2 100644
--- a/avidemux_core/ADM_coreVideoEncoder/ADM_hwAccelEncoder/ADM_coreLibVAEnc/src/ADM_coreLibVA_encodingContext.cpp
+++ b/avidemux_core/ADM_coreVideoEncoder/ADM_hwAccelEncoder/ADM_coreLibVAEnc/src/ADM_coreLibVA_encodingContext.cpp
@@ -99,7 +99,8 @@ static bool  lookupSupportedFormat(VAProfile profile)
     vaQueryConfigEntrypoints(admLibVA::getDisplay(), profile, entrypoints, &num_entrypoints);
     for (int slice_entrypoint = 0; slice_entrypoint < num_entrypoints; slice_entrypoint++)
     {
-        if (entrypoints[slice_entrypoint] == VAEntrypointEncSlice)
+        if (entrypoints[slice_entrypoint] == VAEntrypointEncSlice ||
+            entrypoints[slice_entrypoint] == VAEntrypointEncSliceLP)
         {
             return true;
         }

allows to use FFmpeg-based "Intel H264" and eventually "Intel HEVC" encoders (the "Intel AVC HW (VA)" one will be broken as it expects VAEntrypointEncSlice to be available).

msta

#9
Sorry, I somehow failed to apply the patch using git and did it by hand. Now, I built avidemux and run it with and without DRI_PRIME=1. Both fails. I hope, the output is helpful for you.