FDH2 / UxPlay

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

-s command not working on CM4 Carrier board #280

Closed Boaztheostrich closed 2 months ago

Boaztheostrich commented 2 months ago

I am having an issue with getting UxPlay to fill up my full screen. I can't seem to get it to fill up more than this amount of my screen:

image

I tried a variety of different resolutions with the -s command but it always displays this same framing.

If I do not specify the resolution with -s it displays a image larger than what my 800x480 screen can display:

image

Not sure if there is a better way to approach this.

uxplay -bt709 -as 0 -s 800x480 -fs

Is the command I have been using.

Boaztheostrich commented 2 months ago

I'm not sure this is relevant, but if I don't use the -bt709 command I get this error:

GStreamer error: Internal data stream error.
*** This is a generic GStreamer error that usually means that GStreamer
*** was unable to construct a working video pipeline.

*** If you are letting the default autovideosink select the videosink,
*** GStreamer may be trying to use non-functional hardware h264 video decoding.
*** Try using option -avdec to force software decoding or use -vs <videosink>
*** to select a videosink of your choice (see "man uxplay").

*** Raspberry Pi OS with (unpatched) GStreamer-1.18.4 needs "-bt709" uxplay option
Removing connection for socket 32
raop_rtp_mirror->running is no longer true
Removing connection for socket 34
Initialized server socket(s)
fduncanh commented 2 months ago

you are using video4linux2 to access the GPU on a RPi 4B or earlier with Raspberry Pi OS bullseye. unpatched gstreamer-1.18.4 needs the -bt709 option. If patch gstreamer you wont need -bt709. https://github.com/FDH2/UxPlay/wiki/Gstreamer-Video4Linux2-plugin-patches

as for the framing, I checked , that's what -vs ximagesink seems to do in -fs mode. (a black frame) - -vs xvimagescreen -fs does better at filling the screen, but if I remember, your screen does not support xv extensions

Boaztheostrich commented 2 months ago

That makes sense, is there another videosink you would recommend I try that supports -fs and doesn't have the black box problem?

I reached out to support regarding the xv issue but haven't found a solution as of yet.

Thank you!

fduncanh commented 2 months ago

waylandsink supports fs on rpi activate wayland in raspi-config "advanced options". (both Bullseye and Bookworm)

whether your screen supports it, I wouldnt know.

Boaztheostrich commented 2 months ago

Unfortunately I have been unable to get past the login screen using wayland. I type in my password the screen turns black, and then it presents the login screen again. Not sure what is happening there.

fduncanh commented 2 months ago

https://www.geeky-gadgets.com/raspberry-pi-os-wayland/

If you also have a test installation of Bookworm, it might or might not be better

Boaztheostrich commented 2 months ago

Sounds good, I can look at installing that instead of bullseye.

Would I be able to just downgrade or upgrade gstreamer to get around the ximagesink issue?

Ideally Waylandsink works.

Failing that do you have any idea on how to eliminate that black border?

Thanks for all your help.

On Sun, Apr 7, 2024 at 1:31 AM fduncanh @.***> wrote:

https://www.geeky-gadgets.com/raspberry-pi-os-wayland/

If you also have a test installation of Bookworm, it might or might not be better

— Reply to this email directly, view it on GitHub https://github.com/FDH2/UxPlay/issues/280#issuecomment-2041335644, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATKHZWEWWH7BQZVTJYENUBLY4DR37AVCNFSM6AAAAABF2XRVOSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANBRGMZTKNRUGQ . You are receiving this because you authored the thread.Message ID: @.***>

fduncanh commented 2 months ago

You should be maintaining set of SDHC cards with different versions of the R Pi OS operating system on them for testing. That way you don't ruin a working system just to test. (lite/desktop, bullseye/bookworm)

Down grading or upgrading gstreamer outside a given series ( 1.18.x, 1.20.x 1.22.x 1.24.x) is not possible on a desktop system. Too much is linked to it. It is possible on a lite system.

You also should have another a more standard terminal to test on, to see whether your issues are to do with your 800x480 one

Boaztheostrich commented 2 months ago

Sounds good, I have spare cards I should have clarified.

1.18 seems to work fine for everything I need so o can try to get that working on bookworm.

I have a way of testing on other terminals it’s just a pain with the carrier board I’m using not having hdmi out. Xvimagesink worked on the other terminal.

On Sun, Apr 7, 2024 at 9:44 AM fduncanh @.***> wrote:

You should be maintaining set of SDHC cards with different versions of the R Pi OS operating system on them for testing. That way you don't ruin a working system just to test. (lite/desktop, bullseye/bookworm)

Down grading or upgrading gstreamer outside a given series ( 1.18.x, 1.20.x 1.22.x 1.24.x) is not possible on a desktop system. Too much is linked to it. It is possible on a lite system.

You also should have another a more standard terminal to test on, to see whether your issues are to do with your 800x480 one

— Reply to this email directly, view it on GitHub https://github.com/FDH2/UxPlay/issues/280#issuecomment-2041493277, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATKHZWGDLQ7OZJ5PUES2PV3Y4FLWRAVCNFSM6AAAAABF2XRVOSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANBRGQ4TGMRXG4 . You are receiving this because you authored the thread.Message ID: @.***>

fduncanh commented 2 months ago

It will be difficult to get gstreamer-1.18.x working on bookworm. You will need to start with a Lite system, and not install any packages linked to gstreamer-1.22.x which if I remember correctly is what Bookworm supplies.

I'll close this as its not an issue uxplay can solve.

Boaztheostrich commented 2 months ago

Thanks for the response, I’ll have to look at the bookworm option a bit more and go from there. Thanks for the help!

On Wed, Apr 10, 2024 at 11:41 AM fduncanh @.***> wrote:

Closed #280 https://github.com/FDH2/UxPlay/issues/280 as not planned.

— Reply to this email directly, view it on GitHub https://github.com/FDH2/UxPlay/issues/280#event-12425258144, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATKHZWFAWK5GZHSL6XASL63Y4VTUJAVCNFSM6AAAAABF2XRVOSVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJSGQZDKMRVHAYTINA . You are receiving this because you authored the thread.Message ID: @.***>

fduncanh commented 2 months ago

I took a look at the ximagesink bug. It dates to March 2022 If you rebuild libgstximagesink.so on bookworm after replacing ximagesink.c and ximagesink.h with the older version it works.

You rebuild gstreamer1.0-plugins-base with debuild, replace the two files, run ninja, then strip libgstximagesink.so and copy it to the /lib/.../gstreamer-1.0/ directory. (Same procedure you did earlier to fix the videoflip bug.)

get the two replacement files here: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/tree/2fd28195caf4502c7fc10cb3d63974c543354180/subprojects/gst-plugins-base/sys/ximage

I reported the issue to gstreamer: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/3470

fduncanh commented 2 months ago

I located the precise point where the ximagesink changes in 1.22 crash X11 on R Pi.

See https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/3470

Boaztheostrich commented 2 months ago

That’s awesome! Thanks for taking the time to deep dive into this. I looked through your comments on the link and previous response and I can try to follow those steps today or tmw if I have time.

I’ll make sure to report back if I can get it working on my side, I would much prefer to use bookworm if possible.

On Sat, Apr 13, 2024 at 1:00 PM fduncanh @.***> wrote:

I located the precise point where the ximagesink changes in 1.22 crash X11 on R Pi.

See https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/3470

— Reply to this email directly, view it on GitHub https://github.com/FDH2/UxPlay/issues/280#issuecomment-2053717023, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATKHZWAPIR5KD6FCOFUZB3TY5FXCXAVCNFSM6AAAAABF2XRVOSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANJTG4YTOMBSGM . You are receiving this because you authored the thread.Message ID: @.***>

fduncanh commented 2 months ago

Found the problem.

#ifdef HAVE_XI2
    if (ximagesink->xcontext->use_xi2) {
      XIEventMask mask_data;
      unsigned char mask[2];

      gst_x_image_sink_xwindow_select_touch_events (ximagesink, xwindow);

      XISetMask (mask, XI_HierarchyChanged);
      mask_data.deviceid = XIAllDevices;
      mask_data.mask_len = sizeof (mask);
      mask_data.mask = mask;

      /* register for HierarchyChanged events to see device changes */
      XISelectEvents (ximagesink->xcontext->disp, xwindow->win, &mask_data, 1);
    }
#endif

line 578 should be changed to initialize mask[2]:

      unsigned char mask[2] = { 0 };

I submitted this as a Merge Request to gstreamer.

Boaztheostrich commented 2 months ago

Perfect thank you!!

Boaztheostrich commented 1 month ago

@fduncanh do you have any advice on installing the version of gstreamer that has the fixes on RPI? I've been having some difficulty figuring it out. GStreamer 1.22.12 old-stable bug-fix is the correct version but just doing the basic:

sudo apt install gstreamer1.0=1.22.12

Didn't work.

I tried following the instructions here: https://gstreamer.freedesktop.org/documentation/installing/building-from-source-using-meson.html?gi-language=c

But I was unable to get past the cloning step:

boazburnett@raspberrypi:~ $ git clone https://gitlab.freedesktop.org/gstreamer/gstreamer.git
Cloning into 'gstreamer'...
remote: Enumerating objects: 913398, done.
remote: Counting objects: 100% (2023/2023), done.
remote: Compressing objects: 100% (1210/1210), done.
error: RPC failed; curl 56 Recv failure: Connection reset by peer
error: 20890 bytes of body are still expected
fetch-pack: unexpected disconnect while reading sideband packet
fatal: early EOF
fatal: fetch-pack: invalid index-pack output

Trying:

git clone https://github.com/GStreamer/gstreamer.git

Does work and I was able to get to the

[(11/12 @ 98%) INSTALL: cargo-c]

step but have not been able to make it past that.

I've been following these instructions: https://gstreamer.freedesktop.org/documentation/installing/building-from-source-using-cerbero.html?gi-language=c

Just swapping the gitlab stuff for github.

Thanks! Boaz

fduncanh commented 1 month ago

The ximagesink fix is in gstreamer-1.22.12

The reference is:

https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6655

Unfortunately, Raspbery Pi OS will not update their gstreamer-1.22.0 package unless this issue is brought to their attention.

If you just need the fix for yourself, the easiest thing is to just patch libgstximagesink.so. with the fix.

If you are planning a device you want to distribute, its not easy to replace the distribution 's gstreamer by compiling it yourself. The best would be to get R Pi OS to include the fix in an update. The above reference would be useful in getting them to do it.

Maybe one needs to start by getting Debian to include the fix in their updates.

Boaztheostrich commented 1 month ago

I installed Gstreamer 1.22.12 on bookwork on my cm4. It took forever but I eventually got it up and running.

I still encountered the black box around the screen mirroring though:

IMG_4984 IMG_4985

Not sure if this is related but upon reboot it changed my desktop enviroment to a different flavor of linux: IMG_4987

I may screw around with it some more, but I'd love to hear your thoughts, I can just try to do the patch instead of installing the full 1.22.12

fduncanh commented 1 month ago

The "black box" is not affected by the fix for ximagesink I got added to gstreamer-1.22-12 and later.

Its a "feature". Maybe by adding ... ! videoscale !... to the video pipeline it can be adjusted: see below.

https://gstreamer.freedesktop.org/documentation/videoconvertscale/videoscale.html?gi-language=c

The pipeline is created in renderers/video_renderer_gstreamer.c starting at line 150

https://gstreamer.freedesktop.org/documentation/tutorials/basic/platform-specific-elements.html?gi-language=c

A standard RGB only X-based video sink. It implements the VideoOverlay interface, so the video window can be re-parented (embedded inside other windows). It does not support scaling or color formats other than RGB; it has to be performed by different means (using the videoscale element, for example).

An X-based video sink, using the X Video Extension (Xv). It implements the VideoOverlay interface, so the video window can be re-parented (embedded inside other windows). It can perform scaling efficiently, on the GPU. It is only available if the hardware and corresponding drivers support the Xv extension.

fduncanh commented 1 month ago

To modify the pipeline, just experiment with

uxplay -vs "videoscale ! ximagesink"
Boaztheostrich commented 1 month ago

Sounds good! I'll play around with

uxplay -vs "videoscale ! ximagesink"

Sorry for the confusion on what the fix you pushed was!