Open jamie-pate opened 3 years ago
one possible option is to copy the texture using EGL or similar? http://wiki.100ask.org/EGL_texture_0-copy
mpv player looks like a good example using ffmpeg
https://github.com/mpv-player/mpv/blob/80c4aaa2a4e7ada6530ad4f16172283cd82fcc1d/libmpv/render_gl.h#L133 Seems like mpv can render directly to hw contexts https://github.com/mpv-player/mpv/blob/802f594a857c703ac88e946d14b69cd3b6eb6006/video/out/opengl/hwdec_dxva2egl.c#L320 https://github.com/mpv-player/mpv/blob/172146e9f7a231b5de21921d883612d18b13a717/video/decode/vd_lavc.c
Something something framebuffers https://learnopengl.com/Advanced-OpenGL/Framebuffers
For linux, looks like we'd need both of these: https://wiki.debian.org/HardwareVideoAcceleration (prefer VA-API except with NVIDIA proprietary drivers)
VA-API - Supported on Intel, AMD, and NVIDIA (only via the open-source Nouveau drivers). Widely supported by software, including Kodi, VLC, MPV, Chromium, and Firefox. Main limitation is lacking any support in the proprietary NVIDIA drivers.
VDPAU - Supported fully on AMD and NVIDIA (both proprietary and Nouveau). Supported by most desktop applications like Kodi, VLC, and MPV, but has no support at all in Chromium or Firefox. Main limitations are poor and incomplete Intel support and not working with browsers for web video acceleration.
Considerations with libva which includes binary blobs (shouldn't be an issue as long as we avoid GPL licensing) https://github.com/intel/libva/issues/118
I'd love to add this but it seems like unless we can figure out a 0-copy mechanism to get the texture into Godot using a native format this would not improve performance appreciably. Only QSV decoding seemed to have a small benefit when dumping raw frames to a null device (NUL, /dev/null) on slower cpus. Please contribute any findings to this thread if you can find a case where rawvideo is improved by hardware device decoding.
Additionally, should test with
-pix_fmt rgb32
before-f rawvideo
as that would perform the rgb32 conversion required to show the frames in godot.The last result in this table shows the expected result, 173fps vs 169fps and reduced the cpu load from 37% to 33%
windows build was https://github.com/BtbN/FFmpeg-Builds/releases 2020-11-23 (shared-vulkan when possible)