FDH2 / UxPlay

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

Image Quality issue with UxPlay on Ubuntu 24.04 #313

Closed cjohn001 closed 3 months ago

cjohn001 commented 3 months ago

Hello together, I am currently trying to use UxPlay to record my iPhone for some tutorial videos. Unfortunately, the image quality is not good. I suspect that it might have to do something with the compression of the images. On my Macbook the images display in a rather good quality. Hence, do I have any options to influence the image quality in UxPlay? Attached images show the issue. Seems like the transparency of the UI elements is more or less getting lost. First image shows the expected outcome, the second one the observed outcome. Thanks for your help and directions!

Original

Streamed

fduncanh commented 3 months ago

uxplay will mirror what is on your macbook's screen, in h264 video which is lower than the native macbook screen resolution.

Uxplay does have a resolution setting -s wxh . default is 1080p video (1920x1080) This is a "suggestion" to the client, that the client does not have to follow (it sets a maximum resolution).

If the client and server are connected over wired ethernet as opposed to wifi, a modern mac client can send higher resolutions and at some point switches to h265 video. Unfortunately in h265 mode, it sends an empty video information packet without "pps" +"sps" info to UxPlay, which are needed to decode the video. UxPlay is masquerading as an older-model AppleTV, so maybe this is just Apple being nasty to older models. So as of now , we can't use the h265 hi-res signal because of this Apple limitation.

You can experiment with the -s wxh setting to see how high you can go before the switch to h265 happens, and uxplay breaks.

cjohn001 commented 3 months ago

Hello @fduncanh, thanks for the detailed response. The 2 images provided above are results from an iPhone conntected wirelessly to a linux pc and a macbook. So if h265 is only used via wired connections for macbook as well, than this is not the issue. Morover, as can be seen from the images. My problem is not a resolution problem. The difference is in the transparencies of the tile in the app (semitransparent vs. solid). To my opinion this looks more like a problem with the used colorpalette or bitrate of the h264 encoding. Is their maybe an option to send suggestions to the client that it uses a higher colordepth or bitrate for compressing 1080p? I assume there lies the problem. Thanks for your support!

Best regards, Christoph

fduncanh commented 3 months ago

we cannot influence what the macOS/iOS client chooses to send in screen mirror mode. The transparency is already there in the images sent by the client. The only information that the server provides is in the "pList" property list that the server initially sends when the connect is made. see it with the -d option.

This is composed in raop_handlers.h, and entries like width x height @ refresh_rate (option -s 1920x1080@60 )and maxFPS can be set by uxplay startup options. Maybe see if using maxFPS = 60 might help. (default is option -fps 30). But these settings could only affect the image you see if they influence the decisions the client makes about processing its screen image for encoding into h264.

The displays "features" entry "14" = 0x0d = 0000 1110 is a bit map. I'm not sure what these settings mean. they tell the macOS/iOS client what video features to use. (I don't know if the features setting is actually used by the client, or where it came from: presumably seen on an actual appleTV?).

Handling request GET with URL /info

RTSP/1.0 200 OK 
CSeq: 0 
Server: AirTunes/220.68 
Content-Type: application/x-apple-binary-plist 
Content-Length: 1071 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>deviceID</key>
        <string>80:c1:5e:dc:a0:99</string>
        <key>pk</key>
        <data>
        OO27jX7jsF9qJw2PTWUzdJVKxTpwLUsUs64pFLLJLYQ=
        </data>
        <key>txtAirPlay</key>
        <data>
        GmRldmljZWlkPTgwOmMxOjZlOmVjOmEwOjg4F2ZlYXR1cmVzPTB4NUE3RkZFRTYsMHgw
        CWZsYWdzPTB4NBBtb2RlbD1BcHBsZVRWMywyQ3BrPTM4ZWRiYjhkN2VlM2IwNWY2YTI3
        MGQ4ZjRkNjUzMzc0OTU0YWM1M2E3MDJkNGIxNGIzYWUyOTE0YjJjOTJkODQHcHc9dHJ1
        ZSdwaT0yZTM4ODAwNi0xM2JhLTQwNDEtOWE2Ny0yNWRkNGE0M2Q1MzYOc3JjdmVycz0y
        MjAuNjgEdnY9Mg==
        </data>
        <key>features</key>
        <integer>1518337766</integer>
        <key>name</key>
        <string>UxPlay@host</string>
        <key>audioFormats</key>
        <array>
                <dict>
                        <key>type</key>
                        <integer>100</integer>
                        <key>audioInputFormats</key>
                        <integer>67108860</integer>
                        <key>audioOutputFormats</key>
                        <integer>67108860</integer>
                </dict>
                <dict>
                        <key>type</key>
                        <integer>101</integer>
                        <key>audioInputFormats</key>
                        <integer>67108860</integer>
                        <key>audioOutputFormats</key>
                        <integer>67108860</integer>
                </dict>
        </array>
        <key>pi</key>
        <string>2e388006-13ba-4041-9a67-25dd4a43d536</string>
        <key>vv</key>
        <integer>2</integer>
        <key>statusFlags</key>
        <integer>68</integer>
        <key>keepAliveLowPower</key>
        <integer>1</integer>
        <key>sourceVersion</key>
        <string>220.68</string>
        <key>keepAliveSendStatsAsBody</key>
        <integer>1</integer>
        <key>audioLatencies</key>
        <array>
                <dict>
                        <key>outputLatencyMicros</key>
                        <false/>
                        <key>type</key>
                        <integer>100</integer>
                        <key>audioType</key>
                        <string>default</string>
                        <key>inputLatencyMicros</key>
                        <false/>
                </dict>
                <dict>
                        <key>outputLatencyMicros</key>
                        <false/>
                        <key>type</key>
                        <integer>101</integer>
                        <key>audioType</key>
                        <string>default</string>
                        <key>inputLatencyMicros</key>
                        <false/>
                </dict>
        </array>
        <key>model</key>
        <string>AppleTV3,2</string>
        <key>macAddress</key>
        <string>80:c1:5e:dc:a0:99</string>
        <key>displays</key>
        <array>
                <dict>
                        <key>uuid</key>
                        <string>e0ff8a27-6738-3d56-8a16-cc53aacee925</string>
                        <key>widthPhysical</key>
                        <false/>
                        <key>heightPhysical</key>
                        <false/>
                        <key>width</key>
                        <integer>1920</integer>
                        <key>height</key>
                        <integer>1080</integer>
                        <key>widthPixels</key>
                        <integer>1920</integer>
                        <key>heightPixels</key>
                        <integer>1080</integer>
                        <key>rotation</key>
                        <false/>
                        <key>refreshRate</key>
                        <integer>60</integer>
                        <key>maxFPS</key>
                        <integer>30</integer>
                        <key>overscanned</key>
                        <false/>
                        <key>features</key>
                        <integer>14</integer>
                </dict>
        </array>
</dict>
</plist>