-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trying to add h265 support (for modern clients with wired connection) (was *** ERROR: unsupported h265 video detected) #233
Comments
Take a look at the discussion in #231 |
Thanks, I'll wait for good news. Should I close the issue? |
The h265 seems to be decoded properly, and now its recognized, it should be easy to handle =. But it needs a gstreamer pipeline to be written. As of now I don't know if it will just be modifying "h264" to "h265", or more complicated. I will need to get a macO or iPadOS client to deliver h265. It seems ethernet connections instead of wifi are what triggers it? @DYY-Studio, how to you get the iPad to use ethernet? Is there a dongle for that? I have one for a mac M2 with usb c |
@fduncanh The H265 just happened when I use Ethernet on iPad. I have tried using Ethernet on my Windows laptop but Wi-Fi on my iPad, it didn't show the error. I haven't tried whether the connection between my laptop and iPad can reach full 1Gbps, but the Speed Test on both devices show that the connections to Internet are 1Gbps. |
I tried with a usb-c to ethernet adapter. I was achieving full gigabit speeds on LAN, but the ipad decided to use h264. I think I have an older model so I probably won't be able to help out here |
I have a What else should I need? (M2 macbook pro and M2 ipad pro are available as test clients) ?just plug into client usb port and connect to 1GB hub of local network? |
@fduncanh The cable go directly to the router's 1Gbps port, and my laptop was using the router's Wi-Fi. It seems that it's just about iPad's Ethernet connection.
H264
H265
H265
H264 All the Ethernet connection I used is 1Gbps. |
@ionull @DYY-Studio |
The difficulty in getting h265 supported is that the first video packet (which is unencrypted, "type 0x01") carries no payload:
??? why is the type 0x01 packet (see lib/raop_rtp_mirror.c) missing the VPS+SPS+PPS data? Where to find it?
https://www.codeproject.com/tips/896030/the-structure-of-hevc-video EDIT: maybe the VPS+SPS+PPS data is in the IDR slice but not as separated NALS?? If so, how to tell gstreamer h265parse ? |
*
I will test this idea when I have the time.
EDIT: It might be that the new h265 protocol won't send any unencrypted data to an AirPlay Server that does not use the newer AirPlay 2 protocol that used fully-encrypted server-client communications.??? Some wireshark studies on how h265 works on an AppleTV 4K might help, but its not clear if any other project besides UxPlay is interested in AirPlay video as opposed to Audio. Suggestions welcomed! |
You write
Just out of interest: Are you using AirMyPC on the Windows computer (or something else)? |
@fduncanh Other softwares I have tried once but in that time I didn't have the idea that to use Ethernet to enhance stability, and also I didn't have iPad. Some of the software I tried limit the bitrate of AirPlay, the using time or the display size. That makes me try to find a better one, which leads me to UxPlay. I can't remember what softwares I have tried, sorry. |
I see. Am I correct that you are running UxPlay as an AirPlay server on a windows PC, using it to mirror an iPad client? AirMyPC emulates an AirPlay client on windows |
@fduncanh I want to replace iOS system screen-recorder but a good HDMI video capture card is too expensive. AirPlay seems like a good choice for its high bitrates and full resolution display. |
This is an issue that can't be solved without understanding the Apple AirPlay2 protocol better. closing for now. |
I tried to copy the file header vps+sps+pps from other h265 streams. Obviously I failed. I continued to try more possibilities. |
The mystery is WHERE does Apple send the vps+sps+pps?, or what causes the client to NOT send them to UxPlay with the unencrypted packet |
If nothing else I can suggest that you plug in your phone into your laptop and use idevice tools' logger to see if there are any clues |
I've got a 4K Apple TV and have captured the Wireshark packets (they were captured over awdl0 since it prefers p2p) - I'm willing to send them over to you, only issue is that I do believe the data is encrypted as after the pair-verify stage there is no readable transfer of data. I really would like to get H265 going as I want to make a portable equivalent of an Apple TV, I've got Bluetooth IP Address advertisement working now so it has more reliable discovery and I just want to get some crisper quality to go with it. |
The Apple TV 4k will probably tell the client it supports coreutils pairing and encryption (features bit 48) some aspects of this are understood (but not by me). Uxplay is using legacy pairing. you could post what you found up to pair verify, just to see what the initial phase before encryption is. Probably wont help solve the h265 riddle though. |
Okay, I have a different idea, I'll see if I can set up a mitm proxy and the only thing I change is zeroing all pairing bits except for legacy pairing so that then the packets we're looking for should be readable to then determine if the h265 header contains anything different in that scenario. |
If you could post the initial unencrypted communications you captured one can look at the features code to see what the apple TV is telling the client. |
Okay so I did some testing and after setting up a proxy for the Apple TV 4k (being spoofed so that it supports only the legacy pairing and the UxPlay features bits) the device will connect, get the full way through the handshake (and initiate the stream), but once the data port is sent from the server, the client will immediately initiate a TEARDOWN, almost as though the Apple TV isn't sending through enough info for it to start sending the stream?? I've literally got right up to the finish line here and it's refusing to go and send the next packet (which is the most important one as it will be the h265 header!!) |
Reopened: |
Okay nevermind, there is hardware accel decoding for Raspberry Pi 4 (and I assume 5) as when I playback a raw hevc video from online on VLC that says in the console "avcodec decoder: Using DRM Video Accel for Hardware Decoding" but the same message does not display when I play back a video dump. I'll see if I can investigate why this is happening... I wonder if the hardware decoder just doesn't support the format it's being fed? Maybe bt709 isn't supported? Or maybe it's the chroma format? |
the GST_DEBUG=4 messages will show if that is the case. (or if anything else like that is happening) It was for the v4l2 ,h264, which is why the -bt709 option is there (that was a fix I used, before the fix I got into gstreamer |
I don't think I can get to that stage atm, since GStreamer doesn't have a h265 hardware decoder sink at all for the RPi 4 from what I can tell. Is that the same with you @fduncanh ? I do have most of the gst plugins installed (good, bad and base) |
what modules does lsmod show are working (or at least loaded) when vlc is using acceleration.? take a look at https://github.com/FDH2/UxPlay/wiki/Gstreamer-Video4Linux2-plugin-patches |
Could you explain what you need me to do sorry - Is it literally just run |
yes lsmod | grep bcm, probably, |
Pi 4b Full output (
|
Well you can see it all there... The more obvious new module is rpivid_hevc. |
From what I've been reading I think the HEVC decoder block is very specific and only supports certain compression codecs. I don't think we have much control over what gets sent by the client but from memory I think there is a |
Hmm, perhaps it's worth investing some time into getting 4:4:4 implemented then? I'll need to have a look some time this week at the flat that I referenced earlier ( |
I posted a question on GStreamer forum to see if anyone gives advice https://discourse.gstreamer.org/t/v4l2-stateless-api-support/3339 |
Perfect, should anyone respond just double check what yuv standards are supported since it seems like only a select few (not the one that's used by airplay) are supported |
This is the code in question. (ffmpeg patch for rpi HEVC) See the issues for comments by its author ("jc-kynesim/rpi-ffmpeg#80 https://github.com/jc-kynesim/rpi-ffmpeg EDIT: its a whole version of ffmpeg that is patched. hopefully the history can help spot where the rpi work is found |
some info from the author of the ffmpeg patch: |
@connorh315 got a (terse) response:
|
I've been doing quite a lot of research into alternatives for this. Since all official Raspberry Pis run off the Broadcom chip there is no chance since interfacing with the VPU is kept proprietary from my understanding. So instead I looked into alternative SBCs. I went ahead and bought an Orange Pi Zero 2W about 2 weeks ago that arrived yesterday. The OPi runs with an AllWinner SOC (rather than a Broadcom)... I flashed an image and installed UxPlay and h.264 was alright (except for a certain resolution where eventually I started to get severe artifacting) and then h.265 is non-existent too as the driver only supports h.264. Supposedly Android TV can decode h.265 but I can't even get an image bootable to be able to test that fact. However I found a wiki online that quite clearly outlines that the VPU is not supported in mainline linux for the AllWinner SOCs (and also countless hours of research backs this) so that rules out the Allwinner chips. This then leaves one final SOC that would offer H.265 which is the Rockchip processors. There's about 6/7 SOCs that have been used in the last 5 years that all supposedly support h.265 decoding. From research though, the VPU driver (rkvdec) only ever supported h.264 decoding and h.265 was planned but has never made it to fruition. The only chip that has any support is the RK3399 but that's because of a patch that was rolled in. The rest of them have zero support for h.265. Even the newer processors only seem to have had their VPU driver rolled out back in June (rkvdec2) and that again only supports h.264. It's a bit of a minefield atm with these boards. I don't really understand how manufacturers can justify advertising SBCs as having hardware capabilities but they don't actually provide any way of accessing it - That's off topic though. I'm thinking that I need to look some more into the RPi's h265 decoder that seems to have some partial support? Last time I checked though I couldn't actually get it to accurately decode the uxplay stream from a file as it was an unsupported compression format?? Kind of hoping someone else has made more progress as unfortunately I'm all out of options now and I really still want to make a small plug-n-play uxplay receiver that can run off a USB-C connection. |
T here is another response on the gstreamer discourse:
If the ffmpeg work by js-kinesim shows how to interface to broadcom, the stateless gstreamer v4l2 interface (which we now know is in gstreamer1.0-plugins-bad, can perhaps be got to work with it. active development is going on: |
Good to see that something is going on but I have a feeling it'll be another year until we get h265 working. On another note though, I was surprised to find that the raspberry pi 4 can decode the h265 sent from apple devices correctly using hello_drmprime. I'll have a go at building rpi-ffmpeg (which I believe should do the same) later on today but at the very least the hardware is there to support it. All that's needed now is for the necessary changes to be ported over to gstreamer. EDIT: rpi-ffmpeg can also decode the airplay h265 streams. I'm going to have a go at hijacking ffmpeg in place of gstreamer in UxPlay and output the decoded result directly to the framebuffer over the weekend. |
some more info here: |
because the jc-kinesim github repository is difficult to view directly (because of a github 1000 file per directory viewing limit) I created a clone with all but the v4l2 files removed from the libavcodec directory of branch "test/5.1.6/main. https://github.com/fduncanh/rpi-ffmpeg/tree/test/5.1.6/main/libavcodec |
@fduncanh you said you've done something similar to this before right? How difficult of a process is this? |
I just did a few fixes in the gstreamer 44l2 code that accesses the STATEFUL h264 decoded on rpi 4b. The stateless decoder seems to be simpler, leaving userspace to do all the difficult organising needed. The process is only viable if that's already there in the gstreamer code (this might be the case). There is an OUTPUT queue into which the encoded frames are put. The R Pi driver decodes them and puts the decoded frame in the CAPTURE queue for gstreamer to use them. I am not really sure how the connection to the driver (proprietary) gets made, maybe see this in the jc-kinesim code or ask again. see
|
https://www.linuxtv.org/downloads/v4l-dvb-apis/userspace-api/v4l/dev-mem2mem.html
*CAPTURE
https://www.linuxtv.org/downloads/v4l-dvb-apis/userspace-api/v4l/dev-stateless-decoder.html |
@connorh315 can we move further discussion of this to the new issue #358 I opened:
|
this issue moved to #358 |
iOS 16.5.1
iPad Pro 4 (11-inch)
When I use Ethernet to AirPlay(Both iPad and my Windows Computer), it shows the error message, but Wi-Fi would not.
Do we have any plan to support the h265 video?Thanks.
By the way, Wi-Fi here is too bad to AirPlay a fluent video, that's why I want to use Ethernet.
The text was updated successfully, but these errors were encountered: