Stream content to Unity#
MiddleVR NDI#
This is a package that allows sending/receiving video frames between computers using NDI.
It is based on the open-source KlakNDI plugin: KlakNDI - https://github.com/keijiro/KlakNDI
NDI® (Network Device Interface) is a standard developed by NewTek, Inc that enables applications to deliver video streams via a local area network. Please refer to ndi.tv for further information about the technology.
Streaming sources#
NDI offers a wide range of sources for streaming:
-
Windows desktop: By using NDI Screen Capture you can stream the content of any Windows desktop. This allows you to display any Windows software like Microsoft Powerpoint, Excel, a web browser, a video, a webcam ...
-
Phone / tablet: Stream the screen or camera with apps such as NDI HX Capture
System Requirements#
-
Note: You need to make sure that all cluster clients are on the same local network as the NDI source.
-
Windows: D3D11 and D3D12 are supported
All the standard render pipelines are supported (built-in, URP, and HDRP).
Installation#
You must add the MiddleVR_NDI package at C:\Program Files\MiddleVR3\unity_packages\com.middlevr.ndi.tgz
NDI Display prefab#
There is a prefab that you can easily use in Packages/MiddleVR_NDI/Runtime/Assets/Prefabs/MVRNDIDisplay.prefab
.
It includes the Cluster Texture script so that the texture is correctly synchronized on the cluster.
NDI Receiver Component#
The NDI Receiver component (Packages/MiddleVR NDI/Runtime/Component/NdiReceiver.cs
)
receives a video stream and feeds it to the main texture of the renderer.
-
NDI Name - Specify the name of the NDI source. You can edit the text field or use the selector to choose a name from currently available NDI sources. If Name is empty, the component will check every second for new sources and will take the first one in case of change of the first source name. It will ignore the sources containing "Remote Connection" if another source is available.
-
Width, Height: Resolution of the texture displaying the stream. Note: The source texture from the stream might have a different resolution, which can even vary during runtime, but Cluster Texture requires a fixed resolution.
You can extract metadata using .metadata
property.
NDI Sender Component#
The NDI Sender component (Packages/MiddleVR NDI/Runtime/Component/NdiSender.cs
)
sends a video stream from a given video source.
NDI Name - Specify the name of the NDI endpoint.
Enable Alpha - Enable this checkbox to make the stream contain the alpha channel. You can disable it to reduce the bandwidth.
Capture Method - Specify how to capture the video source from the following options.
- Game View - The sender captures frames from the Game View.
- Camera - The sender captures frames from a given camera. Note: This option only supports URP and HDRP.
- Texture - The sender captures frames from a texture asset. You can also use a render texture with this option.
You can attach metadata using .metadata
property.
Tips for Scripting#
You can enumerate currently available NDI sources using the NDI Finder class
(NdiFinder
). See the [Source Selector] example for usage.
Source Selector: Test/SourceSelector.cs
You can instantiate the NDI Sender/Receiver component from a script but have
to specify an NDI Resources asset (NdiResources.asset
) right after the
instantiation. See the [Sender Benchmark]/[Receiver Benchmark] examples for
details.
Sender Benchmark: Test/SenderBenchmark.cs
Receiver Benchmark : Test/ReceiverBenchmark.cs