how to set Pi4/gpu/vulkan/wayland in config?
after build -Dvulkan-hwaccel=enabled, run mpv --hwdec=vulkan â Unsupported hwdec: vulkan.
and this,
mpv --ao=pipewire --vo=gpu-next --gpu-api=vulkan --hwdec-codecs=vulkan --gpu-context=waylandvk, done.
What is the difference in the performance between this and software rendering or vpu?
play on Pi4, in my old eyes everything is no different
Iâm not really sure mpv is actually doing HW decoding there. In the commandline posted above --hwdec-codecs=vulkan
does not appear to be valid. I am thinking it is getting ignored and defaulting to software decoding. It should be --hwdec-codecs=all' or something like '--hwdec-codecs=h264,mpeg2video
If you do a mpv --hwdec=help
it gives the available APIâs with itâs codecs. If @Rip2 would post the terminal output using the parameters he posted above up to playing the movie we can see what is going on. It should be --hwdec=<API>
so --hwdec=vulkan
.
Looking in the latest mpv configure the only mention for the raspberry pi gpu is for hwaccel is using MMAL. The problem with it is the proprietary libs used right now is 32 bit only. I used MMAL in the past in a 32bit image when ffmpeg-rpi and mpv-rpi was in AUR.
Looking over the link above there is no mention of using a rpi gpu so I am assuming it is for desktop looking at their list of gpuâs.
Hi @Darksky, @Rip2, @spikerguy,
Are there prerequisite packages need to be installed first to enable âvulkanâ on mpv?
Manajro-Arm-Gnome-linux-aml-6.1.39-1 on GT King Pro (Amlogic S922X)
mpv --ao=pipewire --vo=gpu-next --gpu-api=vulkan --hwdec-codecs=vulkan --gpu-context=waylandvk â/run/media/jfl/Elements/Movies/English Movies/300.Rise.Of.An.Empire.2014.1080p.BluRay.x264-BLOW[rarbg]/blow-300.rise.of.an.empire.2014.1080p.bluray.x264.mkvâ
(+) Video --vid=1 () (h264 1920x800 23.976fps)
(+) Audio --aid=1 --alang=eng () (dts 6ch 48000Hz)
Subs --sid=1 --slang=eng âEnglish SDHâ (subrip)
Subs --sid=2 --slang=eng âEnglishâ (subrip)
[vo/gpu-next] Failed initializing any suitable GPU context!
Error opening/initializing the selected video_out (âvo) device.
Video: no videoExiting⌠(Errors when loading file)
Doesnât seems to recognize ââvo=gpu-nextâ and ââgpu-context=waylandvkâ.
Edit: Surprises. The new mpv-0.36.0-1 support vpu hw acceleration on GT King Pro usiing the usual ââhwdec=v4l2m2-copyâ!
mpv --gpu-context=wayland --hwdec=v4l2m2m-copy â/run/media/jfl/Elements/Movies/English Movies/300.Rise.Of.An.Empire.2014.1080p.BluRay.x264-BLOW[rarbg]/blow-300.rise.of.an.empire.2014.1080p.bluray.x264.mkvâ
(+) Video --vid=1 () (h264 1920x800 23.976fps)
(+) Audio --aid=1 --alang=eng () (dts 6ch 48000Hz)
Subs --sid=1 --slang=eng âEnglish SDHâ (subrip)
Subs --sid=2 --slang=eng âEnglishâ (subrip)
[vo/gpu/wayland] GNOMEâs wayland compositor lacks support for the idle inhibit protocol. This means the screen can blank during playback.
AO: [pulse] 48000Hz 5.1(side) 6ch float
Using hardware decoding (v4l2m2m-copy).
VO: [gpu] 1920x800 nv12
Invalid video timestamp: 0.000000 â 0.000000
AV: 00:01:40 / 01:42:36 (2%) A-V: 0.000 Dropped: 1 Cache: 125s/150MBExiting⌠(Quit)
But when I tried to use mpv to stream Youtube video it does NOT work with âvp9â.
mpv --gpu-context=wayland --hwdec=v4l2m2m-copy Nightwish - The Siren (Subtitles) - YouTube
(+) Video --vid=1 () (vp9 1920x1080 60.000fps)
(+) Audio --aid=1 --alang=eng () (opus 2ch 48000Hz)
Subs --sid=1 --slang=en âEnglishâ (webvtt) (external)
Subs --sid=2 --slang=pt âPortugueseâ (webvtt) (external)
Subs --sid=3 --slang=ru âRussianâ (webvtt) (external)
File tags:
Uploader: Hardigun
Channel_URL: https://www.youtube.com/channel/UCiyqpG37FD1BgmP-y33Et6Q
[vo/gpu/wayland] GNOMEâs wayland compositor lacks support for the idle inhibit protocol. This means the screen can blank during playback.
Segmentation fault (core dumped)
This command in âmpv.confâ:
ytdl-format=bestvideo[height<=?1080][fps<=?60][ext=mp4]+bestaudio/best
used to force mpv to stream Youtube âh264â only (with "yt-dlp-2023.03.04-1 or earlier) but now it doesnât seems to be recognized anymore with the latest âyt-dlp-2023.07.06-1â or âmpvâ.
Appreciate tips on how to force mpv or yt-dlp to stream âh264â only?
[vcodec^=avc1]
Test for pi4
[ffmpeg/video] h264: Device does not support the VK_KHR_video_decode_queue extension!
[ffmpeg/video] hevc: Device does not support the VK_KHR_video_decode_queue extension!
No hardware decoding with vulkan
Do you mean:
ytdl-format=bestvideo[height<=?1080][fps<=?60][vcodec^=avc1]+bestaudio/best
or
ytdl-format=bestvideo[height<=?1080][fps<=?60][vcodec^=h264]+bestaudio/best
Both resulted in âSegmentation fault (core dumped)â
mpv --gpu-context=wayland --hwdec=v4l2m2m-copy Nightwish - The Siren (Subtitles) - YouTube
(+) Video --vid=1 () (h264 1280x720 30.000fps)
(+) Audio --aid=1 --alang=eng () (aac 2ch 44100Hz)
Subs --sid=1 --slang=en âEnglishâ (webvtt) (external)
Subs --sid=2 --slang=pt âPortugueseâ (webvtt) (external)
Subs --sid=3 --slang=ru âRussianâ (webvtt) (external)
[vo/gpu/wayland] GNOMEâs wayland compositor lacks support for the idle inhibit protocol. This means the screen can blank during playback.
Segmentation fault (core dumped)
Edit: The new mpv-0.36.0-1 does NOT support the older âyt-dlp-2023.03.04-1â anymore. When downgraded to yt-dlp-2023.03.04-1 results in:
mpv --gpu-context=wayland --hwdec=v4l2m2m-copy Nightwish - The Siren (Subtitles) - YouTube
[ytdl_hook] Traceback (most recent call last):
[ytdl_hook] File â/usr/bin/yt-dlpâ, line 5, in
[ytdl_hook] from yt_dlp import main
[ytdl_hook] ModuleNotFoundError: No module named âyt_dlpâ
[ytdl_hook] youtube-dl failed: unexpected error occurred
Failed to recognize file format.Exiting⌠(Errors when loading file)
I used to be able to use --hwdec=v4l2m2m-copy
on the pi4 with mp4 and possibly h265 but something changed in the kernel and all it gives me is the Segmentation fault (core dumped)
you are seeing above.
Guessing you are running wayland with the right vulkan stuff installed for your device.
Doesnât seems to recognize ââvo=gpu-nextâ and ââgpu-context=waylandvkâ.
Check if those are available in your mpv install.
gpu-next:
[ray@jellyfin packages]$ mpv --vo=help
Available video outputs:
libmpv render API for libmpv
gpu Shader-based GPU Renderer
gpu-next Video output based on libplacebo
vdpau VDPAU with X11
wlshm Wayland SHM video output (software scaling)
xv X11/Xv
dmabuf-wayland Wayland dmabuf video output
vaapi VA API with X11
x11 X11 (software scaling)
null Null video output
image Write video frames to image files
tct true-color terminals
drm Direct Rendering Manager (software scaling)
kitty Kitty terminal graphics protocol
gpu-context:
[ray@jellyfin packages]$ mpv --gpu-context=help
GPU contexts (APIs):
auto (autodetect)
wayland (opengl)
x11egl (opengl)
drm (opengl)
waylandvk (vulkan)
x11vk (vulkan)
displayvk (vulkan)
First line
Try at first with just vo=gpu only before testing and test other videos because they have change "extractor-args=âyoutube:player_clientâ too for 1080p premium.
I use that for pi4
ytdl-format="(bestvideo[fps>50][height<=1080][vcodec^=avc1]/bestvideo[fps>50][height<=720]/bestvideo[fps<=50][height<=1080])+(bestaudio/best)"
ytdl-raw-options=write-sub=,write-auto-sub=,sub-lang="en,eng,fr,fra,fre",cookies-from-browser="firefox",extractor-args="youtube:player_client=android,web"
Hi @Darksky,
Yes, with earlier mpv-0.34.1 ââhwdec=v4l2m2m-copyâ on h264 works and sort of work on vp9 (have some visual artifacts at times) this is with ffmpeg-4.4
But on mpv-0.35.1 ââhwdec=v4l2m2m-copyâ will results in âsegmentation fault â core dumpâ with ffmpeg-5.
As far as I can tell, âvo=gpu-nextâ and âgpu-context=waylandvkâ is available on âmpv-0.36.0-1â but it doesnât seems to recognize them.
Do I need to install âvulkan-extra-layersâ, âvulkan-mesa-layersâ, âvulkan-panfrostâ? These were not installed.
jfl@jfl-gtkpro î° ď î° mpv --vo=help
Available video outputs:
libmpv render API for libmpv
gpu Shader-based GPU Renderer
gpu-next Video output based on libplacebo
vdpau VDPAU with X11
wlshm Wayland SHM video output (software scaling)
xv X11/Xv
dmabuf-wayland Wayland dmabuf video output
vaapi VA API with X11
x11 X11 (software scaling)
null Null video output
image Write video frames to image files
tct true-color terminals
drm Direct Rendering Manager (software scaling)
kitty Kitty terminal graphics protocol
jfl@jfl-gtkpro î° ď î° mpv --gpu-context=help
GPU contexts (APIs):
auto (autodetect)
wayland (opengl)
x11egl (opengl)
drm (opengl)
waylandvk (vulkan)
x11vk (vulkan)
displayvk (vulkan)
Hi @tartanpion,
Thanks for the tips.
mpv.conf âvo=gpuâ seems to work.
These commands on âmpv.confâ does set it to stream âh264â provided âhwdec=v4l2m2m-copyâ is NOT enabled
î î° jfl@jfl-gtkpro î° ď î° mpv --gpu-context=wayland https://www.youtube.com/watch?v=wZnVQT_iEYo
(+) Video --vid=1 (*) (h264 1920x1080 60.000fps)
(+) Audio --aid=1 --alang=eng (*) (opus 2ch 48000Hz)
Subs --sid=1 --slang=en 'English' (webvtt) (external)
File tags:
Uploader: Hardigun
Channel_URL: https://www.youtube.com/channel/UCiyqpG37FD1BgmP-y33Et6Q
[vo/gpu/wayland] GNOME's wayland compositor lacks support for the idle inhibit protocol. This means the screen can blank during playback.
AO: [pulse] 48000Hz stereo 2ch float
VO: [gpu] 1920x1080 yuv420p
AV: 00:00:22 / 00:04:45 (8%) A-V: 0.000 Dropped: 21 Cache: 29s/7MB
Audio/Video desynchronisation detected! Possible reasons include too slow
hardware, temporary CPU spikes, broken drivers, and broken files. Audio
position will not match to the video (see A-V status field).
AV: 00:01:21 / 00:04:45 (28%) A-V: 0.001 Dropped: 125 Cache: 65s/22MB
Exiting... (Quit)
Once âhwdec=v4l2m2m-copyâ is enabled âsegmentation fault (core dumped)â. Eventhough the video is in âh264â format.
This is interesting. Basically âhwdec=v4l2m2m-copyâ work with local h264 video but will NOT stream Youtube h264 video with âhwdec=v4l2m2m-copyâ. Same Youtube video. Why?
î î° jfl@jfl-gtkpro î° ď î° mpv --gpu-context=wayland --hwdec=v4l2m2m-copy https://www.youtube.com/watch?v=wZnVQT_iEYo
(+) Video --vid=1 (*) (h264 1920x1080 60.000fps)
(+) Audio --aid=1 --alang=eng (*) (opus 2ch 48000Hz)
Subs --sid=1 --slang=en 'English' (webvtt) (external)
File tags:
Uploader: Hardigun
Channel_URL: https://www.youtube.com/channel/UCiyqpG37FD1BgmP-y33Et6Q
[vo/gpu/wayland] GNOME's wayland compositor lacks support for the idle inhibit protocol. This means the screen can blank during playback.
Segmentation fault (core dumped)
Edit: Correction. mpv-0.36.0-1 âhwdec=v4l2m2m-copyâ does NOT play all local âh264â video files. video files with âh264.mp4â will result in âsegmentation fault (core dumped)â.
jfl@jfl-gtkpro î° ď î° mpv --gpu-context=wayland --hwdec=v4l2m2m-copy '/run/media/jfl/Elements/Movies/English Movies/Avengers Age of Ultron (2015)/Avengers.Age.of.Ultron.2015.720p.BluRay.x264.YIFY.mp4'
(+) Video --vid=1 (*) (h264 1280x536 23.976fps)
(+) Audio --aid=1 --alang=eng (*) (aac 2ch 48000Hz)
[vo/gpu/wayland] GNOME's wayland compositor lacks support for the idle inhibit protocol. This means the screen can blank during playback.
Segmentation fault (core dumped)
Video files with âh264.mkvâ will work with âhwdec=v4l2m2m-copyâ.
î î° jfl@jfl-gtkpro î° ď î° mpv --gpu-context=wayland --hwdec=v4l2m2m-copy '/run/media/jfl/Elements/Movies/English Movies/Lets.Be.Cops.2014.1080p.BluRay.x264-SPARKS[rarbg]/Lets.Be.Cops.2014.1080p.BluRay.x264-SPARKS.mkv'
(+) Video --vid=1 (*) (h264 1920x1040 23.976fps)
(+) Audio --aid=1 --alang=eng (*) (dts 6ch 48000Hz)
(+) Subs --sid=1 --slang=eng (*) (f) 'English-Forced' (subrip)
[vo/gpu/wayland] GNOME's wayland compositor lacks support for the idle inhibit protocol. This means the screen can blank during playback.
AO: [pulse] 48000Hz 5.1(side) 6ch float
Using hardware decoding (v4l2m2m-copy).
VO: [gpu] 1920x1040 nv12
Invalid video timestamp: 0.000000 -> 0.000000
AV: 00:01:06 / 01:44:28 (1%) A-V: 0.000 Dropped: 5 Cache: 104s/150MB
Exiting... (Quit)
Once you figure out what options you want to use put them in the conf file.
(this is not from ARM, but nonetheless)
$ cat ~/.config/mpv/mpv.conf
vo=gpu
profile=gpu-hq
hwdec=vaapi-copy
last ffmpeg removed MMAL, --enable-v4l2-m2m, build ok.
but mpv not work --hwdec=v4l2m2m-copy on Pi4.
Hi @spikerguy, @Darksky and @tartanpion,
Additional info on mpv-0.36.0-1 and mpv-hwdec-0.35.1-4.
mpv.conf:
vo=gpu
ytdl-format=â(bestvideo[fps>50][height<=1080][vcodec^=avc1]/bestvideo[fps>50][height<=720]/bestvideo[fps<=50][height<=1080])+(bestaudio/best)â
mvp-0.36.0-1 as pointed out earlier it can play or support âhwdec=v4l2m2m-copyâ for x264.mkv
mpv --gpu-context=wayland --hwdec=v4l2m2m-copy â/run/media/jfl/Elements/Movies/English Movies/300.Rise.Of.An.Empire.2014.1080p.BluRay.x264-BLOW[rarbg]/blow-300.rise.of.an.empire.2014.1080p.bluray.x264.mkvâ
(+) Video --vid=1 (<em>) (h264 1920x800 23.976fps)
(+) Audio --aid=1 --alang=eng (</em>) (dts 6ch 48000Hz)
Subs --sid=1 --slang=eng âEnglish SDHâ (subrip)
Subs --sid=2 --slang=eng âEnglishâ (subrip)
[vo/gpu/wayland] GNOMEâs wayland compositor lacks support for the idle inhibit protocol. This means the screen can blank during playback.
AO: [pulse] 48000Hz 5.1(side) 6ch float
**Using hardware decoding (v4l2m2m-copy).**
**VO: [gpu] 1920x800 nv12**
Invalid video timestamp: 0.000000 â 0.000000
AV: 00:01:40 / 01:42:36 (2%) A-V: 0.000 Dropped: 1 Cache: 125s/150MB
Exiting⌠(Quit
But mpv-0.36.0-1 will not support âhwdec=v4l2m2m-copyâ for seemingly typical âh264â format
mpv --gpu-context=wayland --hwdec=v4l2m2m-copy [Nightwish - The Siren (Subtitles) - YouTube](https://www.youtube.com/watch?v=wZnVQT_iEYo)
(+) Video --vid=1 (<em>) (h264 1280x720 30.000fps)
(+) Audio --aid=1 --alang=eng (</em> ) (aac 2ch 44100Hz)
Subs --sid=1 --slang=en âEnglishâ (webvtt) (external)
Subs --sid=2 --slang=pt âPortugueseâ (webvtt) (external)
Subs --sid=3 --slang=ru âRussianâ (webvtt) (external)
[vo/gpu/wayland] GNOMEâs wayland compositor lacks support for the idle inhibit protocol. This means the screen can blank during playback.
Segmentation fault (core dumped)
mpv-hwdec-0.35.1-4 does not recognise:
ytdl-format="(bestvideo[fps>50][height<=1080][vcodec^=avc1]/bestvideo[fps>50][height<=720]/bestvideo[fps<=50][height<=1080])+(bestaudio/best)
As such, mpv-hwdec-0.35.1-4 will NOT stream typical Youtube video as iYoutube default video format is âvp9â.
Whereas mpv-0.36.0-1 have no issue recognising the âmpv.confâ but wonât support âhwdec=v4l2m2m-copyâ with âmp4â format as highlighted above.
But mpv-hwdec-0.35.1-4 âhwdec=v4l2m2m-copyâ will play local âx264.mkvâ and âmp4â
[jfl@jfl-mnjro ~]$ mpv --gpu-context=wayland --hwdec=v4l2m2m-copy '/run/media/jfl/Elements/GT_KING_PRO/videos/Big Buck Bunny 60fps 4K - Official Blender Foundation Short Film [aqz-KE-bpKQ].mp4'
Error parsing option ytdl-format (option not found)
/etc/mpv/mpv.conf:9: setting option ytdl-format='(bestvideo[fps>50][height<=1080][vcodec^=avc1]/bestvideo[fps>50][height<=720][vcodec^=avc1]/bestvideo[fps<=50][height<=1080][vcodec^=avc1])+(bestaudio/best)' failed.
(+) Video --vid=1 (*) (h264 1920x1080 60.000fps)
could not consume packet
Using hardware decoding (v4l2m2m-copy).
VO: [gpu] 1920x1080 nv12
V: 00:10:34 / 00:10:34 (100%) Dropped: 21 Cache: 0.0s
Exiting... (End of file)
https://test-videos.co.uk/jellyfish/mkv
https://test-videos.co.uk/bigbuckbunny/mp4-h264
I can hardware decoding the big bunny.mp4 but not the mkv. It must be something other than the container.
ffprobe to inspect
I compiled from AUR ffmpeg-v4l2-request-git (6.0.r329749) with drm prime and mpv-git and I can play some .mp4âs with a mkv wrapper using HW decoding and some I canât. I can not play any plain .mp4 files. My device used is the rpi-400.
Seems --hwdec=v4l2m2m has a slight edge over --hwdec=v4l2m2m-copy in htop
Notice the VO: line using drm prime:
[ray@jellyfin Extraction.2.2023]$ mpv --hwdec=v4l2m2m Extraction.2.2023.mkv
(+) Video --vid=1 () (h264 1280x720 24.000fps)
(+) Audio --aid=1 --alang=eng () (eac3 6ch 48000Hz)
Subs --sid=1 --slang=eng (*) (f) âEnglish (forced)â (subrip)
(+) Subs --sid=2 --slang=eng âEnglish (SDH)â (subrip)
Using hardware decoding (v4l2m2m).
AO: [pipewire] 48000Hz 5.1(side) 6ch floatp
VO: [gpu] 1280x720 drm_prime[yuv420p]
AV: 00:00:02 / 02:03:57 (0%) A-V: 0.000
Anyone is welcome to use my pkgbuildâs to test on your devices to see if anything migt be better. I noticed ffmpeg had something with rockchip enabled.
md5sum:
8288ee78becccd3519d0f04c394bfe17 ffmpeg-mpv-git.tar
https://drive.google.com/file/d/1T8XbxidOficPotNvCkMqyWtA2d4mLhMn/view?usp=sharing
glibc-widevine as dependency?
No not really. I forgot I had it installed testing widevine. It is glibc with widevine support added.
Added:
I am redoing the packages so it will install using the right glibc but I am trying to make some changes to see if .mp4 files will HW decode.