FDH2 / UxPlay

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

Connection Error. Screen appears and then disappears. #65

Closed TheThings027 closed 2 years ago

TheThings027 commented 2 years ago

Hi there! I have just installed this software but when attempting to connect from my mac it opens a window only to immediately close it.

This is what happens in the terminal: pi@raspi-4{colon}/UxPlay $ uxplay using system MAC address e4:5f:01:05:86:51 Initialized server socket(s) Accepted IPv4 client on socket 28 Local: 192.168.133.211 Remote: 192.168.133.245 Open connections: 1 Client identified as User-Agent: AirPlay/610.14.1 Accepted IPv4 client on socket 30 Local: 192.168.133.211 Remote: 192.168.133.245 Open connections: 2 raop_rtp_mirror starting mirroring GStreamer error: No valid frames decoded before end of stream Removing connection for socket 28 Destroying connection Open connections: 1 Removing connection for socket 30 Destroying connection Open connections: 0 Initialized server socket(s) ^C Stopping... pi@raspi-4{colon}~/UxPlay $

Why might this be happening?

TheThings027 commented 2 years ago

Mind you this is a Raspberry Pi 4.

fduncanh commented 2 years ago

No valid decoded video was received by GStreamer, so a Gstreamer error was posted and uxplay correctly disconnected.

GStreamer error: No valid frames decoded before end of stream

This is probably a GStreamer error, but one needs to look at the output of "uxplay -d" to see if any video is actually being received by uxplay and sent to GStreamer.

  1. to see if uxplay's raop server is working properly:

    uxplay -d 

    (you can compare output to https://github.com/FDH2/UxPlay/files/7805869/uxplay_debug_output.txt )

  2. to see GStreamer errors

    export GST_DEBUG=2
    uxplay 

UxPlay is not so far tested on RPi 4, there seems to be a lot of confusion between Buster / Bullseye, 32bit /64 bit, and X11/Wayland display manager, for getting a working GStreamer on RPi 4 with the built-in h264 hardware decoding.

UxPlay is aimed primarily at X86_64 desktop/laptop architecture, but should work well on RPi 4 (a guess) when GStreamer is properly set up. (A RPi 4B 8GB has been ordered just to see if this guess is correct.)

There are no posted reports of success with RPi 4 so far. see #63 for a link about GStreamer on RPi 4.

https://qengineering.eu/install-gstreamer-1.18-on-raspberry-pi-4.html

https://forums.raspberrypi.com/viewtopic.php?t=313685

Try (1) Buster 32 bit (2) Bullseye 32 bit (3) Bullseye 64 bit. (if your RPi 4 has 4 GB or more memory) (and try both X11 and Wayland display managers, this might be a ubuntu--specific issue, don't know about Raspian etc.) to see if any give you a working gstreamer.

fduncanh commented 2 years ago

When looking at the output of uxplay -d: just look at what happens after "raop_rtp_mirror accepting client": if uxplay is working properly before sending video to GStreamer, you will see:

raop_rtp_mirror accepting client
raop_rtp type_c 0x54, packetlen = 20
raop_rtp sync: ntp=228207842706, local ntp: 1641277672982257, rtp=3930228331, rtp_next=3930246853
raop_rtp sync correction=-1641188552158425
raop_rtp_mirror width_source = 1440.000000 height_source = 1080.000000 width = 1440.000000 height = 1080.000000
raop_rtp_mirror sps size = 18
raop_rtp_mirror pps size = 4
raop_rtp_mirror video ntp = 1641277673101117, now = 1641277673048926, latency = -52191
raop_rtp_mirror video ntp = 1641277673151073, now = 1641277673054071, latency = -97002
raop_rtp audio: ntp = 1641277673584320, now = 1641277673078366, latency=-505954, rtp=3930254882
raop_rtp audio: ntp = 1641277673584320, now = 1641277673078374, latency=-505946, rtp=3930254882

(and more like this until the GStreamer error occurs)
TheThings027 commented 2 years ago

This is what I get with "uxplay" -d:

pi@raspi-4{colon}~ $ uxplay -d supported audio format 1: AAC-ELD 44100/2 supported audio format 2: ALAC 44100/16/2 supported audio format 3: AAC-LC 44100/2 supported audio format 4: PCM 44100/16/2 S16LE Initialized GStreamer video renderer using system MAC address e4:5f:01:05:86:51 Initialized server socket(s) Accepted IPv4 client on socket 29 Local: 192.168.133.211 Remote: 192.168.133.245 Open connections: 1 httpd receiving on socket 29 conn_request

GET /info RTSP/1.0 X-Apple-ProtocolVersion: 1 Content-Length: 70 Content-Type: application/x-apple-binary-plist CSeq: 0 DACP-ID: 3243622BC5922E88 Active-Remote: 124334687 User-Agent: AirPlay/610.14.1

<?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">

qualifier txtAirPlay

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: 1065

<?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">

txtAirPlay GmRldmljZWlkPWU0OjVmOjAxOjA1Ojg2OjUxE2ZlYXR1cmVzPTB4NUE3RkZFRTYJZmxh Z3M9MHg0EG1vZGVsPUFwcGxlVFYzLDJDcGs9YjA3NzI3ZDZmNmNkNmUwOGI1OGVkZTUy NWVjM2NkZWFhMjUyYWQ5ZjY4M2ZlYjIxMmVmOGEyMDUyNDY1NTRlNydwaT0yZTM4ODAw Ni0xM2JhLTQwNDEtOWE2Ny0yNWRkNGE0M2Q1MzYOc3JjdmVycz0yMjAuNjgEdnY9Mg== features 130367356919 name UxPlay@raspi-4 audioFormats type 100 audioInputFormats 67108860 audioOutputFormats 67108860 type 101 audioInputFormats 67108860 audioOutputFormats 67108860 pi 2e388006-13ba-4041-9a67-25dd4a43d536 vv 2 statusFlags 68 keepAliveLowPower 1 sourceVersion 220.68 pk sHcn1vbNbgi1jt5SXsPN6qJSrZ9oP+shLviiBSRlVOc= keepAliveSendStatsAsBody 1 deviceID e4:5f:01:05:86:51 audioLatencies outputLatencyMicros type 100 audioType default inputLatencyMicros outputLatencyMicros type 101 audioType default inputLatencyMicros model AppleTV3,2 macAddress e4:5f:01:05:86:51 displays uuid e0ff8a27-6738-3d56-8a16-cc53aacee925 widthPhysical heightPhysical width 1920 height 1080 widthPixels 1920 heightPixels 1080 rotation refreshRate 60 maxFPS 30 overscanned features 14

httpd receiving on socket 29 conn_request

POST /pair-setup RTSP/1.0 Content-Length: 32 Content-Type: application/octet-stream CSeq: 1 DACP-ID: 3243622BC5922E88 Active-Remote: 124334687 User-Agent: AirPlay/610.14.1

28 ae 5c 60 4f 94 f4 36 fd 7c 08 b9 ff fc 32 8f 70 ad 54 31 f9 f2 7a 5d a9 e1 e8 94 3d dc 83 11

Handling request POST with URL /pair-setup

RTSP/1.0 200 OK CSeq: 1 Server: AirTunes/220.68 Content-Type: application/octet-stream Content-Length: 32

1c f4 80 16 3a d1 46 db 58 08 ec aa f6 9f e4 96 90 88 54 8f 3d c3 d2 ab 11 7d 34 6b ca 38 22 4d

httpd receiving on socket 29 conn_request

POST /pair-verify RTSP/1.0 X-Apple-PD: 1 Content-Length: 68 Content-Type: application/octet-stream CSeq: 2 DACP-ID: 3243622BC5922E88 Active-Remote: 124334687 User-Agent: AirPlay/610.14.1

01 00 00 00 ba a7 d8 02 3a 5f b6 f1 e8 6a d4 ae 84 b6 05 98 79 9d 85 cb 53 e0 63 91 5b 45 24 58 dc f2 48 50 28 ae 5c 60 4f 94 f4 36 fd 7c 08 b9 ff fc 32 8f 70 ad 54 31 f9 f2 7a 5d a9 e1 e8 94 3d dc 83 11

Handling request POST with URL /pair-verify

RTSP/1.0 200 OK CSeq: 2 Server: AirTunes/220.68 Content-Type: application/octet-stream Content-Length: 96

7e d4 48 3a 1d b8 20 14 ef 58 b9 6c ea b7 fa 83 0d 9c 3a 53 35 fe 7c ab 55 31 75 12 f8 94 76 64 67 ea 6b d2 aa c8 3f b0 81 91 18 78 3a 3e cb 83 e1 e4 bb 09 1b 6b af 3c b9 86 03 9d 8e 59 1c 4e d2 54 65 8c f7 89 df 7f 22 1a 37 3d 35 d5 41 5d 1a ba 0f 96 00 a6 d8 21 6d 22 75 55 58 08 30 e0

httpd receiving on socket 29 conn_request

POST /pair-verify RTSP/1.0 X-Apple-PD: 1 Content-Length: 68 Content-Type: application/octet-stream CSeq: 3 DACP-ID: 3243622BC5922E88 Active-Remote: 124334687 User-Agent: AirPlay/610.14.1

00 00 00 00 a4 59 52 f1 12 1c 4e 84 3b aa 26 44 80 e8 1a 87 66 6a f8 6d 11 5f bf 4d 8a a3 dc 01 b7 b5 8d 5d 3c 6d d5 6e fd e8 ae ee 01 be 88 88 5b a6 2c 59 36 8a 6e f7 e4 14 11 33 86 e4 4a c3 e2 94 8c 33

Handling request POST with URL /pair-verify 2nd pair-verify step: checking signature pair-verify: signature is verified

RTSP/1.0 200 OK CSeq: 3 Server: AirTunes/220.68 Content-Type: application/octet-stream

httpd receiving on socket 29 conn_request

POST /fp-setup RTSP/1.0 X-Apple-ET: 32 Content-Length: 16 Content-Type: application/octet-stream CSeq: 4 DACP-ID: 3243622BC5922E88 Active-Remote: 124334687 User-Agent: AirPlay/610.14.1

46 50 4c 59 03 01 01 00 00 00 00 04 02 00 01 bb

Handling request POST with URL /fp-setup

RTSP/1.0 200 OK CSeq: 4 Server: AirTunes/220.68 Content-Type: application/octet-stream Content-Length: 142

46 50 4c 59 03 01 02 00 00 00 00 82 02 01 cf 32 a2 57 14 b2 52 4f 8a a0 ad 7a f1 64 e3 7b cf 44 24 e2 00 04 7e fc 0a d6 7a fc d9 5d ed 1c 27 30 bb 59 1b 96 2e d6 3a 9c 4d ed 88 ba 8f c7 8d e6 4d 91 cc fd 5c 7b 56 da 88 e3 1f 5c ce af c7 43 19 95 a0 16 65 a5 4e 19 39 d2 5b 94 db 64 b9 e4 5d 8d 06 3e 1e 6a f0 7e 96 56 16 2b 0e fa 40 42 75 ea 5a 44 d9 59 1c 72 56 b9 fb e6 51 38 98 b8 02 27 72 19 88 57 16 50 94 2a d9 46 68 8a

httpd receiving on socket 29 conn_request

POST /fp-setup RTSP/1.0 X-Apple-ET: 32 Content-Length: 164 Content-Type: application/octet-stream CSeq: 5 DACP-ID: 3243622BC5922E88 Active-Remote: 124334687 User-Agent: AirPlay/610.14.1

46 50 4c 59 03 01 03 00 00 00 00 98 01 8f 1a 9c b0 32 54 9f 3c fa e4 8e 71 6a 89 cf 6e c8 62 54 56 bf db 27 9c e6 50 9f d7 72 bc ee 41 ad 30 f4 b9 2f 1a ff 18 1c 17 c1 f2 ac b0 a5 14 2b bb 22 67 54 af d2 3e aa 49 62 ef 5e 34 a1 e4 2d 03 72 a1 e5 22 02 78 18 18 bd aa dc ad af df b7 20 d5 b6 0a da 32 7e f7 6d d1 48 87 c6 6c f7 c4 3e 76 52 59 03 ee f7 1e 02 6e 13 e9 6d d6 4b 81 26 8b c5 32 3e 43 16 dc 13 86 77 88 15 84 99 dd e3 2b 71 aa 4f af 3c 48 7d 3d 1a e4 e7 ab e9 88 fb a8 c3 64 05 d6

Handling request POST with URL /fp-setup

RTSP/1.0 200 OK CSeq: 5 Server: AirTunes/220.68 Content-Type: application/octet-stream Content-Length: 32

46 50 4c 59 03 01 04 00 00 00 00 14 71 aa 4f af 3c 48 7d 3d 1a e4 e7 ab e9 88 fb a8 c3 64 05 d6

httpd receiving on socket 29 conn_request

SETUP rtsp://192.168.133.211/17335642223661105797 RTSP/1.0 Content-Length: 540 Content-Type: application/x-apple-binary-plist CSeq: 6 DACP-ID: 3243622BC5922E88 Active-Remote: 124334687 User-Agent: AirPlay/610.14.1

<?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">

et 32 eiv 8YjxzaKpoGqDiA0r/bK11A== timingProtocol NTP sessionUUID F09492C1-1695-4285-8C8A-CE766900FD1B osName macOS osBuildVersion 21E5196i sourceVersion 610.14.1 timingPort 61513 isScreenMirroringSession osVersion 12.3 ekey RlBMWQECAQAAAAA8AAAAANHm7isw1x8vqjAynUkkyMEAAAAQ8g5kFTS3EgeItjemQtF6 MdoAjoVXRHADccijLfaky/wG4fHS deviceID 14:7D:DA:C3:D9:BF model MacBookAir9,1 name {name here} macAddress 14:7D:DA:C3:D9:BF

Handling request SETUP with URL rtsp://192.168.133.211/17335642223661105797 DACP-ID: 3243622BC5922E88 Active-Remote: 124334687 Transport: null SETUP 1 eiv_len = 16 16 byte aesiv (needed for AES-CBC audio decryption iv): f1 88 f1 cd a2 a9 a0 6a 83 88 0d 2b fd b2 b5 d4

ekey_len = 72 ekey: 46 50 4c 59 01 02 01 00 00 00 00 3c 00 00 00 00 d1 e6 ee 2b 30 d7 1f 2f aa 30 32 9d 49 24 c8 c1 00 00 00 10 f2 0e 64 15 34 b7 12 07 88 b6 37 a6 42 d1 7a 31 da 00 8e 85 57 44 70 03 71 c8 a3 2d f6 a4 cb fc 06 e1 f1 d2

fairplay_decrypt ret = 0 16 byte aeskey (fairplay-decrypted from ekey): da 6a 38 09 41 42 09 c8 56 77 9d 8e 2a 73 41 45

32 byte shared ecdh_secret: 16 1f 20 2d 1e f3 28 70 b2 1e 4e b0 70 83 7b 7f 47 ec ff 10 57 c8 d3 1d 85 7f ce 16 20 58 75 5a

Client identified as User-Agent: AirPlay/610.14.1 16 byte aeskey after sha-256 hash with ecdh_secret: 43 a8 3e 08 57 4e 2c ee 9e 9f 0a 2c 0d 93 c6 1e

timing_rport = 61513 raop_ntp parse remote ip = 192.168.133.245 raop_ntp starting time raop_ntp local timing port socket 30 port UDP 54653 raop_rtp parse remote ip = 192.168.133.245 raop_rtp_mirror parse remote ip = 192.168.133.245 eport = 42395, tport = 54653 raop_ntp send_len = 32, now = 1645044669191953

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

<?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">

timingPort 54653 eventPort 42395

raop_ntp receive time type_t packetlen = 32 raop_ntp sync correction = -1644740514929017 Accepted IPv4 client on socket 31 Local: 192.168.133.211 Remote: 192.168.133.245 Open connections: 2 httpd receiving on socket 29 conn_request

GET /info RTSP/1.0 X-Apple-ProtocolVersion: 1 CSeq: 7 DACP-ID: 3243622BC5922E88 Active-Remote: 124334687 User-Agent: AirPlay/610.14.1

Handling request GET with URL /info

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

<?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">

txtAirPlay GmRldmljZWlkPWU0OjVmOjAxOjA1Ojg2OjUxE2ZlYXR1cmVzPTB4NUE3RkZFRTYJZmxh Z3M9MHg0EG1vZGVsPUFwcGxlVFYzLDJDcGs9YjA3NzI3ZDZmNmNkNmUwOGI1OGVkZTUy NWVjM2NkZWFhMjUyYWQ5ZjY4M2ZlYjIxMmVmOGEyMDUyNDY1NTRlNydwaT0yZTM4ODAw Ni0xM2JhLTQwNDEtOWE2Ny0yNWRkNGE0M2Q1MzYOc3JjdmVycz0yMjAuNjgEdnY9Mg== features 130367356919 name UxPlay@raspi-4 audioFormats type 100 audioInputFormats 67108860 audioOutputFormats 67108860 type 101 audioInputFormats 67108860 audioOutputFormats 67108860 pi 2e388006-13ba-4041-9a67-25dd4a43d536 vv 2 statusFlags 68 keepAliveLowPower 1 sourceVersion 220.68 pk sHcn1vbNbgi1jt5SXsPN6qJSrZ9oP+shLviiBSRlVOc= keepAliveSendStatsAsBody 1 deviceID e4:5f:01:05:86:51 audioLatencies outputLatencyMicros type 100 audioType default inputLatencyMicros outputLatencyMicros type 101 audioType default inputLatencyMicros model AppleTV3,2 macAddress e4:5f:01:05:86:51 displays uuid e0ff8a27-6738-3d56-8a16-cc53aacee925 widthPhysical heightPhysical width 1920 height 1080 widthPixels 1920 heightPixels 1080 rotation refreshRate 60 maxFPS 30 overscanned features 14

httpd receiving on socket 29 conn_request

GET_PARAMETER rtsp://192.168.133.211/17335642223661105797 RTSP/1.0 Content-Length: 8 Content-Type: text/parameters CSeq: 8 DACP-ID: 3243622BC5922E88 Active-Remote: 124334687 User-Agent: AirPlay/610.14.1

volume

Handling request GET_PARAMETER with URL rtsp://192.168.133.211/17335642223661105797

RTSP/1.0 200 OK CSeq: 8 Server: AirTunes/220.68 Content-Type: text/parameters Content-Length: 13

volume: 0.0

httpd receiving on socket 29 conn_request

RECORD rtsp://192.168.133.211/17335642223661105797 RTSP/1.0 CSeq: 9 DACP-ID: 3243622BC5922E88 Active-Remote: 124334687 User-Agent: AirPlay/610.14.1

Handling request RECORD with URL rtsp://192.168.133.211/17335642223661105797 raop_handler_record

RTSP/1.0 200 OK CSeq: 9 Server: AirTunes/220.68 Audio-Latency: 11025 Audio-Jack-Status: connected; type=analog

httpd receiving on socket 29 conn_request

SET_PARAMETER rtsp://192.168.133.211/17335642223661105797 RTSP/1.0 Content-Length: 20 Content-Type: text/parameters CSeq: 10 DACP-ID: 3243622BC5922E88 Active-Remote: 124334687 User-Agent: AirPlay/610.14.1

volume: -20.000000

Handling request SET_PARAMETER with URL rtsp://192.168.133.211/17335642223661105797

RTSP/1.0 200 OK CSeq: 10 Server: AirTunes/220.68

httpd receiving on socket 29 conn_request

SETUP rtsp://192.168.133.211/17335642223661105797 RTSP/1.0 Content-Length: 204 Content-Type: application/x-apple-binary-plist CSeq: 11 DACP-ID: 3243622BC5922E88 Active-Remote: 124334687 User-Agent: AirPlay/610.14.1

<?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">

streams timestampInfo name SubSu name BePxT name AfPxT name BefEn name EmEnc latencyMs 100 type 110 streamConnectionID -5266743182493269368

Handling request SETUP with URL rtsp://192.168.133.211/17335642223661105797 DACP-ID: 3243622BC5922E88 Active-Remote: 124334687 Transport: null type = 110 streamConnectionID (needed for AES-CTR video decryption key and iv): 13180000891216282248 raop_rtp_mirror starting mirroring raop_rtp_mirror local data port socket 32 port TCP 42675 Mirroring initialized successfully

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

<?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">

streams dataPort 42675 type 110

raop_rtp_mirror accepting client

Received video streaming performance info packet from client httpd receiving on socket 29 conn_request

POST /feedback RTSP/1.0 CSeq: 12 DACP-ID: 3243622BC5922E88 Active-Remote: 124334687 User-Agent: AirPlay/610.14.1

Handling request POST with URL /feedback raop_handler_feedback

RTSP/1.0 200 OK CSeq: 12 Server: AirTunes/220.68

begin video stream wxh = 1920x1080; source 1920x1080 raop_rtp_mirror width_source = 1920.000000 height_source = 1080.000000 width = 1920.000000 height = 1080.000000 raop_rtp_mirror sps size = 30 raop_rtp_mirror pps size = 4 raop_rtp_mirror video ntp = 1645044671328713, now = 1645044671376349, latency = 47636 Segmentation fault pi@raspi-4{colon}~ $

I'm not sure if this is the version I received with "export GST_DEBUG=2" as I am not currently with my pi.

fduncanh commented 2 years ago

The segmentation fault seems to occur the first time a decrypted video packet is sent to GStreamer. (well, I suppose it could happen any time after

raop_rtp_mirror video ntp = 1645044671328713, now = 1645044671376349, latency = 47636

which is just before the decryption takes place)

OK I've added a new INFO message just before streaming video to GStreamer starts, in the github code, to check this. (But I'm pretty sure it's your GStreamer installation on Pi 4 that's not working) Please download latest github, and test again.

You don't need the uxplay -d option, but do use "export GST_DEBUG=2" just before running uxplay.

fduncanh commented 2 years ago

The latest github code will issue a message "Begin streaming to GStreamer video pipeline" just before the first decrypted video packet is sent to GStreamer for rendering. This is the boundary between uxplay and GStreamer.

TheThings027 commented 2 years ago

How to I uninstall the previous version?

fduncanh commented 2 years ago

Assuming you built it yourself (i.e. didnt install a 3rd party package like the ones on ArchLinux AUR) run "sudo make uninstall" in the directory you ran "sudo make install" in.

But just reinstall, it copies the new files over the old ones.

If you downloaded with "git clone ... " (i.e, you didn't download a zip file) just do "git pull" inside the UxPlay directory (or any subdirectory) to update the source.

TheThings027 commented 2 years ago

This is what I received from it:

$ uxplay 0:00:00.014091769 1824 0x556d550030 WARN vaapi gstvaapiutils.c:78:gst_vaapi_warning: vaGetDriverNameByIndex() failed with unknown libva error, driver_name = (null) 0:00:00.015973069 1824 0x556d550030 WARN vaapi gstvaapiutils.c:78:gst_vaapi_warning: vaGetDriverNameByIndex() failed with unknown libva error, driver_name = (null) 0:00:00.016954571 1824 0x556d550030 WARN vaapi gstvaapiutils.c:78:gst_vaapi_warning: vaGetDriverNameByIndex() failed with unknown libva error, driver_name = (null) 0:00:00.017273861 1824 0x556d550030 WARN default gstvaapi.c:231:plugin_init: Cannot create a VA display using system MAC address e4:5f:01:05:86:51 Initialized server socket(s) Accepted IPv4 client on socket 29 Local: 192.168.133.211 Remote: 192.168.133.245 Open connections: 1 Client identified as User-Agent: AirPlay/610.14.1 Accepted IPv4 client on socket 31 Local: 192.168.133.211 Remote: 192.168.133.245 Open connections: 2 raop_rtp_mirror starting mirroring ct=8 spf=480 usingScreen=1 isMedia=1 audioFormat=0x1000000 start audio connection, format AAC-ELD 44100/2 raop_rtp starting audio Begin streaming to GStreamer video pipeline 0:00:12.446040046 1823 0x55c573f180 WARN v4l2videodec gstv4l2videodec.c:861:gst_v4l2_video_dec_decide_allocation: Duration invalid, not setting latency 0:00:12.592726712 1823 0x55c573f180 WARN videodecoder gstvideodecoder.c:1246:gst_video_decoder_sink_event_default: error: No valid frames decoded before end of stream 0:00:12.592782544 1823 0x55c573f180 WARN videodecoder gstvideodecoder.c:1246:gst_video_decoder_sink_event_default: error: no valid frames found GStreamer error: No valid frames decoded before end of stream Removing connection for socket 29 Destroying connection Open connections: 1 Removing connection for socket 31 Destroying connection Open connections: 0

(uxplay:1823): GStreamer-CRITICAL **: 17:26:54.475: _gst_util_uint64_scale: assertion 'denom != 0' failed

(uxplay:1823): GStreamer-CRITICAL **: 17:26:54.475: gst_segment_to_running_time: assertion 'segment->format == format' failed

(uxplay:1823): GStreamer-CRITICAL **: 17:26:54.476: gst_segment_to_stream_time: assertion 'segment->format == format' failed Initialized server socket(s) ^CStopping... 0:00:21.886456207 1823 0x7fa40a30c0 WARN typefind gsttypefindelement.c:987:gst_type_find_element_chain_do_typefinding: error: Stream doesn't contain enough data. 0:00:21.886713666 1823 0x7fa40a30c0 WARN typefind gsttypefindelement.c:987:gst_type_find_element_chain_do_typefinding: error: Can't typefind stream

fduncanh commented 2 years ago

What OS (linux distribution and version) is being used? If it is debian-based, run sudo apt list --installed | grep -i gstreamer to see what gstreamer packages are installed

  1. initial gstreamer errors: gst_vaapi is probably the GStreamer plugin for Intel hardware accelerated graphics. uninstall the gstreamer-1.0-vaapi plugin package. Its certainly not appropriate for a PI. However this may just be a futile attempt to use vaapi that gets abandoned and is not the key error.

  2. This is the real error, I believe.

    0:00:12.446040046 1823 0x55c573f180 WARN v4l2videodec gstv4l2videodec.c:861:gst_v4l2_video_dec_decide_allocation: Duration invalid, not setting latency
    0:00:12.592726712 1823 0x55c573f180 WARN videodecoder gstvideodecoder.c:1246:gst_video_decoder_sink_event_default: error: No valid frames decoded before end of stream
    0:00:12.592782544 1823 0x55c573f180 WARN videodecoder gstvideodecoder.c:1246:gst_video_decoder_sink_event_default: error: no valid frames found

    GStreamer is trying to use v4l2videocodec (Video for Linux 2) This is probably the way to access hardware h264 decoding on the PI 4. But its not working. I have no idea about this without a PI 4. Maybe a special GStreamer pipeline is needed for the PI. (I will soon have one to experiment with.) Some Pi user sites could be useful.

The pipeline is created in lib/rendererers/video_renderer_gstreamer.c lines 124-129 (default videosink on line 128 is "autovideosink".) If you are able to experiment.

But maybe just some kind of configuration on the PI is needed? (I have no idea about it)

TheThings027 commented 2 years ago

So I am running raspberry pi OS 64-bit (debian based) and I tried what you said. Still doesnt appear to be working.

I also could not find the file you were speaking of. "video_renderer_gstreamer.c" (mind you, you said "video_rendererer_gstreamer.c" and I tried that aswell with no luck.

fduncanh commented 2 years ago

uxplay itelf is working fine, the issue is to get gstreamer working on the PI.

the default pipeline uses decoder = "decodebin" and videosink="autovideosink"

 GString *launch = g_string_new("appsrc name=video_source stream-type=0 format=GST_FORMAT_TIME is-live=true ! queue ! ");
    g_string_append(launch, decoder);                                     <---------- decoder="decodebin"
    g_string_append(launch, " ! videoconvert ! ");
    append_videoflip(launch, &videoflip[0], &videoflip[1]);
    g_string_append(launch, videosink);                         <------------------videosink="autovideosink"
    g_string_append(launch, " name=video_sink sync=false");
    renderer->pipeline = gst_parse_launch(launch->str,  &error);

This pipeline should automatically discover what GStreamer elements to use on your system, if things are set up properly. The default pipeline this code constructs with gst_parse_launch is:

appsrc name=video_source stream-type=0 format=GST_FORMAT_TIME is-live=true ! queue ! decodebin ! videoconvert ! autovideosink name=video_sink sync=false

One needs to find someone's example for a h264 decoder pipeline on the PI 4B with current OS to see if this needs modifying.

fduncanh commented 2 years ago

UxPlay/renderers/video_renderer_gstreamer.c

fduncanh commented 2 years ago

read this:

https://qengineering.eu/install-gstreamer-1.18-on-raspberry-pi-4.html

fduncanh commented 2 years ago

Its obviously complicated to get the Pi working with the new 64 bit Bullseye Raspberry PI OS, but eventually it will be known on the internet exactly what to do. You might want to try "legacy" 32bit Buster version until things settle down,

fduncanh commented 2 years ago

heres a wild guess:

in UxPlay/renderers/video_renderer_gstreamer.c, replace the line 125 gstring_append(launch, decoder); by gstring_append(launch, " h264parse ! v4l2h264dec ");

TheThings027 commented 2 years ago

Ooh, I just started re-installing the pi.

fduncanh commented 2 years ago

whatever. See if that makes it work after the re-install. (I dont know if v4l2h264dec is specific to the new Bullseye OS)

For this beast, it would be good to have a number of SD cards with different versions of the OS for booting from.

TheThings027 commented 2 years ago

Well, I have a second if that would be better.

fduncanh commented 2 years ago

You are the one with the PI, so good luck!

fduncanh commented 2 years ago

v4l2h264dec is available on buster too. I will add a undocumented option -v4l2 to uxplay github now that may be removed later that will use this instead of decodebin because there is a very similar option -avdec already there.

fduncanh commented 2 years ago

OK github uxplay now has undocumented option -v4l2 which may help for the PI (or not).

needs gstreamer1.0-plugins-good I think. good luck!

fduncanh commented 2 years ago

also try uxplay -avdec (software h264 decoding)
as well as uxplay -v4l2 (hardware h264 decoding, should be much better when working)

fduncanh commented 2 years ago

If you get an error message

uxplay -v4l2
0:00:00.053954010 16371      0x1a40a30 WARN     GST_ELEMENT_FACTORY gstelementfactory.c:458:gst_element_factory_make: no such element factory "v4l2h264dec"!
0:00:00.053978444 16371      0x1a40a30 ERROR           GST_PIPELINE grammar.y:816:priv_gst_parse_yyparse: no element "v4l2h264dec"
0:00:00.053995032 16371      0x1a40a30 ERROR           GST_PIPELINE grammar.y:901:priv_gst_parse_yyparse: link has no sink [source=@0x1a47260]
0:00:00.054352853 16371      0x1a40a30 ERROR           GST_PIPELINE grammar.y:901:priv_gst_parse_yyparse: link has no source [sink=@0x1a52740]

also see this

https://stackoverflow.com/questions/64426904/no-such-element-or-plugin-v4l2h264enc it says


I had the same problem with on a raspberrypi 4 with gstreamer and solved it by enabling the kernel side support (often referenced as "v4l2m2m").

You can check it is activated because you get new /dev/video character device files in addition to /dev/video0. (for me it's 3 new files /dev/video[10,11,12]).

Check that the kernel module is loaded or load it with:

modprobe bcm2835-codec

Then gst-inspect-1.0 video4linux2 should show you the elements you are looking for, such as v4l2h264dec, v4l2h264enc, v4l2vp8dec, .... (sometimes gst-inspect-1.0 does not really retry but relies on a cache which might not reflect recent changes: removing the cache can be helpful. In my install I do rm ~/.cache/gstreamer-1.0/registry.armv8-a.bin)
fduncanh commented 2 years ago

more clues https://forums.raspberrypi.com/viewtopic.php?t=316381

https://www.linkedin.com/pulse/video-analytics-edge-using-raspberry-pi-4-intel-ncs-aby-paul-varghese

https://forums.raspberrypi.com/viewtopic.php?t=234778

"The hardware H.264 encoder on the Raspberry Pi 4 supports only resolutions of 1920x1080 or lower. 

(probably same for decoder) this is OK default for uxplay is 1920x1080

Still seems like a lot of work to get this going.

Strategy: First get things working (probably badly) with uxplay -fps 10 -avdec
so we stream at 10 fps. maybe get audio working with this as well.

Afterwards work out how to get things working with uxplay -v4l2 and hardware decoding for good quality video at 30fps. (the default).

when success happens, write up a wiki page with the recipe.

TheThings027 commented 2 years ago

Okay, I have succesfully put raspberry pi OS 32 bit onto my SD card and I am installing the software right now.

TheThings027 commented 2 years ago

We have struck gold! Using -avdec allows the video to pass through!

However, the audio sounds like a very distorted mouse.

Latency (not sure if this is my internet or not as it is not wired) is about 30 seconds to a minute.

TheThings027 commented 2 years ago

using -v4l2 seems to fail as before.

fduncanh commented 2 years ago

OK -avdec is using software decoding for the h264 video stream, but the CPU on the older PI's was not powerful enough to process 30fps video, and dropped frames, giving a jerky picture. Maybe the Pi 4 has become powerful enough, but the correct thing should be to use the PI's GPU which has built in h264 hardware decoding. We also need to fix the sound.

From what I read, something needs to be activated to access the built in h264 hardware decoding.

first, lets see what is available to gstreamer: please report the output of

sudo apt list --installed | grep -i gstreamer

and

gst-inspect-1.0 video4linux2 
fduncanh commented 2 years ago

for the sound, what kind of sound system/ speaker is it playing through? I think the Pi sends out sound with the HDMI signal. or are you using a different sound device? Is the sound just poor quality or is it completely messed up?

I see that Your Raspberry Pi can either send sound to the screen’s built-in speakers through the HDMI connection (if your screen has speakers), or to the analogue headphone jack.

TheThings027 commented 2 years ago

As for your first comment:

  1. Spits out

gir1.2-gstreamer-1.0/stable,now 1.18.4-2.1 armhf [installed,automatic] gstreamer1.0-alsa/stable,now 1.18.4-2 armhf [installed] gstreamer1.0-libav/stable,now 1.18.4-3 armhf [installed] gstreamer1.0-omx/stable,now 1.0.0.1-0+rpi12+jessiepmg armhf [installed] gstreamer1.0-plugins-bad/stable,now 1.18.4-3 armhf [installed] gstreamer1.0-plugins-base/stable,now 1.18.4-2 armhf [installed] gstreamer1.0-plugins-good/stable,now 1.18.4-2 armhf [installed] gstreamer1.0-vaapi/stable,now 1.18.4-2 armhf [installed] gstreamer1.0-x/stable,now 1.18.4-2 armhf [installed] libgstreamer-gl1.0-0/stable,now 1.18.4-2 armhf [installed,automatic] libgstreamer-plugins-bad1.0-0/stable,now 1.18.4-3 armhf [installed,automatic] libgstreamer-plugins-base1.0-0/stable,now 1.18.4-2 armhf [installed,automatic] libgstreamer-plugins-base1.0-dev/stable,now 1.18.4-2 armhf [installed] libgstreamer1.0-0/stable,now 1.18.4-2.1 armhf [installed,automatic] libgstreamer1.0-dev/stable,now 1.18.4-2.1 armhf [installed]

and 2. spits out an error -bash: gst-inspect-1.0: command not found

should this be installed?

As for your second comment.

The sound is being sent through hdmi to my monitor which has no speakers. the monitor had an audio out port which is connected to my headphones.

The audio is completely messed up.

fduncanh commented 2 years ago

install

 gstreamer1.0-tools                          (should have gst-inspect-1.0 in here) 
 gstreamer1.0-gl 
 gstreamer1.0-gtk3
 gstreamer1.0-pulseaudio               (probably (?) this will fix audio)
fduncanh commented 2 years ago

@TheThings027 now have a R Pi 4B with 8GB now running raspi OS bullseye, am experimenting.

fduncanh commented 2 years ago

opening a new issue for the R Pi.