Mpv-0.36 how to setup

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.

1 Like

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 :stuck_out_tongue_closed_eyes:

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 video

Exiting… (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/150MB

Exiting… (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 https://www.youtube.com/watch?v=wZnVQT_iEYo
(+) 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 https://www.youtube.com/watch?v=wZnVQT_iEYo
(+) 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 https://www.youtube.com/watch?v=wZnVQT_iEYo
[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

2 Likes

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.

1 Like