veldenb / plugin.program.moonlight-qt

A launcher and updater for running Moonlight-qt on LibreELEC.
GNU General Public License v3.0
94 stars 15 forks source link

CoreELEC support #48

Open mvrk69 opened 10 months ago

mvrk69 commented 10 months ago

Hi,

Is there any possibility of a version for CoreELEC (ODROID-C4)?

veldenb commented 10 months ago

From moonlight-qt 5.0.0 and up there seem to be generic ARM packages available, so it might be possible. I own a ODROID-C2 so that might be comparable to the C4 for testing. I'll give it a try when I have some spare time :)

edit: if you want to try for yourself, see this guide to install it on a Debian image to check if it can work with your hardware: https://github.com/moonlight-stream/moonlight-docs/wiki/Installing-Moonlight-Qt-on-ARM%E2%80%90based-Single-Board-Computers

veldenb commented 9 months ago

I tried this manual to install moonlight-qt on my C2 with Armbian, but my device isn't compatible with moonlight-qt. It starts but very quickly segfaults:

moonlight-qt log ``` 00:00:00 - Qt Info: Unable to detect Wayland or X11, so EGLFS will be used by default. Set QT_QPA_PLATFORM to override this. 00:00:00 - Qt Info: Setting display mode by default. Set QT_QPA_EGLFS_ALWAYS_SET_MODE=0 to override this. 00:00:01 - Qt Warning: Failed to move cursor on screen HDMI1: -14 00:00:01 - Qt Warning: Failed to move cursor on screen HDMI1: -14 00:00:01 - Qt Warning: Could not set cursor on screen HDMI1: -6 00:00:01 - SDL Info (0): Compiled with SDL 2.29.0 00:00:01 - SDL Info (0): Running with SDL 2.29.0 00:00:01 - Qt Info: Successfully loaded translation for "nl_NL" 00:00:01 - Qt Warning: qrc:/gui/main.qml:13:1: QML ApplicationWindow: ToolTip must be attached to an Item 00:00:01 - Qt Info: Found "gamecontrollerdb.txt" at ":/data/gamecontrollerdb.txt" 00:00:01 - SDL Info (0): Loaded 296 new gamepad mappings 00:00:02 - SDL Info (0): V-sync disabled 00:00:02 - SDL Info (0): Sharing DRM FD with SDL 00:00:02 - SDL Info (0): GPU driver: meson 00:00:02 - SDL Error (0): Failed to find suitable overlay plane! 00:00:02 - SDL Info (0): Sharing DRM FD with SDL 00:00:02 - SDL Info (0): GPU driver: meson 00:00:02 - SDL Error (0): Failed to find suitable overlay plane! 00:00:02 - SDL Info (0): Sharing DRM FD with SDL 00:00:02 - SDL Info (0): GPU driver: meson 00:00:02 - SDL Error (0): Failed to find suitable overlay plane! 00:00:02 - SDL Info (0): DRM backend supports exporting EGLImage 00:00:02 - SDL Info (0): Color buffer is: R8G8B8A8 00:00:02 - SDL Info (0): EGL passed preflight checks. Using EGL for GL context creation. 00:00:02 - SDL Info (0): Using DRM renderer 00:00:02 - FFmpeg: [hevc @ 0xaaaafb931950] nal_unit_type: 32(VPS), nuh_layer_id: 0, temporal_id: 0 00:00:02 - FFmpeg: [hevc @ 0xaaaafb931950] nal_unit_type: 33(SPS), nuh_layer_id: 0, temporal_id: 0 00:00:02 - FFmpeg: [hevc @ 0xaaaafb931950] nal_unit_type: 34(PPS), nuh_layer_id: 0, temporal_id: 0 00:00:02 - FFmpeg: [hevc @ 0xaaaafb931950] nal_unit_type: 21(CRA_NUT), nuh_layer_id: 0, temporal_id: 0 00:00:02 - FFmpeg: [hevc @ 0xaaaafb931950] nal_unit_type: 21(CRA_NUT), nuh_layer_id: 0, temporal_id: 0 00:00:02 - FFmpeg: [hevc @ 0xaaaafb931950] nal_unit_type: 21(CRA_NUT), nuh_layer_id: 0, temporal_id: 0 00:00:02 - FFmpeg: [hevc @ 0xaaaafb931950] nal_unit_type: 21(CRA_NUT), nuh_layer_id: 0, temporal_id: 0 00:00:02 - FFmpeg: [hevc @ 0xaaaafb931950] Decoding VPS 00:00:02 - FFmpeg: [hevc @ 0xaaaafb931950] Main 10 profile bitstream 00:00:02 - FFmpeg: [hevc @ 0xaaaafb931950] Decoding SPS 00:00:02 - FFmpeg: [hevc @ 0xaaaafb931950] Main 10 profile bitstream 00:00:02 - FFmpeg: [hevc @ 0xaaaafb931950] Decoding VUI 00:00:02 - FFmpeg: [hevc @ 0xaaaafb931950] Decoding PPS 00:00:02 - FFmpeg: [hevc @ 0xaaaafb931950] Format drm_prime chosen by get_format(). 00:00:02 - FFmpeg: [hevc @ 0xaaaafb931950] Format drm_prime requires hwaccel initialisation. 00:00:02 - FFmpeg: [hevc @ 0xaaaafb931950] ff_v4l2_request_init: avctx=0xaaaafb931950 hw_device_ctx=0xaaaafc7a6730 hw_frames_ctx=(nil) 00:00:02 - FFmpeg: [hevc @ 0xaaaafb931950] Failed setup for format drm_prime: hwaccel initialisation returned error. 00:00:02 - FFmpeg: [hevc @ 0xaaaafb931950] Format drm_prime not usable, retrying get_format() without it. 00:00:02 - FFmpeg: [hevc @ 0xaaaafb931950] Error parsing NAL unit #3. 00:00:02 - SDL Warn (0): Test decode failed (avcodec_send_packet): Actie is niet toegestaan 00:00:02 - SDL Info (0): Trying DrmRenderer for codec hevc_v4l2m2m due to preferred pixel format: 0xb3 00:00:02 - SDL Info (0): Sharing DRM FD with SDL 00:00:02 - SDL Info (0): GPU driver: meson 00:00:02 - SDL Error (0): Failed to find suitable overlay plane! 00:00:02 - SDL Info (0): Sharing DRM FD with SDL 00:00:02 - SDL Info (0): GPU driver: meson 00:00:02 - SDL Error (0): Failed to find suitable overlay plane! 00:00:02 - SDL Info (0): Sharing DRM FD with SDL 00:00:02 - SDL Info (0): GPU driver: meson 00:00:02 - SDL Error (0): Failed to find suitable overlay plane! 00:00:02 - SDL Info (0): DRM backend supports exporting EGLImage 00:00:03 - SDL Info (0): Color buffer is: R8G8B8A8 00:00:03 - SDL Info (0): EGL passed preflight checks. Using EGL for GL context creation. 00:00:03 - SDL Info (0): Using DRM renderer 00:00:03 - FFmpeg: [hevc_mp4toannexb @ 0xaaaafc1214f0] The input looks like it is Annex B already 00:00:03 - FFmpeg: [hevc_v4l2m2m @ 0xaaaafb931950] Format drm_prime chosen by get_format(). 00:00:03 - FFmpeg: [hevc_v4l2m2m @ 0xaaaafb931950] probing device /dev/video0 00:00:03 - FFmpeg: [hevc_v4l2m2m @ 0xaaaafb931950] driver 'meson-vdec' on card 'Amlogic Video Decoder' in mplane mode 00:00:03 - FFmpeg: [hevc_v4l2m2m @ 0xaaaafb931950] v4l2 capture format not supported 00:00:03 - FFmpeg: [hevc_v4l2m2m @ 0xaaaafb931950] Could not find a valid device 00:00:03 - FFmpeg: [hevc_v4l2m2m @ 0xaaaafb931950] can't configure decoder 00:00:03 - SDL Error (0): Unable to open decoder for format: 200 00:00:03 - SDL Info (0): Trying DrmRenderer for codec hevc_v4l2m2m due to compatible pixel format: 0x17 00:00:03 - SDL Info (0): Sharing DRM FD with SDL 00:00:03 - SDL Info (0): GPU driver: meson 00:00:03 - SDL Error (0): Failed to find suitable overlay plane! 00:00:03 - SDL Info (0): Sharing DRM FD with SDL 00:00:03 - SDL Info (0): GPU driver: meson 00:00:03 - SDL Error (0): Failed to find suitable overlay plane! 00:00:03 - SDL Info (0): Sharing DRM FD with SDL 00:00:03 - SDL Info (0): GPU driver: meson 00:00:03 - SDL Error (0): Failed to find suitable overlay plane! 00:00:03 - SDL Info (0): DRM backend supports exporting EGLImage 00:00:03 - SDL Info (0): Color buffer is: R8G8B8A8 00:00:03 - SDL Info (0): EGL passed preflight checks. Using EGL for GL context creation. 00:00:03 - SDL Info (0): Using DRM renderer 00:00:03 - FFmpeg: [hevc_mp4toannexb @ 0xaaaafc357a00] The input looks like it is Annex B already 00:00:03 - FFmpeg: [hevc_v4l2m2m @ 0xaaaafb931950] Format nv12 chosen by get_format(). 00:00:03 - FFmpeg: [hevc_v4l2m2m @ 0xaaaafb931950] probing device /dev/video0 00:00:03 - FFmpeg: [hevc_v4l2m2m @ 0xaaaafb931950] driver 'meson-vdec' on card 'Amlogic Video Decoder' in mplane mode 00:00:03 - FFmpeg: [hevc_v4l2m2m @ 0xaaaafb931950] Using device /dev/video0 00:00:03 - FFmpeg: [hevc_v4l2m2m @ 0xaaaafb931950] driver 'meson-vdec' on card 'Amlogic Video Decoder' in mplane mode 00:00:03 - FFmpeg: [hevc_v4l2m2m @ 0xaaaafb931950] requesting formats: output=HEVC/none capture=NM12/nv12 00:00:03 - FFmpeg: [hevc_v4l2m2m @ 0xaaaafb931950] output: HEVC 16 buffers initialized: 1280x0720, sizeimage 00691328, bytesperline 00000000 00:00:03 - FFmpeg: [hevc_v4l2m2m @ 0xaaaafb931950] VIDIOC_STREAMON on output context Segmentation fault ```

Can you try the same manual to see if it works with your C4 so we can check compatibility?

veldenb commented 8 months ago

Version 0.4.3 has an experimental Amlogic build, feel free to try it on LibreELEC Amlogic or CoreELEC.

skupi20 commented 8 months ago

nice to see its coming for amlogic :) i tried it on coreelec NE kodi 20 version but actually whole system is aarch64 now. New kernel version NO too. So plugin compiled wrong version of moonlight-qt, i get exec error"

bootstrap_moonlight-qt.sh: line 120: ./moonlight-qt: cannot execute binary file: Exec format error

I will try coreelec old kernel version NG which is still arm.

my build.log:

Platform amlogic-ce (aarch64) running coreelec 20.3 detected, using platform generic... Building generic_local_libs... removed 'moonlight-qt/bin/moonlight-qt' removed directory: 'moonlight-qt/bin' removed directory: 'moonlight-qt' 'tmp' -> 'moonlight-qt'

my moonlight-qt.log

Platform amlogic-ce (aarch64) running coreelec 20.3 detected, using platform generic... Running without window manager... Detected resolution 1920,2160... Using Qt scale factor 1.28... --- Starting Moonlight --- bootstrap_moonlight-qt.sh: line 120: ./moonlight-qt: cannot execute binary file: Exec format error

os-release

NAME="CoreELEC" VERSION="20.3-Nexus" ID="coreelec" VERSION_ID="20.3" PRETTY_NAME="CoreELEC (official): 20.3-Nexus" HOME_URL="https://coreelec.org" BUG_REPORT_URL="https://github.com/CoreELEC/CoreELEC" LIBREELEC_ARCH="Amlogic-ne.aarch64" LIBREELEC_BUILD="official" LIBREELEC_PROJECT="Amlogic-ce" COREELEC_ARCH="Amlogic-ne.aarch64" COREELEC_BUILD="official" COREELEC_PROJECT="Amlogic-ce" COREELEC_DEVICE="Amlogic-ne"

veldenb commented 8 months ago

CoreELEC seems to add a -ce suffix, I added a workaround for it in this version. Can you try if this helps?

skupi20 commented 8 months ago

Oki, its build a lot :) i cant write build.log, cause after restart was deleted,

my moolight-qt.log

Platform amlogic (aarch64) running coreelec 20.3 detected... Using custom libraries from /storage/.kodi/userdata/addon_data/plugin.program.moonlight-qt/moonlight-qt/lib... Using Qt library from /storage/.kodi/userdata/addon_data/plugin.program.moonlight-qt/moonlight-qt/lib/qt5... Running without window manager... Detected resolution 1920,2160... Using Qt scale factor 1.28... --- Starting Moonlight --- 00:00:00 - Qt Info: Unable to detect Wayland or X11, so EGLFS will be used by default. Set QT_QPA_PLATFORM to override this. 00:00:00 - Qt Info: Setting display mode by default. Set QT_QPA_EGLFS_ALWAYS_SET_MODE=0 to override this. 00:00:00 - Qt Warning: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root' 00:00:00 - Qt Warning: Failed to load EGL device integration "eglfs_kms" 00:00:00 - Qt Fatal: EGL library doesn't support Emulator extensions bootstrap_moonlight-qt.sh: line 120: 1312 Aborted ./moonlight-qt "$@"

mvrk69 commented 8 months ago

CoreELEC seems to add a -ce suffix, I added a workaround for it in this version. Can you try if this helps?

Hi,

With this version, on my CoreELEC-Amlogic-ng.arm-19.5-Matrix-Odroid_C4, seems to build ok, but i end up with wrong architecture binary:

.../addon_data/plugin.program.moonlight-qt/moonlight-qt/bin # ldd moonlight-qt $ not a dynamic executable

I think binaries in CoreELEC for ODROID-C4 are armhf not arm64, runs a 64-bit kernel, but userspace is 32-bit.

mvrk69 commented 8 months ago

After adding some workarounds on the scripts:

on plugin.program.moonlight-qt/resources/bin/bootstrap_moonlight-qt.sh changed if [ "$PLATFORM_DISTRO" == "libreelec" ]; then to if [ "$PLATFORM_DISTRO" == "libreelec" ] || [ "$PLATFORM_DISTRO" == "coreelec" ]; then

on plugin.program.moonlight-qt/resources/bin/get-platform.sh changed if [ "$LIBREELEC_ARCH" == "RPi4.arm" ]; then to if [ "$LIBREELEC_ARCH" == "RPi4.arm" ] || [ "$LIBREELEC_ARCH" == "Amlogic-ng.arm" ]; then

on plugin.program.moonlight-qt/resources/bin/kodi_hooks/ created a symlink called coreelec pointing to libreelec

Now with all this changes, it built the the binaries for the correct architecture (armhf), but now i have this error when it tries to run moonlight:

Platform amlogic (armhf) running coreelec 20.3 detected... Loading LibreELEC profile for setting up environment... Using custom libraries from /storage/.kodi/userdata/profiles/Maverick/addon_data/plugin.program.moonlight-qt/moonlight-qt/lib... Using Qt library from /storage/.kodi/userdata/profiles/Maverick/addon_data/plugin.program.moonlight-qt/moonlight-qt/lib/qt5... Running without window manager... Detected resolution 1920,2160... Using Qt scale factor 1.28... Using Kodi hooks for coreelec... --- Starting Moonlight --- 00:00:00 - Qt Info: Unable to detect Wayland or X11, so EGLFS will be used by default. Set QT_QPA_PLATFORM to override this. 00:00:00 - Qt Info: Setting display mode by default. Set QT_QPA_EGLFS_ALWAYS_SET_MODE=0 to override this. 00:00:00 - Qt Warning: Unable to find a KMSDRM display device! 00:00:00 - Qt Warning: On the Raspberry Pi, you must enable the 'fake KMS' driver in raspi-config to use Moonlight outside of the GUI environment. 00:00:00 - Qt Warning: Failed to load EGL device integration "eglfs_kms" 00:00:00 - Qt Fatal: EGL library doesn't support Emulator extensions bootstrap_moonlight-qt.sh: line 128: 21200 Aborted ./moonlight-qt "$@"

veldenb commented 8 months ago

I got some success getting amlogic to work. I removed some Pi-stuff from the 32-bit amlogic build and added quirks for known amlogic 64-bit kernels with 32-bit userspace. Also added hooks for CoreELEC.

My ODROID-C2 is not supported anymore on CoreELEC but it is on LibreELEC and I got it running by forcing the dri card to /dev/dri/card0. There was already a similar quirk for the Pi 5 so I decided to replace that with an option in the settings menu to force a specific card. The C2 managed to stream on 720p fairly decent for such an old device, 1080p didn't work (black screen).

Could you try the latest version and check if building ("Update moonlight to latest version") works better and get it running, optionally by forcing card0 or card1?

mvrk69 commented 8 months ago

With the new version i still get this error when i try to launch moonlight:

moonlight-qt.log: Platform amlogic (armhf) running coreelec 20.3 detected... Loading LibreELEC profile for setting up environment... Using custom libraries from /storage/.kodi/userdata/profiles/Maverick/addon_data/plugin.program.moonlight-qt/moonlight-qt/lib... Using Qt library from /storage/.kodi/userdata/profiles/Maverick/addon_data/plugin.program.moonlight-qt/moonlight-qt/lib/qt5... Running without window manager... Detected resolution 1920,2160... Using Qt scale factor 1.28... Using Kodi hooks for coreelec... --- Starting Moonlight --- 00:00:00 - Qt Info: Unable to detect Wayland or X11, so EGLFS will be used by default. Set QT_QPA_PLATFORM to override this. 00:00:00 - Qt Info: Setting display mode by default. Set QT_QPA_EGLFS_ALWAYS_SET_MODE=0 to override this. 00:00:00 - Qt Warning: Unable to find a KMSDRM display device! 00:00:00 - Qt Warning: On the Raspberry Pi, you must enable the 'fake KMS' driver in raspi-config to use Moonlight outside of the GUI environment. 00:00:00 - Qt Warning: QStandardPaths: wrong permissions on runtime directory /var/run/, 0755 instead of 0700 00:00:00 - Qt Warning: Failed to load EGL device integration "eglfs_kms" 00:00:00 - Qt Fatal: EGL library doesn't support Emulator extensions bootstrap_moonlight-qt.sh: line 120: 4738 Aborted ./moonlight-qt "$@"

Can you explain what you mean by forcing dri card?

On CoreELEC i don't have any /dev/dri.

veldenb commented 8 months ago

Can you explain what you mean by forcing dri card?

There is a new setting "EGL card" in the settings screen of the plugin in Kodi. You can now select card0 or card1 there to overwrite the default behaviour in moonlight. It was needed for my C2.

skupi20 commented 8 months ago

the same error no matter what card i choose

Platform amlogic (aarch64) running coreelec 20.3 detected... Loading LibreELEC profile for setting up environment... Using custom libraries from /storage/.kodi/userdata/addon_data/plugin.program.moonlight-qt/moonlight-qt/lib... Using Qt library from /storage/.kodi/userdata/addon_data/plugin.program.moonlight-qt/moonlight-qt/lib/qt5... Running without window manager... Forcing KMS mode: { "device": "/dev/dri/card0" } Detected resolution 1920,2160... Using Qt scale factor 1.28... Using Kodi hooks for coreelec... --- Starting Moonlight --- 00:00:00 - Qt Info: Unable to detect Wayland or X11, so EGLFS will be used by default. Set QT_QPA_PLATFORM to override this. 00:00:00 - Qt Info: Setting display mode by default. Set QT_QPA_EGLFS_ALWAYS_SET_MODE=0 to override this. 00:00:00 - Qt Warning: QStandardPaths: wrong permissions on runtime directory /var/run/, 0755 instead of 0700 00:00:00 - Qt Warning: Failed to load EGL device integration "eglfs_kms" 00:00:00 - Qt Fatal: EGL library doesn't support Emulator extensions bootstrap_moonlight-qt.sh: line 120: 4300 Aborted ./moonlight-qt "$@"

mvrk69 commented 8 months ago

Yes, same as me:

Platform amlogic (armhf) running coreelec 20.3 detected... Loading LibreELEC profile for setting up environment... Using custom libraries from /storage/.kodi/userdata/profiles/Maverick/addon_data/plugin.program.moonlight-qt/moonlight-qt/lib... Using Qt library from /storage/.kodi/userdata/profiles/Maverick/addon_data/plugin.program.moonlight-qt/moonlight-qt/lib/qt5... Running without window manager... Forcing KMS mode: { "device": "/dev/dri/card0" }

Detected resolution 1920,2160... Using Qt scale factor 1.28... Using Kodi hooks for coreelec... --- Starting Moonlight --- 00:00:00 - Qt Info: Unable to detect Wayland or X11, so EGLFS will be used by default. Set QT_QPA_PLATFORM to override this. 00:00:00 - Qt Info: Setting display mode by default. Set QT_QPA_EGLFS_ALWAYS_SET_MODE=0 to override this. 00:00:00 - Qt Warning: Unable to find a KMSDRM display device! 00:00:00 - Qt Warning: On the Raspberry Pi, you must enable the 'fake KMS' driver in raspi-config to use Moonlight outside of the GUI environment. 00:00:00 - Qt Warning: QStandardPaths: wrong permissions on runtime directory /var/run/, 0755 instead of 0700 00:00:00 - Qt Warning: Failed to load EGL device integration "eglfs_kms" 00:00:00 - Qt Fatal: EGL library doesn't support Emulator extensions bootstrap_moonlight-qt.sh: line 120: 7738 Aborted ./moonlight-qt "$@"

Seems CoreELEC doesn't have any dri devices:

odroidc4:~ # ls -l /dev/dri/card0 ls: /dev/dri/card0: No such file or directory

odroidc4:~ # ls -l /dev/dri/card1 ls: /dev/dri/card1: No such file or directory

odroidc4:~ # ls -l /dev/dri ls: /dev/dri: No such file or directory

veldenb commented 8 months ago

Strange, can you try the LibreELEC Amlogic build? Not sure but it looks like CoreELEC is missing some functionality.

skupi20 commented 8 months ago

my dri folder, so i have card 0, and error is the same. Iam using 20NE version.

CoreELEC:/dev/dri # ls by-path card0 renderD128

veldenb commented 8 months ago

Could you try the LibreELEC builds to figure out if this is software or hardware related?

tpoltorak commented 1 week ago

Any news on this feature? I've installed 0.4.3 and 0.4.4 versions on Ugoos AM6B+ but Moonlight isn't starting. On 0.4.4 it restarts Kodi.