msys2 / MINGW-packages

Package scripts for MinGW-w64 targets to build under MSYS2.
https://packages.msys2.org
BSD 3-Clause "New" or "Revised" License
2.22k stars 1.19k forks source link

Add gstreamer-vaapi #17140

Open ksvert opened 1 year ago

ksvert commented 1 year ago

Package name

gstreamer-vaapi

Brief description of package

VA-API-based decoder, encoder, postprocessing and video sink elements for GStreamer.

URL for package's homepage

https://gstreamer.freedesktop.org/modules/gstreamer-vaapi.html

Provide a basic test case to validate the package's functionality.

Launch some video with vaapidecodebin: gst-launch-1.0 filesrc location=~/big_buck_bunny.mov ! qtdemux ! h264parse ! vaapidecodebin ! vaapisink

MINGW environments where you need the package

Are you willing to submit a PR?

No response

Biswa96 commented 1 year ago

Does gstreamer-vaapi support native Windows platform? I get the following error using meson build command.

meson.build:153:2: ERROR: Problem encountered: No renderer API found (it is requried either DRM, X11 and/or WAYLAND)
driver1998 commented 1 year ago

Is dx12 va-api in msys2 now?

Biswa96 commented 1 year ago

I am not sure what that means. There is a libva package https://packages.msys2.org/base/mingw-w64-libva. Do you mean that one? Is it related to gstreamer-vaapi?

driver1998 commented 1 year ago

yeah, libva and also the VaOn12 va-api driver in mesa.

https://devblogs.microsoft.com/directx/video-acceleration-api-va-api-now-available-on-windows/

Since libva 2.17 a new libva-win32 node was added to enable support on Windows platforms and provide VA-API acceleration from any chosen GPU adapter. Since Mesa 22.3 the same VA-API driver used in WSL can be compiled for Windows, and we named it VAOn12. Implemented on top of the D3D12 Video APIs, provides cross-hardware-vendor VA-API acceleration.

Biswa96 commented 1 year ago

How that can help gstreamer-vaapi? Or is it not even required in Windows?

ksvert commented 1 year ago

In gstreamer-vaapi package description it's not mentioned if it works on windows or not. But for example here: https://gstreamer.freedesktop.org/releases/gstreamer-vaapi/1.8.0.html binaries for windows are mentioned so it should work (unless they mean gstreamer binaries in general and not specifically for vaapi).

I just now came across information about DXVA in GStreamer and it looks like it uses it as VA-API on windows (libraries should be already included in bad-plugins package): https://gstreamer.freedesktop.org/documentation/d3d11/d3d11h264dec.html So maybe it's not required.

Biswa96 commented 1 year ago

So maybe it's not required.

Can this issue be closed now?

ksvert commented 1 year ago

It would be great to have gstreamer-vaapi as d3d11 doesn't have encoders, but i'm still not sure if it's supported on windows or not.

driver1998 commented 1 year ago

It might work with the Windows VA-API driver mentioned above. I don't think this is tested by anybody though.

dvrogozh commented 1 year ago

VAAPI is in uAPI for hardware accelerated media codecs (decoders, encoder and video processing) used primarily for Intel Gen graphics though some other vendors did use it as well, for example, AMD. VAAPI is exposed via https://github.com/intel/libva which is a small "dispatching" library, i.e. it just defines uAPI, some key functions and its major goal is to load a driver. I.e. to make things work at the first place you need to have combination of libva + driver.

Libva initially was Linux uAPI and on Windows Intel used (and still uses) DXVA + custom extensions (for encoders). Though this is starting to change now with DX12 which has some encoders API. However, recently Libva was ported to Windows (starting from 2.18), see [1]. It works with 2 pieces: 1) libva library itself was ported (and that's why you see msys2 *-libva package), 2) plus vaon12 mesa gallium driver was provided. vaon12 driver is layered driver which means that it actually maps DX12 API calls to VAAPI calls. So, features exposed by VAAPI would be shrinked by what DX12 actually support + what got mapped in vaon12 implementation + what fallback was provided on mesa level (for some video processing operations shaders are used).

So, libva+vaon12 now opens a door to have VAAPI acceleration on Windows. However, don't assume that ffmpeg-vaapi and gstreamer-vaapi would be workable as is. Some enabling effort is required to make them work. Such work was done for ffmpeg-vaapi, see https://github.com/FFmpeg/FFmpeg/commit/d54127c41a81cf2078a3504f78e0e4232cfe11b7, and we basically are waiting ne release, n6.1 to be able to connect the dots, i.e. enable ffmpeg-vaapi withing msys2 ffmpeg package build. As for the gstreamer-vaapi I don't know whether enabling was actually done. Thus, before this package request will become valid, there is need to be a request to gstreamer-vaapi to actually enable support on Windows + release it.

As for ffmpeg-vaapi it's much closer to be enabled on msys2 level. I noted that we need new ffmpeg release for that. In a meanwhile there are few things which needs to be done on msys2 level for the full experience:

  1. https://github.com/msys2/MINGW-packages/pull/17421 - this will eliminate a crash in vaon12 due to missing dxil.dll
  2. https://github.com/msys2/MINGW-packages/pull/17468 - some video codecs need to be enabled in mesa build explicitly (h264, h265, etc.) - they are off by default
  3. https://github.com/msys2/MINGW-packages/pull/17455 - vainfo needs to be packaged - that's simple application lists available VAAPI entrypoints

[1] https://devblogs.microsoft.com/directx/video-acceleration-api-va-api-now-available-on-windows/

dvrogozh commented 1 year ago

Thus, before this package request will become valid, there is need to be a request to gstreamer-vaapi to actually enable support on Windows + release it.

Looking into gstreamer repo, I see that enabling effort was actually completed: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/commit/c1946c02092a2bb486105f3f5f71cc42743b8a1e. It is not yet included into any release though, same as for ffmpeg.

So, ffmpeg-vaapi and gstreamer-vaapi are currently in same state: we need releases.

lazka commented 8 months ago

New ffmpeg with vaapi is here: #19050 But I get crashes in dxva2, so blocked for now.

edit: fixed