mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
27.61k stars 2.86k forks source link

h264_v4l2m2m: capture VIDIOC_REQBUFS failed: Cannot allocate memory with amlogic meson vdec decoder #8825

Closed danboid closed 3 years ago

danboid commented 3 years ago

Important Information

Provide following Information:

git commit ded36a4470a5970693ee0ceb2f43baa5db470cd3 Date: Tue May 11 22:22:33 2021 +0200

Manjaro ARM running Linux 5.11.13-1-MANJARO-ARM

built from git

No

MATE 1.24.1

mesa 21.0.3-3

Reproduction steps

I have installed Manjaro ARM on a T95 MAX Plus Android TV box, which is based upon the Amlogic S905X3 SoC. It only cost me £45 new and this looks like it will be a very cool and very affordable ARM Linux box when Panfrost support matures and we have hw accelerated mpv working, of course!

mpv was demonstrated working with hw acceleration on a very similar amlogic soc in this video so I have been using the same mpv command to test it. The mpv demo comes at about 5:30:

https://www.youtube.com/watch?v=J9EuXwxVik0

I have been told by one of the libreelec and by one of the majaro devs that ffmpeg needs to be patched in order to use the v4l2m2m copy feature so I built and installed a custom ffmpeg package from:

https://gitlab.manjaro.org/manjaro-arm/packages/community/ffmpeg-m2m/-/tree/master

Then I built a mpv package from the latest git tree as of today using a slightly tweaked version of the official arch mpv PKGBUILD.

As in the video, I've been using a command like this to play a 30 fps 4K h264 file:

mpv --hwdec=auto --hwdec-codecs=all VID_20210511_140223.mp4

Expected behavior

Smooth video playback.

Actual behavior

Hundreds of frames are dropped playing a 30 second video. Playback appears to be under 15/10 fps

Log file

$ mpv --hwdec=auto --hwdec-codecs=all VID_20210511_140223.mp4
 (+) Video --vid=1 (*) (h264 3840x2160 30.009fps)
 (+) Audio --aid=1 --alang=eng (*) (aac 2ch 48000Hz)
Cannot load libcuda.so.1
[vaapi] libva: vaGetDriverNameByIndex() failed with unknown libva error, driver_name = (null)
Failed to open VDPAU backend libvdpau_meson.so: cannot open shared object file: No such file or directory
AO: [pulse] 48000Hz stereo 2ch float
[ffmpeg/video] h264_v4l2m2m: capture VIDIOC_REQBUFS failed: Cannot allocate memory
[ffmpeg/video] h264_v4l2m2m: can't request capture buffers
Error while decoding frame (hardware decoding)!
[ffmpeg/video] h264_v4l2m2m: capture VIDIOC_REQBUFS failed: Cannot allocate memory
[ffmpeg/video] h264_v4l2m2m: can't request capture buffers
Error while decoding frame (hardware decoding)!
[ffmpeg/video] h264_v4l2m2m: capture VIDIOC_REQBUFS failed: Cannot allocate memory
[ffmpeg/video] h264_v4l2m2m: can't request capture buffers
Error while decoding frame (hardware decoding)!
[ffmpeg/video] h264_v4l2m2m: VIDIOC_STREAMON capture error: -22
VO: [gpu] 3840x2160 yuv420p
AV: 00:00:00 / 00:00:30 (1%) A-V:  0.337 Dropped: 5

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:00:30 / 00:00:30 (100%) A-V:  0.000 Dropped: 552

Exiting... (End of file)
danboid commented 3 years ago

Note about:

Failed to open VDPAU backend libvdpau_meson.so: cannot open shared object file: No such file or directory

Not only is there no libvdpau_meson.so in the Manjaro libvdpau packages but I have read reports of people who have got mpv to work with the meson vdec decoder using the same command on the Manjaro forums albeit playing 1080p videos. They didn't note what kernel they were running but the comment I'm looking at now was posted in November of last year.

sfan5 commented 3 years ago

Sample file?

I have been told by one of the libreelec and by one of the majaro devs that ffmpeg needs to be patched in order to use the v4l2m2m copy feature

Without more specifics this is provably false (might've been that way in the past). I just successfully tested v4l2m2m-copy with an unmodified ffmpeg 4.4.

danboid commented 3 years ago

Hi @sfan5 !

I have uninstalled my custom packages and reverted to the regular Manjaro packages for ffmpeg 4.4 and mpv 0.33.1 but I still get the same errors when trying to play h264 files such as this short test clip:

https://drive.google.com/file/d/14z1Gd8zXbJ2XWvULvmWXeqLVRcgUHo2p/view?usp=sharing

What platform / OS / GPU are you using @sfan5 ?

I have not tried mpv under wayland yet but I prefer MATE over KDE and GNOME so I'd like this to work under MATE & Xorg ideally.

sfan5 commented 3 years ago

I tested a 1080p H.264 video, which worked fine. With your file I get the exact same errors you reported initially.

The SoC is specified to support H.264AVC HP@L5.1up to 4Kx2K@30fps so I guess there's some other reason that this is hitting resource limits.

What platform / OS / GPU are you using @sfan5 ?

Arch Linux on an ODROID-C4. It has the same Amlogic S905X3 SoC. I tested headless (--vo=null --no-audio) so I could do it over SSH, the DE doesn't make a difference here.

danboid commented 3 years ago

I'm going to close this because I have discovered how much better plasma wayland runs on my TV box under Manjaro unstable vs any other X desktop/wm. I can't go back to X now, not on my ARM/Mali boxes, at least.

I still cannot get the test video to play with mpv but I get a different set of errors so I shall open a new bug report targetting wayland.