FDH2 / UxPlay

AirPlay Unix mirroring server
GNU General Public License v3.0
1.35k stars 72 forks source link

Error connecting to UxPlay on Raspberry Pi #82

Closed xXPerditorXx closed 2 years ago

xXPerditorXx commented 2 years ago
error: XDG_RUNTIME_DIR not set in the environment.
error: XDG_RUNTIME_DIR not set in the environment.
using network ports UDP 36830 36831 36832 TCP 36836 36837 36838
using system MAC address dc:a6:32:b6:10:e2
Initialized server socket(s)
Accepted IPv4 client on socket 41
Local: 192.168.168.253
Remote: 192.168.168.34
Open connections: 1
Client identified as User-Agent: AirPlay/610.19.1
Accepted IPv4 client on socket 43
Local: 192.168.168.253
Remote: 192.168.168.34
Open connections: 2
raop_rtp_mirror starting mirroring
Begin streaming to GStreamer video pipeline
GStreamer error: failed to activate bufferpool
Removing connection for socket 41
Destroying connection
Open connections: 1
raop_rtp_mirror->running is no longer true
Removing connection for socket 43
Destroying connection
Open connections: 0
error: XDG_RUNTIME_DIR not set in the environment.
error: XDG_RUNTIME_DIR not set in the environment.
Initialized server socket(s)

Command I used: /usr/local/bin/uxplay -rpi -p tcp 36836 -p udp 36830 -n '404 NotFound' -nh -fps 30 -reset 3

Pi: Screenshot_20220402_201151

fduncanh commented 2 years ago

GStreamer error. (1) check tthat uxplay -rpi -avdec works (will have latency) (2) which version of gstreamer (1.18.4 or 1.18.5 ?) (3) did you patch libsgstv4l2dec.so according to the Wiki instructions?

fduncanh commented 2 years ago

Your image shows a non-desktop installation.

If you will use the framebuffer for video, the UxPlay README tells you to use uxplay -rpi -vs kmssink

from the README:

GPU Support for Raspberry Pi

you can find patching instructions in the UxPlay Wiki.

Use the options uxplay -rpi ( or uxplay -rpi -vs kmssink on RPi OS Lite with no X11) with the patched GStreamer. Patches for GStreamer-1.18.5 (used in Ubuntu 21.10 for RPi) and GStreamer-1.20.0 (used in Manjaro for RPi) are also available there.

fduncanh commented 2 years ago

I checked using the Debian "daily build" for RPi 4, and found it has an incomplete video4linux2 plugin. Ubuntu etc are complete. You solution is probably to rebuild from the official gstreamer -1.18.4 source, debian seems to have done something to it that removes the needed features. i will try this now, and update the UxPlay wiki.

EDIT: I didn't succeed. on Debian. see https://github.com/FDH2/UxPlay/wiki/Gstreamer-Video4Linux2-plugin-patches for what a correct output of gst-inspect-1.0 video4linux2 should look like

user@raspberrypi:~$ gst-inspect-1.0 video4linux2 Plugin Details: Name video4linux2 Description elements for Video 4 Linux Filename /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstvideo4linux2.so Version 1.18.4 License LGPL Source module gst-plugins-good Source release date 2021-03-15 Binary package GStreamer Good Plugins (Debian) Origin URL http://packages.qa.debian.org/gst-plugins-good1.0

v4l2deviceprovider: Video (video4linux2) Device Provider v4l2radio: Radio (video4linux2) Tuner v4l2sink: Video (video4linux2) Sink v4l2src: Video (video4linux2) Source

4 features: +-- 3 elements +-- 1 device providers

user@raspberrypi:~$ uname -a Linux raspberrypi 5.10.0-13-arm64 #1 SMP Debian 5.10.106-1 (2022-03-17) aarch64 GNU/Linux user@raspberrypi:~$

fduncanh commented 2 years ago

Rebuilding the complete gstreamer-1.18.4 on Debian Raspberry Pi didnt make the full set of video4linux2 plugins available.

What we need are the ones that use the Broadcom GPU I'm wondering if this is a Debian "non-free" issue.

  v4l2jpegdec: V4L2 JPEG Decoder
  v4l2h264dec: V4L2 H264 Decoder
  v4l2h264enc: V4L2 H.264 Encoder
  v4l2convert: V4L2 Video Converter
  v4l2video18convert: V4L2 Video Converter
  v4l2jpegenc: V4L2 JPEG Encoder

perhaps on pure Debian you need to do something extra to install or build the Broadcom kernel modules for decoding.

xXPerditorXx commented 2 years ago

I rebuilded gstreamer (1.18.4) what now?

EDIT: run gst-inspect-1.0 video4linux2 as described above to see if the V4L2 decoders are shown. My guess is that they are missing

fduncanh commented 2 years ago

Unfortunately this seems to be a specific Debian problem. You need the bcm2385-codec.ko kernel module which is where the hardware h264 decoding work is done. The Debian build I tested on doesn't supply that by default, probably because it is "non-free". Ubuntu , RPi OS, Manjaro etc all supply it. Hopefully there is some "non-free" Debian package for non-purists that allows you to add it or build it.

EDIT : without that bcm2385-codec kernel model, Debian on RPi would probably be worthless for video processing

I also saw that bcm_host.h header file is not found during the tests preparing the rebuild of gst-plugins-good on Debian. Probably this is a related issue that will be fixed by finding out how to add the bcm2385-codec module. I will check it this header is found when rebuilding on ubuntu 21.10, which works.

EDIT: not finding bcm_host.h is NOT a problem: it also isn't found during the sucessful rebuild on Ubuntu. My guess is that your rebuild is fine, but gst-inspect-1.0 might not show the v4l2 decoder plugins if no suitable kernel module is avalable (?).

xXPerditorXx commented 2 years ago

I have Raspbian OS installed not Debian

fduncanh commented 2 years ago

I haven't tried to support Raspian. It will work with RPiPlay using non-gstreamer OpenMax drivers, but the omx gstreamer drivers appear to be broken and no-one is supporting them anymore as they are 32 bit only with no future.

You did not report what gst-inspect-1.0 video4linux2 reports , or whether bcm2835.ko is present (ls -R /lib/modules | grep bcm)

xXPerditorXx commented 2 years ago

The first one:

Plugin Details:
  Name                     video4linux2
  Description              elements for Video 4 Linux
  Filename                 /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstvideo4linux2.so
  Version                  1.18.4
  License                  LGPL
  Source module            gst-plugins-good
  Source release date      2021-03-15
  Binary package           GStreamer Good Plugins (Debian)
  Origin URL               http://packages.qa.debian.org/gst-plugins-good1.0

  v4l2src: Video (video4linux2) Source
  v4l2sink: Video (video4linux2) Sink
  v4l2radio: Radio (video4linux2) Tuner
  v4l2deviceprovider: Video (video4linux2) Device Provider
  v4l2jpegdec: V4L2 JPEG Decoder
  v4l2h264dec: V4L2 H264 Decoder
  v4l2h264enc: V4L2 H.264 Encoder
  v4l2convert: V4L2 Video Converter
  v4l2video18convert: V4L2 Video Converter
  v4l2jpegenc: V4L2 JPEG Encoder

  10 features:
  +-- 9 elements
  +-- 1 device providers

The second one:

bcma
/lib/modules/5.15.30-v8+/kernel/drivers/bcma:
bcma.ko
bcm203x.ko
btbcm.ko
bcm2835_smi_dev.ko
i2c-bcm2708.ko
i2c-bcm2835.ko
bcm3510.ko
bcm2835
/lib/modules/5.15.30-v8+/kernel/drivers/media/platform/bcm2835:
bcm2835-unicam.ko
bcm2835_smi.ko
pwm-bcm2835.ko
spi-bcm2835.ko
spi-bcm2835aux.ko
bcm2835-audio
bcm2835-camera
bcm2835-codec
bcm2835-isp
/lib/modules/5.15.30-v8+/kernel/drivers/staging/vc04_services/bcm2835-audio:
snd-bcm2835.ko
/lib/modules/5.15.30-v8+/kernel/drivers/staging/vc04_services/bcm2835-camera:
bcm2835-v4l2.ko
/lib/modules/5.15.30-v8+/kernel/drivers/staging/vc04_services/bcm2835-codec:
bcm2835-codec.ko
/lib/modules/5.15.30-v8+/kernel/drivers/staging/vc04_services/bcm2835-isp:
bcm2835-isp.ko
bcm2835-mmal-vchiq.ko
can-bcm.ko
bcm
/lib/modules/5.15.30-v8+/kernel/sound/soc/bcm:
snd-soc-bcm2835-i2s.ko

I hope it can help you.

fduncanh commented 2 years ago

OK You have what it takes. Did you actually test after rebuilding? I assumed your question "I rebuilded gstreamer (1.18.4) what now?" meant you had finished all the instructions and it still didnt work, but you did not actually say that.

Which Raspian release are you using? I could test it. The image shows bullseye, but I though Raspian was finished with Buster, and the name is now "Raspberry Pi OS " (not Raspian) with Bullseye? I'm confused by seeing the debian symbol that you showed

fduncanh commented 2 years ago

OK It looks like you are running Raspberry Pi OS Kernel 5.15.30-v8.

This is Desktop not Lite? and it is not Debian, even though your splash screen image claims it is... (?) (Its Debian-based, but different in many ways).

Uxplay is working with this but seems not to work so well (latency) with new kernel 5.15.30-v8. It was working great with the previous kernel 5.10.103-v71.

Just read and follow the instructions in the Wiki and README.

xXPerditorXx commented 2 years ago

I think neofetch isn't detecting Raspberry Pi OS. It's a new version 64Bit based. If you open the rpi-imager it's on top.

fduncanh commented 2 years ago

@xXPerditorXx

I've fully tested both 32 and 64 Bit RPi OS Bullseye. (image of Jan 26 or something like that). These have kernel 5.10. If you are using desktop (I think you are, kernel is v8) test with a fresh image on a new sdcard and dont allow an upgrade the kernel to the new 5.15 one, it introduced huge latency. place a hold on apt for raspberrypikernel and kernelmodules Don't yet know why this happened. Its a mess.

I recommend experimenting with the ubuntu image instead until there is a fix for the 5.15 kernel issue.

xXPerditorXx commented 2 years ago

I don't really know if you can do anything about it, but the playback on e.g youtube twitch etc isn't working. I saw that on any non apple device. My phone/ipad is showing always the same message: "Oh oh. Something went wrong."

fduncanh commented 2 years ago

I don't know about twitch

UxPlay can receive streaming from iOS device but not (i) things with Apple DRM encryption such as appleTV (the app) (2) it does not let the iOS device run a http:server on the Linux server ( an iPad will prefer to send a source http address to an Apple TV (the device) and have the Apple TV stream directly from the source, instead of streaming from the source to the iPad and restreaming from the iPad to the Apple TV)

If twitch is in one of these two categories it won't work on uxplay.

Is there a twitch source I can test?

Youtube itself does work.

xXPerditorXx commented 2 years ago

You can try any site with a video. Try YouTube in a browser. That works fine but open this video on full screen and you will see the error.

fduncanh commented 2 years ago

Yes.

If you open it in a browser, and in the browser window on the ipad click on the symbol at lower right (to the right of the "airplay" symbol), a square with breaks in the middle of each edge, you can get it playing "full screen" inside a larger window on the linux server, while the screen on the iPad goes dark with a message "TV Connected This video is playing on the TV".

Clicking the AirPlay symbol (a rectangle with a upwards-pointing filled triangle on the bottom edge) to the left of this will NOT work, as that is supposed to get the Apple TV box to stream directly from YouTube, without passing the video through the iPad. This runs an http server on the Apple TV; uxplay does not support this mode. The other mode (square symbol with breaks in the sides) stops rendering the picture on the iPad, but still streams it to uxplay via the iPad.

You can get full screen with the vaapisink or waylandsink videosinks. If you have a Raspberry Pi, the Ubuntu 21.10 for RPi4 uses waylandsink. Use uxplay -vs "vaapisink fullscreen=true". I think this only works for vaapisink and waylandsink.

uxplay -rpi -vs "waylandsink fullscreen=true".

Rasperry Pi OS lite always gives you full screen with "uxplay -rpi -vs kmssink" as it uses the kernel framebuffer for video.

xXPerditorXx commented 2 years ago

I tried uxplay on my arch Linux and it worked well with prime-run and the Nvidia settings to put into the wiki. Are you able to add the functionality that the raspberry or Linux is running YouTube in background and shows the video over Linux or is this encrypted too?

fduncanh commented 2 years ago

You could always watch youtube directly from the Pi itself (e.g. using chromium) without going through uxplay. It's not clear what would be gained by adding a http server feature to uxplay which is aimed mainly at mirroring the ios device screen.

fduncanh commented 2 years ago

@xXPerditorXx

if your original problem is fixed, and only a "feature request" remains, please close this issue. (only streaming from the iOS device, not direct streaming from an internet source, is practical for uxplay to support)

fduncanh commented 2 years ago

closing. please open a new issue if needed.