Closed philipl closed 3 months ago
AMD on Windows appears to be 5000/6000 series according to https://www.amd.com/en/support/kb/release-notes/rn-rad-win-22-11-2-vlk-video-code-decode (possibly 7000 works?). It doesn't work on Polaris: 0.339][e][ffmpeg/video] h264: Device does not support the VK_KHR_video_decode_queue extension!
After bc28dce303a4abcc8ec2f1fd941bc1bfd02e6f79, you need to patch your Mesa with this PR to get AV1 decoding on radv.
Reliably crashes driver for me with this sample: https://0x0.st/HbHJ.mkv Other files seem to work for whatever reason (hwdec beeing used confirmed). Latest git-master of mpv, libplacebo, ffmpeg and radv on 6700 xt.
Sounds like you probably need to file a mesa issue for that - and even if it was an mpv issue, please open a separate one. This FAQ isn't the place to report it.
@aufkrawall AMD currently needs https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23227 to avoid crashes, which also fixes quite a lot of bugs
(+) Video --vid=1 (*) (hevc 3828x1592 23.976fps)
(+) Audio --aid=1 --alang=eng (*) (eac3 6ch 48000Hz)
Subs --sid=1 --slang=eng (subrip)
Subs --sid=2 --slang=eng 'SDH' (subrip)
Subs --sid=3 --slang=fre (subrip)
[vo/gpu-next/libplacebo] vk->CreateDevice(vk->physd, &dinfo, PL_VK_ALLOC, &vk->dev): VK_ERROR_OUT_OF_HOST_MEMORY (../../../../../src_packages/libplacebo/src/vulkan/context.c:1308)
[vo/gpu-next/libplacebo] Failed creating logical device!
[vo/gpu-next/libplacebo] Failed initializing vulkan device
[vo/gpu-next] Failed initializing any suitable GPU context!
Error opening/initializing the selected video_out (--vo) device.
Video: no video
what does this error mean, my device has amd and i used the following config
mpv --vo=gpu-next --gpu-api=vulkan --hwdec=vulkan --gpu-context=winvk
mpv was working fine with gpu-next and gpu-api=vulkan till yesterdays' shinchiro release. todays release gave me this error
maybe @shinchiro needs to bump libplacebo and ffmpeg version as per required?
AMD on Windows Special 22.11.2 drivers with video decoding support Hardware supported by those drivers (documented as 5000/6000 series. Apparently not newer 7000 series)
I don't know if that specific driver is required, they may have been included in 23.2.1 where they added other extensions, the driver notes aren't clear. 7000 series wasn't launched when the 22-11-2 Vulkan video drivers were released so that driver doesn't officially support them. If they did include the video extensions in newer drivers then they may support 7000 series but someone with those GPUs will need to test.
Yeah, I've reported to nvidia months ago that their descriptor buffer implementation is broken, but they haven't fixed it yet. If you want filters working, ask nvidia to fix it.
I found this video will white screen when using ffmpeg vulkan decoding, SW decoding or nvpro vk_video_decoder have no problem, I don't know if this is also NVIDIA's problem (also already reported to NVIDIA) test.mp4
Github claims you attached an audio-only file...
That file is also broken on anv, it's glitchy and the decode is very slow while utilizing 100% of Render/3D engine.
That file is also broken on anv, it's glitchy and the decode is very slow while utilizing 100% of Render/3D engine.
It's an HEVC file. My experience on ANV is that any HEVC playback pegs the GPU at 100%
Also:
[ffmpeg/video] hevc: First slice in a frame missing.
This is a highly questionable sample.
Will this work with hasvk in the future? I tried using it through wine (I dont want to have to compile everything) and got this error [ffmpeg/video] h264: Device does not support the VK_KHR_video_decode_queue extension!
even though the output of vulkaninfo is:
vulkaninfo | grep video ✔ 10s
VK_KHR_video_decode_h264 : extension revision 8
VK_KHR_video_decode_queue : extension revision 7
VK_KHR_video_queue : extension revision 8
videoCodecOperations:
videoCodecOperations: count = 1
NVIDIA 1650 Super, Tested on windows with: mpv --vo=gpu-next --gpu-api=vulkan --hwdec=vulkan --gpu-context=winvk 5 videos played OK.
This video has problem: https://4kmedia.org/sony-whale-in-tonga-hdr-uhd-4k-demo/ Switched back to hwdec=nvdec, the problem is gone.
for fedora, you need to edit mesa.spec and rebuild with codecs enabled -D video-codecs=h264dec,h264enc,h265dec,h265enc,vc1dec
, codecs is disabled by default.
https://github.com/rpmfusion-infra/fedy/issues/110
https://themaister.net/blog/2023/01/05/vulkan-video-shenanigans-ffmpeg-radv-integration-experiments/
https://forum.endeavouros.com/t/compiling-mesa-22-2-with-codec-support-the-easy-way/30390
works well with intel 11th gen igpu
for those @lavilao with
[ffmpeg/video] h264: Device does not support the VK_KHR_video_decode_queue extension!
make sure to enable mesa video codecs as stated here: https://themaister.net/blog/2023/01/05/vulkan-video-shenanigans-ffmpeg-radv-integration-experiments/ https://forum.endeavouros.com/t/compiling-mesa-22-2-with-codec-support-the-easy-way/30390(small bug: pressing Ctrl+H will toggle vaapi instead of vulkan)
I enabled them. Check the vulkaninfo log, it shows the extension but mpv does not recognizes it. This is what I used to compile it
meson .. --reconfigure -D b_lto=true -D b_pgo=off -D platforms=x11,wayland -D buildtype=release -D prefix="$HOME/anv-master-video" --libdir="$HOME/anv-master-video/lib" -D b_ndebug=true -D gallium-drivers= -D vulkan-drivers=intel_hasvk -D gles1=disabled -D gles2=disabled -D opengl=false -D video-codecs=h264dec,h264enc,h265dec -D vulkan-beta=true
@lavilao i assume you're using Shinchiro's windows build? I haven't tried using mpv through wine, you may need to recompile.
(+) Video --vid=1 (*) (hevc 3840x1608 24.000fps)
(+) Audio --aid=1 --alang=chi (*) (eac3 6ch 48000Hz)
Audio --aid=2 --alang=chi (*) (aac 2ch 44100Hz)
[vo/gpu-next/libplacebo] Missing device feature: dynamicRendering
[vo/gpu-next/libplacebo] Vulkan device does not support all required features!
[vo/gpu-next/libplacebo] Failed creating logical device!
[vo/gpu-next/libplacebo] Failed initializing vulkan device
[vo/gpu-next] Failed initializing any suitable GPU context!
Error opening/initializing the selected video_out (--vo) device.
Video: no video
what does this error mean, my device has intel gpu, and i used the following config
mpv --vo=gpu-next --gpu-api=vulkan --hwdec=vulkan --gpu-context=winvk
using the latest shinchiro release.
Intel on Windows does not support Vulkan hwdec, read the OP
Might be mistaken, but this appears to have allowed zero copy hwacceleration on my polaris on radv. seems like preformance is a bit better too
@lavilao i assume you're using Shinchiro's windows build? I haven't tried using mpv through wine, you may need to recompile.
I recompiled on a arch distrobox and the good news is it detects it. The bad news are that the logs show a driver bug:
(+) Video --vid=1 (*) (h264 1278x720 30.000fps)
(+) Audio --aid=1 --alang=eng (*) (opus 2ch 48000Hz)
[vo/gpu-next/wayland] GNOME's wayland compositor lacks support for the idle inhibit protocol. This means the screen can blank during playback.
MESA-INTEL: warning: ../src/intel/vulkan_hasvk/anv_formats.c:784: FINISHME: support more multi-planar formats with DRM modifiers
Using hardware decoding (vulkan).
AO: [pulse] 48000Hz stereo 2ch float
VO: [gpu-next] 1278x720 vulkan[nv12]
[vo/gpu-next/libplacebo] vkQueueSubmit2: VK_ERROR_DEVICE_LOST (../src/vulkan/command.c:358)
[vo/gpu-next] Failed presenting frame!
[vo/gpu-next/libplacebo] vkQueueSubmit2: VK_ERROR_DEVICE_LOST (../src/vulkan/command.c:358)
[vo/gpu-next/libplacebo] Retrieving query pool results: VK_ERROR_DEVICE_LOST (../src/vulkan/gpu.c:103)
[vo/gpu-next/libplacebo] vkQueueSubmit2: VK_ERROR_DEVICE_LOST (../src/vulkan/command.c:358)
[vo/gpu-next/libplacebo] vkQueueSubmit2: VK_ERROR_DEVICE_LOST (../src/vulkan/command.c:358)
[vo/gpu-next/libplacebo] vkQueueSubmit2: VK_ERROR_DEVICE_LOST (../src/vulkan/command.c:358)
[vo/gpu-next/libplacebo] Retrieving query pool results: VK_ERROR_DEVICE_LOST (../src/vulkan/gpu.c:103)
[vo/gpu-next/libplacebo] vkQueueSubmit2: VK_ERROR_DEVICE_LOST (../src/vulkan/command.c:358)
[vo/gpu-next/libplacebo] Failed holding swapchain image for presentation
[vo/gpu-next] Failed presenting frame!
AV: 00:00:00 / 00:08:13 (0%) A-V: 0.000
[ffmpeg] av_log callback called with bad parameters (NULL AVClass).
[ffmpeg] This is a bug in one of Libav/FFmpeg libraries used.
[ffmpeg] Unable to submit command buffer: VK_ERROR_DEVICE_LOST
[ffmpeg/video] h264: get_buffer() failed
[ffmpeg/video] h264: decode_slice_header error
[ffmpeg/video] h264: no frame!
Error while decoding frame (hardware decoding)!
[ffmpeg] av_log callback called with bad parameters (NULL AVClass).
[ffmpeg] This is a bug in one of Libav/FFmpeg libraries used.
[ffmpeg] Unable to submit command buffer: VK_ERROR_DEVICE_LOST
[ffmpeg/video] h264: get_buffer() failed
[ffmpeg/video] h264: decode_slice_header error
[ffmpeg/video] h264: no frame!
Error while decoding frame (hardware decoding)!
[ffmpeg] av_log callback called with bad parameters (NULL AVClass).
[ffmpeg] This is a bug in one of Libav/FFmpeg libraries used.
[ffmpeg] Unable to submit command buffer: VK_ERROR_DEVICE_LOST
[ffmpeg/video] h264: get_buffer() failed
[ffmpeg/video] h264: decode_slice_header error
[ffmpeg/video] h264: no frame!
Error while decoding frame (hardware decoding)!
[ffmpeg] av_log callback called with bad parameters (NULL AVClass).
[ffmpeg] This is a bug in one of Libav/FFmpeg libraries used.
[ffmpeg] Unable to submit command buffer: VK_ERROR_DEVICE_LOST
Falling back to software decoding.
[ffmpeg/video] h264: co located POCs unavailable
[ffmpeg/video] h264: co located POCs unavailable
AV: 00:00:00 / 00:08:13 (0%) A-V: 0.000
[vo/gpu-next/libplacebo] vkQueueSubmit2: VK_ERROR_DEVICE_LOST (../src/vulkan/command.c:358)
[vo/gpu-next/libplacebo] Retrieving query pool results: VK_ERROR_DEVICE_LOST (../src/vulkan/gpu.c:103)
[vo/gpu-next/libplacebo] vkQueueSubmit2: VK_ERROR_DEVICE_LOST (../src/vulkan/command.c:358)
[vo/gpu-next/libplacebo] vkQueueSubmit2: VK_ERROR_DEVICE_LOST (../src/vulkan/command.c:358)
[vo/gpu-next/libplacebo] vkQueueSubmit2: VK_ERROR_DEVICE_LOST (../src/vulkan/command.c:358)
[vo/gpu-next/libplacebo] Failed holding swapchain image for presentation
[vo/gpu-next] Failed presenting frame!
AV: 00:00:00 / 00:08:13 (0%) A-V: 0.000
Exiting... (Quit)
Ah, hasvk (old Intel GPUs) has a PR to implement video decoding that hasn't been merged yet: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21183
@cyanreg thats the version I am using
(+) Video --vid=1 (*) (hevc 3840x1608 24.000fps) (+) Audio --aid=1 --alang=chi (*) (eac3 6ch 48000Hz) Audio --aid=2 --alang=chi (*) (aac 2ch 44100Hz) [vo/gpu-next/libplacebo] Missing device feature: dynamicRendering [vo/gpu-next/libplacebo] Vulkan device does not support all required features! [vo/gpu-next/libplacebo] Failed creating logical device! [vo/gpu-next/libplacebo] Failed initializing vulkan device [vo/gpu-next] Failed initializing any suitable GPU context! Error opening/initializing the selected video_out (--vo) device. Video: no video
what does this error mean, my device has intel gpu, and i used the following config
mpv --vo=gpu-next --gpu-api=vulkan --hwdec=vulkan --gpu-context=winvk
using the latest shinchiro release.Make sure your GPU is Gen12 or higher (TigerLake+), and update the driver to 4311 or higher
i use i3-10110u's gpu. so I still use d3d11va now. it works well.
I usually use vo=dmabuf-wayland
but noticed that it's causing a segfault when vulkan interop is compiled in (even when it's not being used). Seems like when using dmabuf-wayland it attempts to run through loading every hwdec option even if one is explicitly specified.
Happy to use gpu-next but thought I should note this bug. But also curious if this will work with dmabuf-wayland in the future?
Someone make this into a Wiki entry so I can stop get notifications. Clearly not shithub issue material.
Someone make this into a Wiki entry so I can stop get notifications. Clearly not shithub issue material.
Believe me, I've thought about it. If it was a wiki page, it would still need an issue to be able to pin to the issues page. If locked, it would lead to people filing new issues. You can unsubscribe from this one more easily than unsubscribing from newly filed ones.
Believe me, I've thought about it. If it was a wiki page, it would still need an issue to be able to pin to the issues page. If locked, it would lead to people filing new issues. You can unsubscribe from this one more easily than unsubscribing from newly filed ones.
I believe you, which is really sad. These web-based git front-ends have nothing new to offer nowadays in terms of usability, every shithub new "feature" for the past 4yrs or so is nothing more than a detriment for browser performance and with questionable interface changes... but I digress. Will unsubscribe from this issue and everyone can carry on.
I usually use
vo=dmabuf-wayland
but noticed that it's causing a segfault when vulkan interop is compiled in (even when it's not being used). Seems like when using dmabuf-wayland it attempts to run through loading every hwdec option even if one is explicitly specified.Happy to use gpu-next but thought I should note this bug. But also curious if this will work with dmabuf-wayland in the future?
It's a bug, and I've pushed a fix. Thanks for reporting.
The Sony swordsmith sample got fixed on radv with the following mesa PR: https://gitlab.freedesktop.org/airlied/mesa/-/commits/radv-video-fix-hevc-wip There was also a bug in ffmpeg, fixed with https://github.com/FFmpeg/FFmpeg/commit/65a1e8ee2c4a9c2f325e1921daab915689d9c9fd. Could anyone check if that fixed it on nvidia?
macOS Sonoma, is introducing a translation layer, and that requires dxvk, will macOS Sonoma be bringing vulkan support ? as I've seen it's basically wine/crossover and brings support for dx11 and dx12, and only dxvk supports that in foss.
macOS Sonoma, is introducing a translation layer, and that requires dxvk, will macOS Sonoma be bringing vulkan support ? as I've seen it's basically wine/crossover and brings support for dx11 and dx12, and only dxvk supports that in foss.
This is unlikely, but we can expect MoltenVK Vulkan 1.3
Actually, I heard it's not dxvk, it's some apple's own dx-to-metal translation.
With the latest ffmpeg and mesa, all issues have been solved, and decoding on AMD works perfectly. If there are any bugs left, they're very likely in the driver. So start reporting issues to them as well, if you can.
I'm looking to set up my mpv so it can auto-switch between VVD and NVDec depending on the video codec. How exactly do I write a conditional auto-profile that only enables VVD on videos with H.264 or H.265? I know I'd probably have to match h264
/hevc
at the start of the video-codec
property, but I'm not familiar enough with Lua scripting to write the condition myself.
@arm64-v9a I wanted to do something similar but setting hwdec
at that stage proved to be unreliable and segfaults the whole thing. I had to make a script that waited for a video-reconfig
event and then tried fallbacking if there was some failure with Vulkan, kinda like #11808.
I can share the script if you (or somebody else) wants.
@Riteo video decoding on an intel cpu is the best thing you can do, if you have an intel cpu 10th gen or higher, using nvdec is not needed as cpu hwdec will handle the codecs such as h264, h265, vp9 maybe av1 too.
@arm64-v9a
This profile works fine with winvk+nvdec on NVIDIA, segment errors may be a problem with your driver
Might be, mainline head of ffmpeg segfaults too. Kinda weird that it works when changed after video-reconfig
. I could file a ticket at mesa's repo, I'd have to ask them for more info I think.
@Akczht I don't have an intel CPU, I have an AMD Ryzen 5 3500U, a mobile processor with IGP. I'd like to start using Vulkan Video to find more problems and help polish the standard's implementations by reporting bugs like the aforementioned segfault.
Post sample?
What is cpu hwdec? If you mean qsv-copy, this hwdec does work well, but DV metadata will be lost
hwdec=d3d11va
@Akczht I don't have an intel CPU, I have an AMD Ryzen 5 3500U, a mobile processor with IGP. I'd like to start using Vulkan Video to find more problems and help polish the standard's implementations by reporting bugs like the aforementioned segfault.
Now that I think about it, I should also use vulkan, to test the stuff.
@Akczht
hwdec=d3d11va
I'm pretty sure that it's not done on the CPU; the man page says:
requires --vo=gpu with --gpu-context=d3d11 --gpu-context=angle (Windows 8+ only)
@cyanreg
Post sample?
If you mean video samples for testing, the Kodi wiki has lots: https://kodi.wiki/view/Samples
@Akczht
hwdec=d3d11va
I'm pretty sure that it's not done on the CPU; the man page says:
requires --vo=gpu with --gpu-context=d3d11 --gpu-context=angle (Windows 8+ only)
I don't know exactly, but it's not software i.e. sometimes buggy and power efficient and built into the hardware.
@Riteo I meant one that causes a segfault
@cyanreg here's what I know:
I run mpv on sway (Wayland compositor) on a weird musl-based "meta-distro" (KISS Linux) so mine is definitely not a common setup. I don't think that this should matter in this case but it never hurts to say.
mpv.conf
:
vo=gpu-next
gpu-context=waylandvk
gpu-api=vulkan
hwdec=vaapi
[vulkan]
profile-cond= p["video-format"] == "h264" or p["video-format"] == "hevc"
profile-restore=copy
hwdec=vulkan
With the configuration above, playing the file over at https://dl.ganjanetwork.ru/Files/Video%20Test%20Files/Bitrate/Birds/bird20.mkv returns:
~/test $ mpv ./bird20.mkv
(+) Video --vid=1 (*) (h264 1920x1072 23.976fps)
Using hardware decoding (vaapi).
[auto_profiles] Applying auto profile: vulkan
Segmentation fault
I also built mesa, ffmpeg, libplacebo and mpv with debug symbols (but still with optimizations), disabled the stripping pass of my package manager (kiss, source based) and ran the same command above through GDB. Here's what came from it:
I get a similar segfault with the example ffmpeg command linked here: https://trac.ffmpeg.org/wiki/HWAccelIntro#Vulkan
By similar I mean that it crashes in the same point: set_sps
from libavcodec (ffmpeg).
Edit: In both instances, in the function set_sps
, the vksps
argument points to a completely zeroed out struct for some reason. I have no idea why it isn't populated. Perhaps it's a driver issue?
@Riteo I can't replicate with latest git master of ffmpeg. valgrind is clean too, so I'm not seeing a possibility of an issue. You should retest.
@cyanreg still there :/
The all zeroed struct is the cause of the segfault. The weird thing is that vulkan video definitely works in all the other cases.
I'll try to investigate further to see what's setting this argument and why is it failing.
Edit: oh. It's apparently supposed to be empty as that function sets it. I'm not sure what's the cause of the segfault then. GDB simply points to the start of the function.
Edit2: just to be clear, then my assumption about the empty struct was wrong. I just supposed a normal null deference but that's clearly not the case.
Could you run gdb and run
set disassembly-flavor intel
disassemble
Or just break on set_sps and step through until it crashes. There's nothing weird about that file, it has a single SPS header, so it's not hitting the limit.
EDIT: ah, just read that you're on muslc You're on your own.
@cyanreg
EDIT: ah, just read that you're on muslc You're on your own.
No worries, that's just the musl life lol. Thanks for trying to help!
Should I post the eventual solution here?
Update: yep, it was a muslc thing. Basically the default stack was too small. That's why GDB gave very weird and changing results and valgrind kept reporting "Bad permissions for mapped region at address" even for a local array just declared a line before. How big are those StdVideoH264ScalingLists
?
So, in the end, quick tip for musl users: ask the linker to set a preference for default stack size to something bigger than musl's small default by configuring ffmpeg with something like --extra-ldflags='-Wl,-z,stack-size=0x800000'
. I chose a random size of 8 MBs but I have no idea how small it can be.
I think that I'll stop talking about this here because this is clearly not MPV related. Sorry for the inconvenience.
Vulkan Video Decoding: Usage Guide and FAQ
On the 28th of May, we reached the significant milestone of finally merging all the required functionality into ffmpeg, libplacebo, and mpv to do end-to-end Vulkan video decoding and presentation. Although the functionality is now all there, we still have a complex landscape in terms of what is supported on what hardware and with what drivers. This document attempts to lay out all the requirements and limitations, so you have a chance of successfully using the feature.
Why should I even care about Vulkan video decoding?
It's a fair question. Right now, the actual functionality you gain access to is not terribly different from what you would get with existing video decoding APIs that ffmpeg and mpv already support. However, Vulkan video decoding has the potential to be a credible cross-vendor, cross-platform API that is well supported, and can work efficiently with Vulkan based filtering and post-processing. In the short term, there will be rough edges, and only a narrow set of supported codecs (only H.264 and H.265 are standardised today, with AV1 still a work in progress), but in the future, it will hopefully be the most performant and capable way to do hardware decoding and processing.
Software Requirements
We have finally reached the point where all the required components have made official releases. Ensure you are running with the following releases or newer:
These requirements mean you will likely have to compile everything for yourself (especially on Linux), but Shinchiro's windows builds appear to be functional.
Hardware and Driver Requirements
Usage
The basic command line arguments:
Depending on your system configuration, you may additionally need to force the right
gpu-context
:--gpu-context=winvk
--gpu-context=x11vk
--gpu-context=waylandvk
Capabilities
ANV_VIDEO_DECODE=1
in your environment to expose video decodingRADV_PERFTEST=video_decode
in your environment to expose video decoding