blitzloop icon indicating copy to clipboard operation
blitzloop copied to clipboard

EGL_NOT_INITIALIZED (EGLError) on RaspberryPi

Open jose1711 opened this issue 3 years ago • 17 comments

Following instructions in blitzberry.md I am stuck with the following error:

$ blitzloop --mpv-ao=alsa --no-audioengine
Loading song DB...
Done.
Display mode: 1920x1080
Traceback (most recent call last):
  File "/usr/bin/blitzloop", line 33, in <module>
    sys.exit(load_entry_point('blitzloop==0.1', 'console_scripts', 'blitzloop')())
  File "/usr/lib/python3.8/site-packages/blitzloop/main.py", line 59, in entry
    display = graphics.Display(opts.width, opts.height, opts.fullscreen)
  File "/usr/lib/python3.8/site-packages/blitzloop/graphics.py", line 33, in Display
    _display = rpi.Display(*args, **kwargs)
  File "/usr/lib/python3.8/site-packages/blitzloop/backend/rpi.py", line 102, in __init__
    egl.eglInitialize(self.disp, None, None)
  File "/usr/lib/python3.8/site-packages/OpenGL/platform/baseplatform.py", line 415, in __call__
    return self( *args, **named )
  File "/usr/lib/python3.8/site-packages/OpenGL/error.py", line 230, in glCheckError
    raise self._errorClass(
OpenGL.raw.EGL._errors.EGLError: EGLError(
	err = EGL_NOT_INITIALIZED,
	baseOperation = eglInitialize,
	cArguments = (
		<OpenGL._opaque.EGLDisplay_pointer object at 0x6b922148>,
		None,
		None,
	),
	result = 0
)

and have no idea how to proceed. Raspberry is a 3B+ model.

jose1711 avatar Oct 29 '20 13:10 jose1711

This is without X, running on the text terminal?

Can you check your libEGL.so.* in the library path, and that /opt/vc/lib/libEGL.so exists? Maybe add a print(name) at the top of find_library. I get the feeling that the wrong EGL library is being loaded.

Can you use mpv --vo=rpi to play back videos with mpv normally?

marcan avatar Oct 30 '20 09:10 marcan

Running from text terminal. libEGL exists:

[alarm@alarmpi blitzloop]$ ls -l /opt/vc/lib/libEGL.so 
-rw-r--r-- 1 root root 202072 Oct 16 18:14 /opt/vc/lib/libEGL.so
[alarm@alarmpi blitzloop]$ md5sum /opt/vc/lib/libEGL.so 
31494c335a11c07beceb259b48efe3e6  /opt/vc/lib/libEGL.so

Setting LD_LIBRARY_PATH to /opt/vc/lib prior to running blitzloop yields the same error.

Looks like find_library(name) is not being called at all (as print was not invoked and intentional typo I made did not raise exception either).

rpi output is not recognized by mpv:

[alarm@alarmpi ~]$ mpv --vo=rpi video.mp4
 (+) Video --vid=1 (*) (h264 1280x720 25.000fps)
 (+) Audio --aid=1 (*) (aac 2ch 48000Hz)
[vo] Video output rpi not found!
Error opening/initializing the selected video_out (--vo) device.
Video: no video


Exiting... (Errors when loading file)

[alarm@alarmpi ~]$ pacman -Q mpv
mpv 1:0.32.0-4

[alarm@alarmpi ~]$ mpv -vo help
The legacy option syntax ('-vo value') is deprecated and dangerous.
Please use '--vo=value'.
Available video outputs:
  libmpv           render API for libmpv
  gpu              Shader-based GPU Renderer
  vdpau            VDPAU with X11
  wlshm            Wayland SHM video output
  xv               X11/Xv
  vaapi            VA API with X11
  x11              X11 (slow, old crap)
  null             Null video output
  image            Write video frames to image files
  tct              true-color terminals
  caca             libcaca
  drm              Direct Rendering Manager

jose1711 avatar Oct 30 '20 11:10 jose1711

Shortly after sending this I realized I did not have mpv-rpi installed (only mpv which conflicts with it). Sadly the compilation of its dependency - ffmpeg-mmal is keeping me from building it :-(

jose1711 avatar Oct 30 '20 12:10 jose1711

Yeah, ffmpeg-mmal is a pain in the ass to build.

The thing is, as far as I know you need that to get the video decode acceleration... So it's pretty much a requirement. BlitzLoop on the Rpi3 is already barely holding on on that CPU, without video decode accel it'll be a mess.

It's possible that installing those pulls in some dependency that fixes BlitzLoop too...

marcan avatar Oct 30 '20 13:10 marcan

I believe it might be possible to use BlitzLoop with the drm (fkms) codepath on rPi, and iff you can get video decode accel that would be fine probably, but I'm not holding my breath...

marcan avatar Oct 30 '20 13:10 marcan

Ok, I managed to build both ffmpeg-mmal and mpv-rpi after all. Now I am getting different error:

[alarm@alarmpi ~]$ mpv --vo=rpi video.mp4 
 (+) Video --vid=1 (*) (h264 1280x720 25.000fps)
 (+) Audio --aid=1 (*) (aac 2ch 48000Hz)
[vo/rpi] Could not get DISPMANX objects.
Error opening/initializing the selected video_out (--vo) device.
Video: no video


Exiting... (Errors when loading file)

jose1711 avatar Oct 30 '20 14:10 jose1711

At least it's clearly not a BlitzLoop problem... I wonder if something changed in Arch Linux ARM somewhere along the way, or something else is different about your setup...

marcan avatar Oct 30 '20 14:10 marcan

After reading https://github.com/mpv-player/mpv/issues/7314 I decided to try compile an older version of mpv (0.29.1) and it finally worked:

[alarm@alarmpi ~]$ mpv -fs --vo=rpi video.mp4 
Playing: video.mp4
 (+) Video --vid=1 (*) (h264 1280x720 25.000fps)
 (+) Audio --aid=1 (*) (aac 2ch 48000Hz)
Using hardware decoding (mmal).
AO: [alsa] 48000Hz stereo 2ch float
VO: [rpi] 1280x720 mmal

Video plays smoothly. Sadly the error reported by blitzloop did not go away.

jose1711 avatar Oct 30 '20 15:10 jose1711

Interesting. I'll take a look, but I'm quite busy right now and might not get to doing a full repro on a rPi in quite a while...

marcan avatar Oct 30 '20 16:10 marcan

If you want: to speed things up I can make an image of the SD card (contains nothing but a fresh Arch Linux + blitzloop) and publish it somewhere.

jose1711 avatar Oct 30 '20 17:10 jose1711

That might help, but I still probably won't get to it for a few weeks... I'm catching up on quick GitHub things but I'm a bit too swamped for a proper hardware device debugging session right now :(

marcan avatar Oct 30 '20 19:10 marcan

Ok, putting my RPi on a shelf then. Feel free to ping me once you have some free cycles and I'll send it to you.

jose1711 avatar Oct 31 '20 21:10 jose1711

@jose1711 can you try building mpv-0.33.1 with this PR I sent to mpv? https://github.com/mpv-player/mpv/pull/9097

cyph84 avatar Oct 10 '21 03:10 cyph84

@cyph84 Please allow the following questions:

  • do I still need to build ffmpeg-mmal prior to recompilation instead of using regular ffmpeg and have mpv detect it during configuration?
  • is mpv supposed to recognize --vo=rpi?

jose1711 avatar Nov 01 '21 09:11 jose1711

Following https://forums.raspberrypi.com/viewtopic.php?t=270226#p1692111 I was able to make it work finally. Extra steps taken in addition to what's mentioned in https://github.com/marcan/blitzloop/blob/master/docs/blitzberry.md:

  • Install ffmpeg-mmal from AUR
  • Download PKGBUILD of mpv-git from AUR and make the following modifications:
source=('git+https://github.com/cyph84/mpv#branch=fix-rpi-library-order'
..
        --enable-libmpv-shared --enable-rpi \
  • Build and install mpv-git. As a result mpv -vo help should list rpi - Raspberry Pi (MMAL) among supported outputs.
  • Create symbolic links in /opt/vc/lib:
cd /opt/vc/lib
sudo ln -s libbrcmEGL.so libEGL.so.1
sudo ln -s libbrcmGLESv2.so libGLESv2.so.2
  • Populate /boot/config.txt:
dtparam=audio=on
gpu_mem=384
initramfs initramfs-linux.img followkernel
  • Edit /home/alarm/startblitz.sh:
#!/bin/sh
export LD_LIBRARY_PATH=/opt/vc/lib
cd "$(dirname "$0")"
amixer cset numid=3 2
python -u /usr/bin/blitzloop --port=80 --no-audioengine --mpv-ao=alsa

This makes blitzloop work on an updated Arch Linux. What I left untested is microphone and jackd config.

jose1711 avatar Nov 01 '21 16:11 jose1711

@cyph84 Please allow the following questions:

* do I still need to build `ffmpeg-mmal` prior to recompilation instead of using regular `ffmpeg` and have `mpv` detect it during configuration?

You can build against regular ffmpeg, but you need ffmpeg-mmal installed to use --hwdec=mmal

* is `mpv` supposed to recognize `--vo=rpi`?

I think its best you explicitly specify the vo

cyph84 avatar Nov 02 '21 03:11 cyph84

Btw compiling latest mpv-git still results in [vo/rpi] Could not get DISPMANX objects. so https://github.com/mpv-player/mpv/pull/9097 is indeed required.

jose1711 avatar Nov 07 '21 14:11 jose1711