HEVC decode in MPV

Hello, I am having a problem with video playback. I am using a Pi 4b 1GB. I am using the lite edition installed through the RPI imager program.

Previously I made a topic about poor playback performance overall in MPV. I have since resolved that by using Wayland. Now the problem is that even though H264 playback is great, HEVC not so much. It is hard to pin down because many HEVC files I have play perfectly fine, or only slow down for one second in a 20 minute video. However there are others that are unwatchable due to constantly running out of cache or are stuttering constantly.

Most people solve this by using LibreELEC, but I personally like my minimal setup with MPV, and think it would help other users if this got fixed anyways. Obviously it can work because the hardware supports it and other distros have it working with some black magic. Is this possible with MPV? Do I need to compile ffmpeg myself? Are there updates coming in new kernel versions or something else that will enable this? I found this topic: Question about hevc_v4l2m2m and pi4 but it’s not exactly clear in the replies if this actually solves the problem and how to go about it.

With a pi you can decode h264 60fps even with no hardware accelerated. Software decoding : vp9 1080 until 50fps and hevc 1080 less than 30 fps.
To have access to H265 beyond that you need hardware decoding. That can’t be done in the DE but with drm/framebuffer.
You have two option :
Kodi , you can use it with TTY more easily that enable disable the service.Don’t forget to be in the input group :

usermod -a -G input $user

And if you use kernel> 5.15 you must use kodi 20.

Or you can use vlc-rpi with opengl output.You have acceleration when you go full screen (the package are only in the arch repositery) vlc-rpi/ffmpeg-rpi. Can we have a portage ? :slightly_smiling_face:

Mpv don’t enable hardware decoding…(just h264 but bug)
But use opengl-es in mpv’s config when you are inside the DE.

ao=pipewire
# cache=153600
autofit-smaller=90%
autofit-larger=90%
volume-max=400    # 0&9 keys controls the volume


#vo=gpu-next
#gpu-context=wayland
opengl-es=yes
save-position-on-quit

sub-auto=fuzzy
slang=en,eng,fr,fra,fre
sub-visibility=no
sub-font-size=44

script-opts-append=ytdl_hook-ytdl_path=/usr/bin/yt-dlp

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"

And check your boot/config.txt :

#gpu_mem=64
dtoverlay=vc4-kms-v3d,cma-512

perhaps a bit of overclocking

and if you use a 4k screen you must enable other lines

This package is customized to only work for Raspberry Pi and as such requires a special rpi version of ffpmeg too.

I was hoping, when the ALARM dev started working on those, that it could be integrated into the existing ffnpeg and vlc packages without regressions on other platforms. But it does not seem like it can.

the ffpmeg-rpi is here ffmpeg-rpi

I know. But it’s two extra packages we would need to always keep in sync with ALARM. And the benefit is only for 1 task for 1 device.

I try to compile ffmpeg-rpi and vlc-rpi. No problem with ffmpeg-rpi first, but i have an error during the make install :

libtool: warning: relinking 'libnoseek_plugin.la'
libtool: install: (cd /home/bloodmoon/Téléchargements/vlc/src/vlc-3.0.17.4/modules; /bin/sh "/home/bloodmoon/Téléchargements/vlc/src/vlc-3.0.17.4/modules/../libtool"  --silent --tag CC --mode=relink gcc -march=armv8-a -O2 -pipe -fstack-protector-strong -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -g -fvar-tracking-assignments -ffile-prefix-map=/home/bloodmoon/Téléchargements/vlc/src=/usr/src/debug -I/usr/include/samba-4.0 -ffat-lto-objects -I/usr/include/ffmpeg-rpi -Wall -Wextra -Wsign-compare -Wundef -Wpointer-arith -Wvolatile-register-var -Wformat-security -Wbad-function-cast -Wwrite-strings -Wmissing-prototypes -Werror-implicit-function-declaration -Winit-self -Wlogical-op -Wshadow=local -fvisibility=hidden -O3 -fno-math-errno -funsafe-math-optimizations -fno-rounding-math -fno-signaling-nans -fcx-limited-range -funroll-loops -fomit-frame-pointer -avoid-version -module -export-symbols-regex "^vlc_entry" -shrext .so -no-undefined ../compat/libcompat.la ../src/libvlccore.la -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -Wl,-z,defs -o libnoseek_plugin.la -rpath /usr/lib/vlc/plugins/demux demux/filter/noseek.lo -inst-prefix-dir /home/bloodmoon/Téléchargements/vlc/pkg/vlc-rpi)
libtool: install: /usr/bin/install -c .libs/libstream_out_transcode_plugin.soT /home/bloodmoon/Téléchargements/vlc/pkg/vlc-rpi/usr/lib/vlc/plugins/stream_out/libstream_out_transcode_plugin.so
libtool: install: /usr/bin/install -c .libs/libstream_out_transcode_plugin.lai /home/bloodmoon/Téléchargements/vlc/pkg/vlc-rpi/usr/lib/vlc/plugins/stream_out/libstream_out_transcode_plugin.la
libtool: warning: relinking 'libstream_out_rtp_plugin.la'
libtool: install: (cd /home/bloodmoon/Téléchargements/vlc/src/vlc-3.0.17.4/modules; /bin/sh "/home/bloodmoon/Téléchargements/vlc/src/vlc-3.0.17.4/modules/../libtool"  --silent --tag CC --mode=relink gcc -march=armv8-a -O2 -pipe -fstack-protector-strong -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -g -fvar-tracking-assignments -ffile-prefix-map=/home/bloodmoon/Téléchargements/vlc/src=/usr/src/debug -I/usr/include/samba-4.0 -ffat-lto-objects -I/usr/include/ffmpeg-rpi -Wall -Wextra -Wsign-compare -Wundef -Wpointer-arith -Wvolatile-register-var -Wformat-security -Wbad-function-cast -Wwrite-strings -Wmissing-prototypes -Werror-implicit-function-declaration -Winit-self -Wlogical-op -Wshadow=local -fvisibility=hidden -O3 -fno-math-errno -funsafe-math-optimizations -fno-rounding-math -fno-signaling-nans -fcx-limited-range -funroll-loops -fomit-frame-pointer -avoid-version -module -export-symbols-regex "^vlc_entry" -shrext .so -no-undefined ../compat/libcompat.la ../src/libvlccore.la -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -Wl,-z,defs -o libstream_out_rtp_plugin.la -rpath /usr/lib/vlc/plugins/stream_out stream_out/libstream_out_rtp_plugin_la-rtp.lo stream_out/libstream_out_rtp_plugin_la-rtpfmt.lo stream_out/libstream_out_rtp_plugin_la-rtcp.lo stream_out/libstream_out_rtp_plugin_la-rtsp.lo stream_out/libstream_out_rtp_plugin_la-vod.lo -inst-prefix-dir /home/bloodmoon/Téléchargements/vlc/pkg/vlc-rpi)
libtool: install: /usr/bin/install -c .libs/libnoseek_plugin.soT /home/bloodmoon/Téléchargements/vlc/pkg/vlc-rpi/usr/lib/vlc/plugins/demux/libnoseek_plugin.so
libtool: install: /usr/bin/install -c .libs/libnoseek_plugin.lai /home/bloodmoon/Téléchargements/vlc/pkg/vlc-rpi/usr/lib/vlc/plugins/demux/libnoseek_plugin.la
libtool: warning: remember to run 'libtool --finish /usr/lib/vlc/plugins/demux'
libtool: install: /usr/bin/install -c .libs/libstream_out_rtp_plugin.soT /home/bloodmoon/Téléchargements/vlc/pkg/vlc-rpi/usr/lib/vlc/plugins/stream_out/libstream_out_rtp_plugin.so
libtool: install: /usr/bin/install -c .libs/libstream_out_rtp_plugin.lai /home/bloodmoon/Téléchargements/vlc/pkg/vlc-rpi/usr/lib/vlc/plugins/stream_out/libstream_out_rtp_plugin.la
libtool: warning: remember to run 'libtool --finish /usr/lib/vlc/plugins/stream_out'
make[5] : on quitte le répertoire « /home/bloodmoon/Téléchargements/vlc/src/vlc-3.0.17.4/modules »
make[4]: *** [Makefile:29026 : install-am] Erreur 2
make[4] : on quitte le répertoire « /home/bloodmoon/Téléchargements/vlc/src/vlc-3.0.17.4/modules »
make[3]: *** [Makefile:28597 : install-recursive] Erreur 1
make[3] : on quitte le répertoire « /home/bloodmoon/Téléchargements/vlc/src/vlc-3.0.17.4/modules »
make[2]: *** [Makefile:29019 : install] Erreur 2
make[2] : on quitte le répertoire « /home/bloodmoon/Téléchargements/vlc/src/vlc-3.0.17.4/modules »
make[1]: *** [Makefile:1565 : install-recursive] Erreur 1
make[1] : on quitte le répertoire « /home/bloodmoon/Téléchargements/vlc/src/vlc-3.0.17.4 »
make: *** [Makefile:2039 : install] Erreur 2
==> ERREUR : Une erreur s’est produite dans package().
    Abandon…

Appart from that I can compile vlc-git without error.

I think the error you’re getting may be further up, because I don’t see anything in there indicating a fatal error.

exact the error was :

libtool: install: (cd /home/bloodmoon/Téléchargements/vlc/src/vlc-3.0.17.4/modules; /bin/sh "/home/bloodmoon/Téléchargements/vlc/src/vlc-3.0.17.4/modules/../libtool"  --silent --tag CC --mode=relink gcc -march=armv8-a -O2 -pipe -fstack-protector-strong -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -g -fvar-tracking-assignments -ffile-prefix-map=/home/bloodmoon/Téléchargements/vlc/src=/usr/src/debug -I/usr/include/samba-4.0 -ffat-lto-objects -I/usr/include/ffmpeg-rpi -Wall -Wextra -Wsign-compare -Wundef -Wpointer-arith -Wvolatile-register-var -Wformat-security -Wbad-function-cast -Wwrite-strings -Wmissing-prototypes -Werror-implicit-function-declaration -Winit-self -Wlogical-op -Wshadow=local -fvisibility=hidden -O3 -fno-math-errno -funsafe-math-optimizations -fno-rounding-math -fno-signaling-nans -fcx-limited-range -funroll-loops -fomit-frame-pointer -avoid-version -module -export-symbols-regex "^vlc_entry" -shrext .so -no-undefined ../compat/libcompat.la ../src/libvlccore.la -rpath /usr/lib/vlc/plugins/services_discovery -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -Wl,-z,defs -o libmicrodns_plugin.la services_discovery/libmicrodns_plugin_la-microdns.lo -lmicrodns -inst-prefix-dir /home/bloodmoon/Téléchargements/vlc/pkg/vlc-rpi)
/usr/bin/ld: codec/avcodec/.libs/libavcodec_plugin_la-subtitle.o: in function `InitSubtitleDec':
/usr/src/debug/vlc-3.0.17.4/modules/codec/avcodec/subtitle.c:96: undefined reference to `av_codec_set_pkt_timebase'
/usr/bin/ld: /usr/src/debug/vlc-3.0.17.4/modules/codec/avcodec/subtitle.c:96: undefined reference to `av_codec_set_pkt_timebase'
collect2: error: ld returned 1 exit status
libtool: install: /usr/bin/install -c .libs/libstream_out_display_plugin.soT /home/bloodmoon/Téléchargements/vlc/pkg/vlc-rpi/usr/lib/vlc/plugins/stream_out/libstream_out_display_plugin.so
libtool: install: /usr/bin/install -c .libs/libmp4_plugin.soT /home/bloodmoon/Téléchargements/vlc/pkg/vlc-rpi/usr/lib/vlc/plugins/demux/libmp4_plugin.so
libtool: install: /usr/bin/install -c .libs/libstream_out_display_plugin.lai /home/bloodmoon/Téléchargements/vlc/pkg/vlc-rpi/usr/lib/vlc/plugins/stream_out/libstream_out_display_plugin.la
libtool: install: /usr/bin/install -c .libs/libmp4_plugin.lai /home/bloodmoon/Téléchargements/vlc/pkg/vlc-rpi/usr/lib/vlc/plugins/demux/libmp4_plugin.la
libtool: install: /usr/bin/install -c .libs/libpacketizer_hevc_plugin.soT /home/bloodmoon/Téléchargements/vlc/pkg/vlc-rpi/usr/lib/vlc/plugins/packetizer/libpacketizer_hevc_plugin.so
libtool: install: /usr/bin/install -c .libs/libpacketizer_hevc_plugin.lai /home/bloodmoon/Téléchargements/vlc/pkg/vlc-rpi/usr/lib/vlc/plugins/packetizer/libpacketizer_hevc_plugin.la
libtool:   error: error: relink 'libavcodec_plugin.la' with the above command before installing it
make[5]: *** [Makefile:13281 : install-codecLTLIBRARIES] Erreur 1
make[5]: *** Attente des tâches non terminées....

Conflict between ffmpeg-rpi/ffmpeg installed. Workaround :

yay -Rdd ffmpeg
makepkg -scf
yay -Sd ffmpeg

Is the pipewire line here part of the recommendations or is that just in your config? I’m having trouble getting pipewire working that’s why I’m curious

it will be in the next version of mpv, it’s not mandatory. i use mpv-pipewire or mpv-git. Since i have discovered vlc-rpi i use mpv only with ff2mpv to play youtube video in mpv (see the youtube-dlp in my config).