Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vulkan Video Decoding: Usage Guide and FAQ #11739

Closed
philipl opened this issue May 29, 2023 · 234 comments
Closed

Vulkan Video Decoding: Usage Guide and FAQ #11739

philipl opened this issue May 29, 2023 · 234 comments

Comments

@philipl
Copy link
Member

philipl commented May 29, 2023

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

  • Intel on Linux
    • Mesa: mesa-23.2.1
    • A GPU supported by the ANV driver
    • An MR is open for support in the hasvk driver
  • AMD on Linux
    • Mesa: mesa-23.2.1
    • A GPU supported by the RADV driver
    • The AMDVLK driver is not known to support video decoding
  • Nvidia on Linux or Windows
    • Drivers >= 535.xx
    • Any GPU supported by those drivers
  • AMD on Windows
    • Drivers >= 23.9.3
    • RDNA 1/2/3 GPUs
  • Intel on Windows
    • Unclear and untested
    • There is evidence that drivers from at least 101.4311 expose the video decoding extensions
    • No idea what hardware is supported
  • MacOS (for the record)
    • Although Vulkan on MacOS is supported via MoltenVk, this does not include the decoding extensions, and probably never will. Just keep using videotoolbox.

Usage

The basic command line arguments:

mpv --vo=gpu-next --gpu-api=vulkan --hwdec=vulkan

Depending on your system configuration, you may additionally need to force the right gpu-context:

  • Windows: --gpu-context=winvk
  • Linux X11: --gpu-context=x11vk
  • Linux Wayland: --gpu-context=waylandvk

Capabilities

  • Global
    • The Vulkan Video Decoding specs only cover H.264, H.265, and AV1. Older codecs will require you to use your traditional hardware decoding API (VAAPI, nvdec, dx11va, etc) for now, and possibly forever - depending on whether effort is put into exposing older codecs.
  • Intel
    • You must set ANV_VIDEO_DECODE=1 in your environment to expose video decoding
    • Both H.264 and H.265 are supported
    • VK_EXT_descriptor_buffer support, required for Vulkan filters, has been merged but no release includes it yet
  • AMD
    • You must set RADV_PERFTEST=video_decode in your environment to expose video decoding
    • Both H.264 and H.265 are supported
    • Vulkan filters are supported
  • Nvidia
    • Both H.264 and H.265 are supported
    • AV1 is supported with > 550.54.14 drivers
    • Vulkan filters are supported
@philipl philipl pinned this issue May 29, 2023
@Jules-A
Copy link

Jules-A commented May 29, 2023

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!

@llyyr
Copy link
Contributor

llyyr commented May 29, 2023

After bc28dce, you need to patch your Mesa with this PR to get AV1 decoding on radv.

@aufkrawall
Copy link

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.

@philipl
Copy link
Member Author

philipl commented May 30, 2023

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.

@cyanreg
Copy link
Contributor

cyanreg commented May 30, 2023

@aufkrawall AMD currently needs https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23227 to avoid crashes, which also fixes quite a lot of bugs

@alakittty
Copy link

alakittty commented May 30, 2023

 (+) 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?

@Jules-A
Copy link

Jules-A commented May 30, 2023

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.

@cyanreg
Copy link
Contributor

cyanreg commented May 30, 2023

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.

@philipl
Copy link
Member Author

philipl commented May 30, 2023

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...

@llyyr
Copy link
Contributor

llyyr commented May 30, 2023

That file is also broken on anv, it's glitchy and the decode is very slow while utilizing 100% of Render/3D engine.

@philipl
Copy link
Member Author

philipl commented May 30, 2023

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%

@philipl
Copy link
Member Author

philipl commented May 30, 2023

Also:

[ffmpeg/video] hevc: First slice in a frame missing.

This is a highly questionable sample.

@lavilao
Copy link

lavilao commented May 31, 2023

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

@CharlesMengCA
Copy link

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.

image

@24fpsDaVinci
Copy link

24fpsDaVinci commented Jun 1, 2023

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.

rpmfusion-infra/fedy#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

@lavilao
Copy link

lavilao commented Jun 1, 2023

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

Screenshot from 2023-06-01 11-03-44

(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

@24fpsDaVinci
Copy link

@lavilao i assume you're using Shinchiro's windows build? I haven't tried using mpv through wine, you may need to recompile.

@zhengqwe
Copy link

zhengqwe commented Jun 2, 2023

(+) 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.

@llyyr
Copy link
Contributor

llyyr commented Jun 2, 2023

Intel on Windows does not support Vulkan hwdec, read the OP

@Quackdoc
Copy link

Quackdoc commented Jun 2, 2023

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
Copy link

lavilao commented Jun 2, 2023

@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)

@cyanreg
Copy link
Contributor

cyanreg commented Jun 2, 2023

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

@lavilao
Copy link

lavilao commented Jun 2, 2023

@cyanreg thats the version I am using

@zhengqwe
Copy link

zhengqwe commented Jun 3, 2023

(+) 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.

@kkost
Copy link

kkost commented Jun 4, 2023

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?

@garoto
Copy link
Contributor

garoto commented Jun 4, 2023

Someone make this into a Wiki entry so I can stop get notifications. Clearly not shithub issue material.

@philipl
Copy link
Member Author

philipl commented Jun 4, 2023

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.

@garoto
Copy link
Contributor

garoto commented Jun 4, 2023

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.

@philipl
Copy link
Member Author

philipl commented Jun 4, 2023

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.

@llyyr
Copy link
Contributor

llyyr commented Jan 20, 2024

doesn't indicate HW decoding

Did you set ANV_VIDEO_DECODE=1 in your env?

@wyup
Copy link

wyup commented Jan 21, 2024

Did you set ANV_VIDEO_DECODE=1 in your env?

yes I have, on both Fedora and Windows. But before and after setting it, hwdec enabled or not with vulkan or vaapi, i get this console line:

MESA-INTEL: warning: ../src/intel/vulkan/anv_formats.c:794: FINISHME: support more multi-planar formats with DRM modifiers

But only HW: vaapi appears with hwdec=api, with hwdec=vulkan it does not, although frame timings are the same.

@philipl
Copy link
Member Author

philipl commented Jan 30, 2024

@cyanreg After NVIDIA driver update to 550, ffmpeg vulkan video no longer works.

Validation Error: [ VUID-VkImageCreateInfo-pNext-06811 ] | MessageID = 0x30f4ac70 | vkCreateImage(): pCreateInfo specifies flags (VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT|VK_IMAGE_CREATE_EXTENDED_USAGE_BIT|VK_IMAGE_CREATE_ALIAS_BIT), format (VK_FORMAT_G8_B8R8_2PLANE_420_UNORM), imageType (VK_IMAGE_TYPE_2D), and tiling (VK_IMAGE_TILING_OPTIMAL) which are not supported by any of the supported video format properties for the video profiles specified in the VkVideoProfileListInfoKHR structure included in the pCreateInfo->pNext chain, as reported by vkGetPhysicalDeviceVideoFormatPropertiesKHR for the same video profiles and the image usage flags specified in pCreateInfo->usage (VK_IMAGE_USAGE_TRANSFER_SRC_BIT|VK_IMAGE_USAGE_SAMPLED_BIT|VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR|VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR). The Vulkan spec states: If the pNext chain includes a VkVideoProfileListInfoKHR structure with profileCount greater than 0, then supportedVideoFormat must be VK_TRUE (https://vulkan.lunarg.com/doc/view/1.3.275.0/windows/1.3-extensions/vkspec.html#VUID-VkImageCreateInfo-pNext-06811)
Validation Error: [ VUID-VkImageCreateInfo-pNext-06811 ] | MessageID = 0x30f4ac70 | vkCreateImage(): pCreateInfo specifies flags (VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT|VK_IMAGE_CREATE_EXTENDED_USAGE_BIT|VK_IMAGE_CREATE_ALIAS_BIT), format (VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16), imageType (VK_IMAGE_TYPE_2D), and tiling (VK_IMAGE_TILING_OPTIMAL) which are not supported by any of the supported video format properties for the video profiles specified in the VkVideoProfileListInfoKHR structure included in the pCreateInfo->pNext chain, as reported by vkGetPhysicalDeviceVideoFormatPropertiesKHR for the same video profiles and the image usage flags specified in pCreateInfo->usage (VK_IMAGE_USAGE_TRANSFER_SRC_BIT|VK_IMAGE_USAGE_SAMPLED_BIT|VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR|VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR). The Vulkan spec states: If the pNext chain includes a VkVideoProfileListInfoKHR structure with profileCount greater than 0, then supportedVideoFormat must be VK_TRUE (https://vulkan.lunarg.com/doc/view/1.3.275.0/windows/1.3-extensions/vkspec.html#VUID-VkImageCreateInfo-pNext-06811)

I just tried with 550.40.07 and it worked fine, including passing validation with --gpu-debug=yes.

@netExtra
Copy link

netExtra commented Jan 30, 2024

With the latest Nvidia 550 build on Windows, I am able to play video using Vulkan on the latest main branch mpv build (with a custom ffmpeg build).

@elgab
Copy link

elgab commented Jan 30, 2024

The basic filters you want for the input.conf
v vf toggle vflip_vulkan
h vf toggle hflip_vulkan
b vf toggle flip_vulkan
t vf toggle transpose_vulkan

@netExtra
Copy link

netExtra commented Jan 30, 2024

v vf toggle vflip_vulkan
h vf toggle hflip_vulkan
b vf toggle flip_vulkan
t vf toggle transpose_vulkan

A couple of months ago these didn't work but they all work for me now on Windows 10 with:
hwdec=vulkan
gpu-api=vulkan
gpu-context=winvk

Nvidia driver 551.23. Latest MPV build from 2 days ago but with older ffmpeg libraries.

@kasper93
Copy link
Contributor

Can someone with contact to AMD let them know about this crash. This file, if this matters https://archive.org/download/BBC_Top_of_the_Pops_1979_11_01/BBC_Top_of_the_Pops_1979_11_01.mkv

Happens on 24.1.1 driver.

==38224==ERROR: AddressSanitizer: access-violation on unknown address 0x01de12eac48c (pc 0x7ff9434b9039 bp 0x000000000ca0 sp 0x0068aaad7920 T9)
==38224==The signal is caused by a READ memory access.
    #0 0x7ff9434b9038  (C:\WINDOWS\System32\DriverStore\FileRepository\u0399551.inf_amd64_59e1d871bcfdc47e\B399690\amdvlk64.dll+0x180179038)
    #1 0x7ff9434b842d  (C:\WINDOWS\System32\DriverStore\FileRepository\u0399551.inf_amd64_59e1d871bcfdc47e\B399690\amdvlk64.dll+0x18017842d)
    #2 0x7ff9434b8303  (C:\WINDOWS\System32\DriverStore\FileRepository\u0399551.inf_amd64_59e1d871bcfdc47e\B399690\amdvlk64.dll+0x180178303)
    #3 0x7ff94f0d6d31 in ff_vk_decode_create_params F:\dev\ffmpeg\libavcodec\vulkan_decode.c:1071
    #4 0x7ff94f0ea44e in vk_h264_create_params F:\dev\ffmpeg\libavcodec\vulkan_h264.c:344
    #5 0x7ff94f0dd9bc in vk_h264_start_frame F:\dev\ffmpeg\libavcodec\vulkan_h264.c:367
    #6 0x7ff94c82f639 in decode_nal_units F:\dev\ffmpeg\libavcodec\h264dec.c:666
    #7 0x7ff94c829918 in h264_decode_frame F:\dev\ffmpeg\libavcodec\h264dec.c:1055
    #8 0x7ff94ddc0baf in frame_worker_thread F:\dev\ffmpeg\libavcodec\pthread_frame.c:223

@lolzballs
Copy link

lolzballs commented Feb 10, 2024

Can someone with contact to AMD let them know about this crash. This file, if this matters https://archive.org/download/BBC_Top_of_the_Pops_1979_11_01/BBC_Top_of_the_Pops_1979_11_01.mkv

Happens on 24.1.1 driver.

Thanks for reporting it, will look into it. I remember seeing this stream before, it should have been fixed...

@GreyXor
Copy link

GreyXor commented Feb 28, 2024

FYI, mesa mainlined VK_KHR_video_decode_av1 extension support for radv. Would be available in mesa 24.1.

@morialo3
Copy link

Since 550.54.14 nvidia driver on Linux, hwdec=vulkan not working at all:

mpv --vulkan-device=help                                                                                   
Available vulkan devices:
  'NVIDIA GeForce RTX 3080 Laptop GPU' (GPU 0, PCI ID 10de:249c, UUID b35c4bab-d26b-64e4-1fb3-f76cc2b2f16a)
  'Intel(R) UHD Graphics (CML GT2)' (GPU 1, PCI ID 8086:9bc4, UUID 8680c49b-0500-0000-0002-000000000000)

Then

mpv --no-config --vo=gpu-next --gpu-api=vulkan --hwdec=vulkan --vulkan-device=b35c4bab-d26b-64e4-1fb3-f76cc2b2f16a 'https://www.youtube.com/watch?v=Hi-Uyx34JEQ'
EDL: source file 'https://manifest.googlevideo.com/api/manifest/hls_playlist/expire/1709174377/ei/CZrfZZr_JOjNp-oPqcydkAo/ip/194.170.95.213/id/Hi-Uyx34JEQ.1/itag/234/source/yt_live_broadcast/requiressl/yes/ratebypass/yes/live/1/goi/133/sgoap/gir%3Dyes%3Bitag%3D140/rqh/1/hls_chunk_host/rr8---sn-xupn5a5u5x-4wge6.googlevideo.com/xpc/EgVo2aDSNQ%3D%3D/ctier/A/playlist_duration/3600/manifest_duration/3600/hightc/yes/siu/1/vprv/1/playlist_type/DVR/initcwndbps/785000/mh/ZS/mm/44/mn/sn-xupn5a5u5x-4wge6/ms/lva/mv/m/mvi/8/pcm2cms/yes/pl/24/dover/13/pacing/0/short_key/1/keepalive/yes/fexp/24007246/mt/1709152346/sparams/expire,ei,ip,id,itag,source,requiressl,ratebypass,live,goi,sgoap,rqh,xpc,ctier,playlist_duration,manifest_duration,hightc,siu,vprv,playlist_type/sig/AJfQdSswRQIhAOH4e4qCqo3sz-ZodtpQZTqUtlD2kv3Sw7p9Us6vGjrJAiBbBn1383oa73-amMJjXOqWZ9zDTGwiDg5cmY560-hM7w%3D%3D/lsparams/hls_chunk_host,initcwndbps,mh,mm,mn,ms,mv,mvi,pcm2cms,pl/lsig/APTiJQcwRQIgVu-vNrQRI66-2I0Vgq-iMd72L5U2aNv3150PbkaAH4UCIQDoeFJuOHsyJ2QnViuafeSvpbC9z8YXF9Jf2P4tU9iP1Q%3D%3D/playlist/index.m3u8' has unknown duration.
EDL: source file 'https://manifest.googlevideo.com/api/manifest/hls_playlist/expire/1709174377/ei/CZrfZZr_JOjNp-oPqcydkAo/ip/194.170.95.213/id/Hi-Uyx34JEQ.1/itag/312/source/yt_live_broadcast/requiressl/yes/ratebypass/yes/live/1/sgovp/gir%3Dyes%3Bitag%3D299/rqh/1/hls_chunk_host/rr8---sn-xupn5a5u5x-4wge6.googlevideo.com/xpc/EgVo2aDSNQ%3D%3D/ctier/A/playlist_duration/3600/manifest_duration/3600/hightc/yes/siu/1/vprv/1/playlist_type/DVR/initcwndbps/785000/mh/ZS/mm/44/mn/sn-xupn5a5u5x-4wge6/ms/lva/mv/m/mvi/8/pcm2cms/yes/pl/24/dover/13/pacing/0/short_key/1/keepalive/yes/fexp/24007246/mt/1709152346/sparams/expire,ei,ip,id,itag,source,requiressl,ratebypass,live,sgovp,rqh,xpc,ctier,playlist_duration,manifest_duration,hightc,siu,vprv,playlist_type/sig/AJfQdSswRgIhAKZiTZUH9lX--VBjI8sL9iyU2YF94RdP133B2Sff5u00AiEAq_JzQdkt_uIHLyqpWOjEeRDAnlQbqpwc_MZGn3DNS3I%3D/lsparams/hls_chunk_host,initcwndbps,mh,mm,mn,ms,mv,mvi,pcm2cms,pl/lsig/APTiJQcwRgIhAMrTq_h6nv56AgAE9p4tw3zGBBj3dggcPqe_CNgQd12RAiEAkZ53LfSlstbzO5HVhVXWdvu0dS2dAN9X1NTcmYf_qfo%3D/playlist/index.m3u8' has unknown duration.
 (+) Video --vid=1 (h264 1920x1080 60.000fps)
 (+) Audio --aid=1 (aac 2ch 44100Hz)
     Subs  --sid=1 --slang=live_chat 'json' (null) (external)
File tags:
 Uploader: saint_riot
 Channel_URL: https://www.youtube.com/channel/UCDkeh30ZpOrazSqZ9_RCFog
[vo/gpu-next/libplacebo] Spent 1061.760 ms creating vulkan device (slow!)
Using hardware decoding (vulkan).
AO: [pipewire] 44100Hz stereo 2ch floatp
zsh: segmentation fault (core dumped)  mpv --no-config --vo=gpu-next --gpu-api=vulkan --hwdec=vulkan  

back to hwdec=nvdec, I guess.

THANKS NVIDIA

@philipl
Copy link
Member Author

philipl commented Mar 1, 2024

AV1 decode on nvidia doesn't work because the ffmpeg code is written against the pre-standardised MESA extension, but presumably if we adjust it to use the official KHR one, it should work.

@kasper93
Copy link
Contributor

kasper93 commented Mar 1, 2024

This branch has been adapted for the new KHR extension, but it still doesn't work on NVIDIA.

Have you enabled it? Currently it not enabled in mpv until final version is merged upstream and considered safe to enable.

diff --git a/video/out/vulkan/context.c b/video/out/vulkan/context.c
index 3def7bd213..9f74adbd29 100644
--- a/video/out/vulkan/context.c
+++ b/video/out/vulkan/context.c
@@ -208,6 +208,9 @@ bool ra_vk_ctx_init(struct ra_ctx *ctx, struct mpvk_ctx *vk,
         VK_KHR_VIDEO_QUEUE_EXTENSION_NAME,
         // This is a literal string as it's not in the official headers yet.
         "VK_MESA_video_decode_av1",
+#ifdef VK_KHR_VIDEO_DECODE_AV1_EXTENSION_NAME
+        VK_KHR_VIDEO_DECODE_AV1_EXTENSION_NAME,
+#endif
     };
 
     VkPhysicalDeviceDescriptorBufferFeaturesEXT descriptor_buffer_feature = {

@llyyr
Copy link
Contributor

llyyr commented Mar 1, 2024

This branch has been adapted for the new KHR extension, but it still doesn't work on NVIDIA.

It also doesn't work on radv's implementation of the protocol because there were changes that it hasn't updated for yet. Just wait for it to be merged

@Glog78
Copy link

Glog78 commented Mar 2, 2024

#11739 (comment) << same happens with 550.40.53 (aka the current vulkan beta driver)

maybe the resulting coredump info helps a little -> https://paste.rs/4S1iz

@kkost
Copy link

kkost commented Mar 2, 2024

FYI- VK_EXT_descriptor_buffer support has been merged into mesa (git/mainline) for Intel/anv, and vulkan filters appear to be working now.

@atohmdiy
Copy link

atohmdiy commented Mar 4, 2024

I tried to use vulkan video on my Manjaro linux system. Manjaro is stable repo and everything should be working. Everything is set as in the FAQ / Guide.
My system is a 7800x3d cpu and 6900 XT GPU.
Problem is i get these errors in the console for h264 and h265 playback :

[ffmpeg/video] hevc: Device does not support decoding hevc!
[ffmpeg/video] h264: Device does not support decoding h264!

I still get an image of course, but i assume that with this error decoding is done by the cpu.

@JoonasPitk
Copy link

I tried to use vulkan video on my Manjaro linux system. Manjaro is stable repo and everything should be working. Everything is set as in the FAQ / Guide. My system is a 7800x3d cpu and 6900 XT GPU. Problem is i get these errors in the console for h264 and h265 playback :

[ffmpeg/video] hevc: Device does not support decoding hevc! [ffmpeg/video] h264: Device does not support decoding h264!

I still get an image of course, but i assume that with this error decoding is done by the cpu.

Manjaro doesn't build their Mesa with patented codecs, hence why you're missing H264 and HEVC codecs. You can check which codecs are supported for your hardware with vainfo.

@cyanreg
Copy link
Contributor

cyanreg commented Mar 12, 2024

AV1 decoding now works with the following branch on both RADV and Nvidia: https://github.com/cyanreg/FFmpeg/tree/av1dec
Testing appreciated.

@rubyFeedback
Copy link

For me personally, the whole vulkan situation has been quite painful - not sure if this is nvidia related (I have a cheap, crappy nvidia card) or not. High quality information is in general highly appreciated, because right now, even after reading the initial intro on top of this thread, I still don't really know how to solve the problems I have. I can no longer play anything right now via mpv, e. g. getting errors such as

[vo/gpu/drm] Failed to set up VT switcher. Terminal switching will be unavailable.
[vo/gpu/drm] Failed to create DRM atomic context, no DRM Atomic support
[vo/gpu-next/drm] Can't handle VT release - signal already used
[vo/gpu-next/drm] Failed to set up VT switcher. Terminal switching will be unavailable.
[vo/gpu-next/drm] Failed to create DRM atomic context, no DRM Atomic support

This is all quite painful because I know it all works in theory (default manjaro proprietary
nvidia on the same computer and everything works fine).

@temis01
Copy link

temis01 commented Mar 21, 2024

AV1 decoding now works with the following branch on both RADV and Nvidia: https://github.com/cyanreg/FFmpeg/tree/av1dec Testing appreciated.

Hi !

Could you tell me how to build mpv with your ffmpeg repo ?
I am using shinchiro's clang procedure and successfully build mpv with the official git.
Is it even possible with another branch of ffmpeg?
Thanks

@temis01
Copy link

temis01 commented Mar 21, 2024

I tried changing the repo url ... but I missed the "GIT_TAG av1dec" + "GIT_REMOTE_NAME origin" then it failed at ffmpeg prefix.
Thanks

@temis01
Copy link

temis01 commented Mar 22, 2024

@cyanreg ffmpeg repo does not work for me

@cyanreg
Copy link
Contributor

cyanreg commented Mar 22, 2024

Try https://github.com/cyanreg/FFmpeg/tree/av1dec2
I'll have more time to test in a few hours

@temis01
Copy link

temis01 commented Mar 22, 2024

getting same old

av1dec2.txt

@cyanreg
Copy link
Contributor

cyanreg commented Apr 15, 2024

AV1 should work on NVIDIA now with git master of ffmpeg.

@mpv-player mpv-player locked and limited conversation to collaborators Apr 16, 2024
@philipl philipl converted this issue into discussion #13909 Apr 16, 2024
@philipl philipl unpinned this issue Apr 16, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests