Skip to content

Instantly share code, notes, and snippets.

@KhaosT
Last active April 21, 2024 03:49
Show Gist options
  • Star 48 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KhaosT/e9b60fc0fb99b9f4512759b953cbf38c to your computer and use it in GitHub Desktop.
Save KhaosT/e9b60fc0fb99b9f4512759b953cbf38c to your computer and use it in GitHub Desktop.
Guide for using Apple Vision Pro as HDMI display

Displaying HDMI sources on Apple Vision Pro

While it's possible to stream most content to Apple Vision Pro directly over the internet, having the ability to use Apple Vision Pro as an HDMI display can still be useful.

Since Apple Vision Pro does not support connecting to an HDMI input directly or using an HDMI capture card, we have to be a little creative to make this work. NDI provides the ability to stream HDMI content over a local network with really low latency, and it works great with Apple Vision Pro.

This page shows the setup I’m using.

What’s needed

  • HDMI NDI Encoder
    • Personally, I recommend the Kiloview N40, as it supports streaming up to 4K60 while being fan-less, and can use USB-C as a power input.
    • Kiloview N60 comes with more features, but it’s larger and has a fan.
  • Vxio app
    • I made this one, you can also use other NDI monitor apps as well.
    • Separately, Finn made Castaway that makes it possible to use a USB Capture Card + Mac/iPad instead of an NDI encoder. It's a more cost effective option for most people I imagine.

Things to consider

  • To ensure high video quality, an NDI stream typically consumes significantly more bandwidth than a typical H.264/H.265 stream. Before purchasing the encoder, make sure your network can support data transfers at that speed.
    • For 4K60 stream, the bandwidth required is typically around 250~300mbps. If you're having issue to stream smoothly, try go to the encoder's settings page and reduce the streaming quality.
    • You can test this with some free software NDI encoders.
  • Since this setup requires encode and decode the video content, it is not latency free. From my experience, I typically see 3~4 frames (~50ms, same as moonlight based on my measurement) of delay from the content source.

Setup

Setting up an NDI encoder is pretty straightforward. Just connect the device to your local network via Ethernet, supply power, and connect the HDMI input to the encoder.

If the visionOS shows the Local Network permission dialog, and after granting the permission the app still shows searching, you may need to force close the app, and reopen it.

After that, you should be able to see the encoder show up as a source in the Vxio app. Select the source, and you'll get your HDMI display 🎉

Screenshot

Misc

Adjusting audio queue size

Depending on the NDI encoder, the default audio queue size might be too small for some devices. In that situation, try increasing the audio queue size so that the audio no longer experiences abrupt stops between samples.

Disable Multi-TCP

If your Wi-Fi channel is congested, you can try force N40 to use UDP instead of Multi-TCP. In my experience, UDP performs a lot better in those network condition. You can do so from the N40's configuration UI, select NDI Connection -> Multi-TCP Disallowed.

UDP

Portable setup

I was able to make this setup portable by getting one of those mini router (GL.iNet Beryl AX) with a LAN port.

IMG_3978 IMG_3979

#AppleVisionPro #visionOS

@Amiral-Benson
Copy link

Would that setup works with HDMI sources protected by HDCP, such as Blu-ray UHD players, etc.

I was thinking about plug-in in into the HDMI output of an home theatre A/V Receiver, where the Receiver is fed by sources such as Blu-ray/UHD players, or TV Box running video films/series streaming platform apps (MyCANAL, Netflix, etc.).
Then turning off the sound of the Vision Pro.
Then seat on the couch of my home theatre dedicated room, without using the projector, but still using the 7.1 speakers while adding a ~50ms sound delay on the A/V Receiver.

Would then your app be able to showcase the video stream as a giant cinema screen floating over a lake like in the Vision Pro trailer demo ? Or it would be just over a regular background, and simulating a big screen, but not as giant as the one in their demo ?

If the content is not 16/9 but 2,39:1 film ratio, would it render the black bars, or cut them out ?

Thank you !

@KhaosT
Copy link
Author

KhaosT commented Jan 20, 2024

@Amiral-Benson

Would that setup works with HDMI sources protected by HDCP, such as Blu-ray UHD players, etc.

I only tested with the NDI encoder I'm using, and it was able to encode the stream correctly. Your mileage may vary.
Simulator Screenshot - Apple Vision Pro - 2024-01-20 at 09 45 44

Would then your app be able to showcase the video stream as a giant cinema screen floating over a lake like in the Vision Pro

It works with the system environments, like the ones you see from Apple's demo.

If the content is not 16/9 but 2,39:1 film ratio, would it render the black bars, or cut them out ?

Since the HDMI source in this case will output 16:9, you'll have black bars I believe. If you find some way to have an HDMI device to output in other aspect ratios, the app will adapt the canvas for that.

@Amiral-Benson
Copy link

Thank you very much @KhaosT for all those extra details and your app.
I now just wonder how great the experience is, watching films through your app on a 1200 inches virtual screen, versus 4K laser projector on a 135 inches screen.
Your solution is also more than 3 times cheaper.
I need to go through a Vision Pro demo to figure it out I guess.

@adrum
Copy link

adrum commented Jan 21, 2024

Any chance of publishing Vxio for tvOS?

@KhaosT
Copy link
Author

KhaosT commented Jan 21, 2024

@adrum given NDI has a different SDK for tvOS, and you have ability to connect HDMI directly to a TV, I probably won't bother to port the app over to tvOS 😅

@adrum
Copy link

adrum commented Jan 21, 2024

Yeah, I thought of the simplicity of just plugging it in directly to a TV making this not needed.

I just learned of NDI through this Gist, so I was researching it. After a while, I had thought of a scenario where moving some equipment to a rack and just using the AppleTVs in different rooms to pull whatever HDMI source I want through an IP controlled (HomeKit) HDMI switch.

I recognize you built the app to only bridge the gap from the lack of inputs for AVP.

I recognize there are other options out there for tvOS and NDI players, I just like running the same apps on all platforms if I can. Feb 2nd can't come soon enough!

@matchavez
Copy link

Was the audio off by 50ms, or was that synced ok?

@KhaosT
Copy link
Author

KhaosT commented Jan 23, 2024

Was the audio off by 50ms, or was that synced ok?

In simulator it looked/sound ok, but I guess it's hard to tell without the real headset 😅

@matchavez
Copy link

Here's to hoping I can pull off Red Dead Redemption 2 on a 40 foot tall screen. :)

@austinarchibald
Copy link

~50ms is a lot of latency, especially when you're also required to buy expensive hardware. You can get 1-10ms (depending on your host cpu, resolution, etc) with Sunshine + Moonlight streaming over ethernet. I'm going to just run iPad version of Moonlight on visionOS. WiFi would add a few more milliseconds, but will just use ethernet with Vision Pro when it's going to be plugged into power. Then I get about 20ms latency when I'm using Moonlight outside the home network.

Don't think this is the best solution unless you need to output a device that doesn't support streaming, like a Nintendo Switch or something. But PC, Mac, Linux, Playstation, XBox, etc all support high quality (looks native visually) streaming with the right software and ethernet setup.

@iNanisKa
Copy link

Do you try use it with windows ? or make a stream offilne ?
in quest 3 I use srcpy code that support stream video with offline + by using devloper mode it's work fine with me
But I want to ask who have this apple visino pro maybe find out

Any one who have answers please share it ASAP

Thank you

@micahnyc
Copy link

micahnyc commented Mar 7, 2024

Hey @KhaosT thanks for this!!!! Any chance you want to make the source for the app public? I would love to extends this to work with different shape screens.

@KhaosT
Copy link
Author

KhaosT commented Mar 8, 2024

Hey @KhaosT thanks for this!!!! Any chance you want to make the source for the app public? I would love to extends this to work with different shape screens.

There is no plan to open source this one since dealing with the process is kinda annoying and the app mostly just wraps around the NDI library. If you're interested in building something around NDI, you might want to explore using their library directly.

@lucid-max
Copy link

Hi @KhaosT I was wondering if you could elaborate a little bit on how you managed to build the NDI library for a VisionOS target. In the SDK there are library files only for iOS, macOS, and tvOS - all of which Xcode refuses to link to a VisionOS target. Are you building for iOS and then running that on the Vision? Or somehow building directly to VisionOS? The internet is sparse on these matters, any advice would be appreciated!

@KhaosT
Copy link
Author

KhaosT commented Mar 13, 2024

@lucid-max Yeah sure. Apple toolchain encodes the target platform information in the binary, and the linker will check that to see if something can be linked to your app. Since iOS and visionOS are from the same origin, and the underlying APIs are identical, it's possible to override the platform information to make iOS SDK linkable by the visionOS target. You can read more about how people does that from this article (https://bogo.wtf/arm64-to-sim.html, you need to change the target platform, instead of iOS simulator, change it to visionOS and visionOS simulator).

This technique is useful for using third party binary libraries on visionOS, as most of those have iOS slices that can be repurposed for visionOS without the vendor to do things on their side.

@IceNum
Copy link

IceNum commented Mar 30, 2024

I have no success converting ios.a to visionos.a file,Can you provide a visionos.a file for me to test? Thank you so much!

@IceNum
Copy link

IceNum commented Mar 30, 2024

@lucid-max Yeah sure. Apple toolchain encodes the target platform information in the binary, and the linker will check that to see if something can be linked to your app. Since iOS and visionOS are from the same origin, and the underlying APIs are identical, it's possible to override the platform information to make iOS SDK linkable by the visionOS target. You can read more about how people does that from this article (https://bogo.wtf/arm64-to-sim.html, you need to change the target platform, instead of iOS simulator, change it to visionOS and visionOS simulator).

This technique is useful for using third party binary libraries on visionOS, as most of those have iOS slices that can be repurposed for visionOS without the vendor to do things on their side.

I have no success converting ios.a to visionos.a file,Can you provide a visionos.a file for me to test? Thank you so much!

@KhaosT
Copy link
Author

KhaosT commented Mar 30, 2024

Unfortunately NDI’s SDK license agreement prevents me from redistributing their SDK so I won’t be able to upload that. What are the issues you ran into when trying to update LC_BUILD_VERSION’s platform information?

@IceNum
Copy link

IceNum commented Mar 30, 2024

image

I regenerated the visionos arm64 files. After integration, an error message about missing files appeared.

@KhaosT
Copy link
Author

KhaosT commented Mar 30, 2024

Do I only need to modify the platform information in these places?

Swapping platform should be sufficient.

I regenerated the visionos arm64 files. After integration, an error message about missing files appeared.

I didn't see this one in my conversion. When you repackage all the .o files, are you sure you included all of them?

@IceNum
Copy link

IceNum commented Apr 3, 2024

我只需要修改这些地方的平台信息就可以了吗?

交换平台应该足够了。

我重新生成了visionos arm64 文件。集成后,出现有关丢失文件的错误消息。

我在转换中没有看到这一点。当您重新打包所有 .o 文件时,您确定已包含所有这些文件吗?

Thank you

@Yamhao
Copy link

Yamhao commented Apr 6, 2024

Vxio app support NDI 6? N60 will support it with HDR feature. Thanks

@KhaosT
Copy link
Author

KhaosT commented Apr 6, 2024

@Yamhao yeah I plan to update it to support NDI 6. I’m waiting for N60 firmware update so I can test the support with a real thing before releasing the update.

@Yamhao
Copy link

Yamhao commented Apr 7, 2024

@Yamhao yeah I plan to update it to support NDI 6. I’m waiting for N60 firmware update so I can test the support with a real thing before releasing the update.

Wow!
I just bought N40 yesterday, and suddenly found N60 will support NDI6:(

@lightsailvr
Copy link

This is very cool - I'd be interested in collaborating on how to use NDI to display the video feed on a sphere for immersive video capture. This gives us immersive filmmakers a live preview on set. Would be similar to the app I made called VR.NDI (https://docs.google.com/document/d/1vFI9pNKhtdONcOa6RQ1Aa9w2iIXYvvgoHLlu42WtMyk/edit?usp=sharing) but for Apple Vision Pro. The current implementation of NDI I am using in Unity doesn't translate to Vision Pro sadly, plus I think a native approach would offer better performance.

@KhaosT
Copy link
Author

KhaosT commented Apr 7, 2024

@lightsailvr displaying NDI stream on a sphere is actually relatively straightforward, the app has all the necessary stuff integrated with RealityKit to make it work (right now it's only used to project it on a 3D model, you can check it out by long pressing on the NDI source and select Retro to see that). The challenge in this case is actually Vision Pro's terrible Wi-Fi performance... It can barely stream NDI|HB 4K right now, and I'm not sure it can do 8K+ over NDI for 360 videos without lagging all the times 😅

@jordainfg
Copy link

jordainfg commented Apr 16, 2024

Hi @KhaosT also left you a email. But maybe here’s easier to exchange thoughts.

  • A bit nitpicky, but adding rounded corners like Moonlight would be a very nice attention to detail.
  • 4K upscaling similar to Casteaway (with a toggle for non-4K inputs), making it possible to use more affordable NDI's like the Zowietek. And using less bandwidth by upscaling a 1080p 60fps input instead. I saw that Finn made the upscaler open-source. https://github.com/finnvoor/fx-upscale

@matte-schwartz
Copy link

looking forward to the upcoming NDI 6 update, would be happy to contribute to an NDI 6.0 SDK fund to get HDR encoding if necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment