FDH2 / UxPlay

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

Patch for broken Videoflip in GStreamer 1.22.0 (which was fixed in 1.22.3 - 1.22.6) (was: No flip commands working on Raspberry pi 5) #275

Closed Boaztheostrich closed 6 months ago

Boaztheostrich commented 6 months ago

On my rpi 5 running UxPlay version 1.62 I can't get the flip command to work. It seems to just be ignoring the flip command when I am running it.

I tried:

uxplay -f H
uxplay -f V
uxplay -f I

But was unable to get anything to work, I didn't see any error messages related to flipping, although I did get a

gst_v4l2_buffer_pool_orphan: assertion 'bpool' failed

I'd be happy to provide more information if needed.

fduncanh commented 6 months ago

You are correct!

I checked that nothing in uxplay is broken (uxplay -d shows the video pipeline, and everything about videoflip is correct.

The issue is that videoflip got broken in GStreamer 1.22.0, with a fix in 1.22.3. I verified that it was working on a system with GStreamer 1.20, but it doesnt work in 1.22.0

see https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4536

It seems the "videoflip method" used by uxplay is deprecated and has been superceded by a new "videoflip video-direction property", and this change by accident broke the older method which should have remained workable. It's certainly broken in GStreamer 1.22.0 It was fixed in 1.20.3 but that's not much help if your distribution does not update gstreamer.

I'll look into it. EDIT also see https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/2529

fduncanh commented 6 months ago

It got fixed in GStreamer-1.22.3 bugfix release. Unfortunately Raspberry PI OS (Bookworm) has 1.22.0

fduncanh commented 6 months ago

Here is the fix. It would be fairly easy to patch GStreamer-1.22.0 with the fix.

https://gitlab.freedesktop.org/gstreamer/gstreamer/-/commit/020fd3d14d74adc6dbf6ea59b684e15030eb1be2

(see https://github.com/FDH2/UxPlay/wiki/Gstreamer-Video4Linux2-plugin-patches for how to do a patch)

Boaztheostrich commented 6 months ago

Thanks for the quick response!

What would be my best next steps for patching this? I’m admittedly not the best at Linux. Is this something I could fix with using nano or another text editor to just copy paste the values shown in the link you sent?

Or do I need to update streamer or something?

Thank!

On Sun, Mar 10, 2024 at 3:57 AM fduncanh @.***> wrote:

Here is the fix. It would be fairly easy to patch GStreamer-1.22.0 with the fix.

https://gitlab.freedesktop.org/gstreamer/gstreamer/-/commit/020fd3d14d74adc6dbf6ea59b684e15030eb1be2

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

fduncanh commented 6 months ago

I'm looking into it. I can make you a patch to apply. I'm also trying to find out how to using the alternative method of setting videoflip mentioned in https://gitlab.freedesktop.org/gstreamer/gstreamer/-/commit/020fd3d14d74adc6dbf6ea59b684e15030eb1be2

Boaztheostrich commented 6 months ago

Sounds good thank you! This may be unrelated but is it possible to dynamically change values like -f H dynamically without shutting down and restarting the stream?

In my application some apps, such as those using a camera, are best mirrored to reflect camera movement. While others are best used un flipped for text readability.

Thanks! Boaz

On Sun, Mar 10, 2024 at 10:33 AM fduncanh @.***> wrote:

I'm looking into it. I can make you a patch to apply. I'm also trying to find out how to using the alternative method of setting videoflip mentioned in https://gitlab.freedesktop.org/gstreamer/gstreamer/-/commit/020fd3d14d74adc6dbf6ea59b684e15030eb1be2

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

fduncanh commented 6 months ago

Problem: a regression in GStreamer-1.22.0 means that it fails to respect "! videoflip method=... !" in a pipeline created with gst-parse-launch.

Here is the patch: apply it using exactly the same method described here for applying the v4l2 patch to gstreamer-plugins-good v 1.18.4 in Raspberry Pi OS (Bullseye). You will be patching libgstvideofilter.so from gstreamer1.0-plugins-good-1.22.0*.deb from Raspberry Pi OS (Bookworm).

The only (obvious) changes in the patching instructions are that

The patch is:

https://github.com/FDH2/UxPlay/files/14551547/gst_videoflip_1_22_0_diff.txt

If the distribution updates gstreamer1.0-plugins-good, your patched libgstvideofilter.so will be overwritten, and needs to be recopied to the gstreamer-1.0 directory (unless the update fixes the problem).

The problem appeared in GStreamer-1.22.0, was first fixed in 1.22.3. Evidently this did not completely solve all related issues, as versions of an additional fix were merged 3 times, becoming stable in 1.22.6

The patch here includes all these fixes, and can be applied to gstreamer-plugins-good 1.22.0, 1.22.1, and 1.22.2

References: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/commit/b17fbb231cde6fd72e356daa43122084693fef7d https://gitlab.freedesktop.org/gstreamer/gstreamer/-/commit/2dc0e1ac877c7122ff57d557395f768dbc7ec55a https://gitlab.freedesktop.org/gstreamer/gstreamer/-/commit/4c77bc21617d3717bcd677d1fd3dce71713edb2b https://gitlab.freedesktop.org/gstreamer/gstreamer/-/commit/bbca6cc8c8125f53b74f7b9a5b7a559595f9cf89

.

Boaztheostrich commented 6 months ago

Sounds good! I will try this out later today!

Thank you for the help :)

Would it be possible to make changes dynamically while it is running somehow? Or can run arguments only be applied before the process is running?

On Sun, Mar 10, 2024 at 3:15 PM fduncanh @.***> wrote:

Here is the patch: apply it using exactly the same method described here https://github.com/FDH2/UxPlay/wiki/Gstreamer-Video4Linux2-plugin-patches for applying the v4l2 patch to gstreamer-plugins-good v 1.18.4 in Raspberry Pi OS (Bullseye) You will be patching libgstvideofilter.so from gstreamer1.0-plugins-good-1.22.0*.deb from Raspberry Pi OS (Bookworm).

The only (obvious) changes are that

  • 1.18.4 is replaced by 1.22.0
  • v4l2_1_18_4_diff3.txt is replaced by gst_videoflip_1_22_0_diff.txt
  • sys/v4l2 is replaced by gst/videofilter
  • libgstvideo4linux2.so is replaced by libgstvideofilter.so

The patch is:

https://github.com/FDH2/UxPlay/files/14551547/gst_videoflip_1_22_0_diff.txt

The problem appeared in GStreamer-1.22.0, was first patched in 1.22.3. Evidently this did not completely solve all related issues, as versions of an additional patch were applied 3 times, becoming stable in 1.22.6

The patch here includes all these fixes.

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

fduncanh commented 6 months ago

Would it be possible to make changes dynamically while it is running somehow? Or can run arguments only be applied before the process is running?

Uxplay can't change anything after it starts. Only the client can do that.

Boaztheostrich commented 6 months ago

Sounds good thank you!

On Sun, Mar 10, 2024 at 3:22 PM fduncanh @.***> wrote:

Would it be possible to make changes dynamically while it is running somehow? Or can run arguments only be applied before the process is running?

Uxplay can't change anything after it starts. Only the client can do that.

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

fduncanh commented 6 months ago

It would certainly be possible to modify uxplay to read some file each time a new connection starts to find out what video orientation to use.