marcan / blitzloop

Open source karaoke software
GNU General Public License v2.0
207 stars 31 forks source link

EGL_NOT_INITIALIZED (EGLError) on RaspberryPi #52

Open jose1711 opened 4 years ago

jose1711 commented 4 years ago

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.

marcan commented 4 years ago

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?

jose1711 commented 4 years ago

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 commented 4 years ago

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

marcan commented 4 years ago

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 commented 4 years ago

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...

jose1711 commented 4 years ago

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)
marcan commented 4 years ago

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...

jose1711 commented 4 years ago

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.

marcan commented 4 years ago

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...

jose1711 commented 4 years ago

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.

marcan commented 4 years ago

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

jose1711 commented 4 years ago

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.

cyph84 commented 3 years ago

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

jose1711 commented 3 years ago

@cyph84 Please allow the following questions:

jose1711 commented 3 years ago

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:

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

cyph84 commented 3 years ago

@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

jose1711 commented 3 years ago

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.