Implementing NDI Video Sources in .NET Applications¶
Video Capture SDK .Net VideoCaptureCoreX VideoCaptureCore
Cross-platform support
The VideoCaptureCoreX engine with NDI runs on Windows, macOS, Linux, Android, and iOS via GStreamer; install the NDI runtime for each target platform. The classic VideoCaptureCore NDI source is Windows-only. See the platform support matrix and the Linux deployment guide.
Introduction to NDI Technology¶
Network Device Interface (NDI) is a high-performance standard for IP-based production workflows, developed by NewTek. It allows video-compatible products to communicate, deliver, and receive broadcast-quality video over a standard network connection with low latency.
Our SDK provides robust support for NDI sources, enabling your .NET applications to seamlessly integrate with NDI cameras and NDI-enabled software. This makes it ideal for live production environments, streaming applications, video conferencing solutions, and any system requiring high-quality network video integration.
Prerequisites for NDI Integration¶
Before implementing NDI functionality in your application, you'll need to install one of the following:
- NDI SDK - Recommended for developers building professional applications
- NDI Tools - Sufficient for basic testing and development
These tools provide the necessary runtime components required for NDI communication. After installation, your system will be able to discover and connect to NDI sources on your network.
For Android playback, install the NDI Advanced SDK for Android and package the ABI-specific libndi.so files with your APK. The Android and MAUI NDI Player samples look for the SDK Lib directory using the NdiAndroidSdkLib MSBuild property, then the NDI_ANDROID_SDK_LIB environment variable, then C:\Program Files\NDI\NDI 6 SDK (Android)\Lib.
Android applications that discover NDI sources should request these permissions:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
Discovering NDI Sources on Your Network¶
The first step in working with NDI is to enumerate available sources. Our SDK makes this process straightforward with dedicated methods to scan your network for NDI-enabled devices and applications.
Enumerating Available NDI Sources¶
var lst = await VideoCapture1.IP_Camera_NDI_ListSourcesAsync();
foreach (var uri in lst)
{
cbIPCameraURL.Items.Add(uri);
}
var lst = await DeviceEnumerator.Shared.NDISourcesAsync();
foreach (var uri in lst)
{
cbIPCameraURL.Items.Add(uri.URL);
}
The asynchronous enumeration methods scan your network and return a list of available NDI sources. Each source has a unique identifier that you'll use to establish a connection. The enumeration process typically takes a few seconds, depending on network conditions and the number of available sources.
For player UI, subscribe to NDISourcesChanged and start the watcher so the source list reflects senders that appear or disappear after the initial scan:
DeviceEnumerator.Shared.NDISourcesChanged += OnNDISourcesChanged;
DeviceEnumerator.Shared.StartNDISourceWatch();
Stop the watcher and unsubscribe during shutdown.
Connecting to NDI Sources¶
Once you've identified the NDI sources on your network, the next step is to establish a connection. This involves creating the appropriate settings object and configuring it for your specific requirements.
Configuring NDI Source Settings¶
// Create an IP camera source settings object
settings = new IPCameraSourceSettings
{
URL = new Uri("NDI source URL")
};
// Set the source type to NDI
settings.Type = IPSourceEngine.NDI;
// Enable or disable audio capture
settings.AudioCapture = false;
// Set login information if needed
settings.Login = "username";
settings.Password = "password";
// Set the source to the VideoCaptureCore object
VideoCapture1.IP_Camera_Source = settings;
// Select the operating mode before StartAsync:
// IPPreview — live preview only (no file output).
// IPCapture — preview + record to the configured Output_Format target.
VideoCapture1.Mode = VideoCaptureMode.IPPreview; // or VideoCaptureMode.IPCapture
await VideoCapture1.StartAsync();
In VideoCaptureCoreX, you have two options for creating NDI source settings:
Option 1: Using the NDI source URL
var ndiSettings = await NDISourceSettings.CreateAsync(VideoCapture1.GetContext(), null, "NDI URL");
Option 2: Using the NDI source name
var ndiSettings = await NDISourceSettings.CreateAsync(VideoCapture1.GetContext(), cbIPURL.Text, null);
Finally, set the source to the VideoCaptureCoreX object:
VideoCapture1.Video_Source = ndiSettings;
Android and MAUI NDI Player Pattern¶
The Video Capture SDK X Android and MAUI NDI Player demos use VideoCaptureCoreX as a simple NDI receiver/player. The same flow works for full-screen players, monitoring tools, and preview panels:
- Initialize the SDK.
- Enumerate NDI sources with
DeviceEnumerator.Shared.NDISourcesAsync(). - Keep the list fresh with
NDISourcesChangedandStartNDISourceWatch(). - Create
NDISourceSettingsfrom the selectedNDISourceInfo. - Assign the settings to
VideoCaptureCoreX.Video_Source. - Enable audio playback only when the selected source exposes audio streams.
- Stop and dispose the core when playback stops or the view closes.
var sources = await DeviceEnumerator.Shared.NDISourcesAsync();
var info = sources[0];
var settings = await NDISourceSettings.CreateAsync(null, info);
if (settings == null || !settings.IsValid())
{
throw new InvalidOperationException("Failed to create NDI source settings.");
}
var core = new VideoCaptureCoreX(videoView);
core.Video_Source = settings;
core.Audio_Play = settings.GetInfo()?.AudioStreams?.Count > 0;
await core.StartAsync();
Android Native UI¶
The Android sample uses VisioForge.Core.UI.Android.VideoViewGL as the renderer surface:
var core = new VideoCaptureCoreX(videoView);
On Android, request the network and multicast permissions before discovery. If the app builds without libndi.so for the current ABI, playback fails at runtime with DllNotFoundException, so verify the NDI Advanced SDK Lib path before packaging.
.NET MAUI UI¶
The MAUI sample registers VisioForge handlers in MauiProgram:
builder
.UseMauiApp<App>()
.ConfigureMauiHandlers(handlers => handlers.AddVisioForgeHandlers());
Create VideoCaptureCoreX with the platform view from the MAUI VideoView:
var core = new VideoCaptureCoreX(videoView.GetVideoView());
During shutdown, cancel pending source refreshes, unsubscribe from NDISourcesChanged, call StopNDISourceWatch(), stop/dispose VideoCaptureCoreX, and destroy the SDK if your app owns SDK lifetime.
Advanced NDI Configuration Options¶
Optimizing Performance¶
When working with NDI sources, performance considerations are important, especially in professional environments. Here are some tips to optimize your NDI implementation:
-
Network Bandwidth: Ensure your network has sufficient bandwidth for NDI streams. A typical HD NDI stream requires approximately 100-150 Mbps.
-
Hardware Acceleration: Enable hardware acceleration when available to reduce CPU usage and improve performance.
-
Frame Rate Control: Consider limiting the frame rate if you don't need the maximum quality, which can reduce network load.
-
Resolution Settings: Choose appropriate resolution settings based on your application's needs and available bandwidth.
Managing Multiple NDI Sources¶
For applications that need to handle multiple NDI sources simultaneously:
- Create separate capture instances for each NDI source
- Implement resource pooling to efficiently manage system resources
- Consider using a producer/consumer pattern for processing multiple streams
- Monitor system performance and adjust settings as needed
Error Handling and Troubleshooting¶
When implementing NDI functionality, it's important to handle potential issues gracefully:
Common NDI Connection Issues¶
- Source Not Found: Verify that the NDI source is active and on the same network
- Connection Timeout: Check network configuration and firewall settings
- Authentication Failure: Ensure credentials are correct if authentication is required
- Performance Issues: Monitor CPU and network usage during capture
Implementing Robust Error Handling¶
// The SDK does not expose NDI-specific exception types — the underlying GStreamer elements
// surface failures as generic Exception. Branch on the discovery result (null / empty) for
// "source not found", and on CreateAsync failure for connection issues.
try
{
var discovered = await DeviceEnumerator.Shared.NDISourcesAsync();
var match = discovered.FirstOrDefault(s => s.URL == ndiUrl);
if (match == null)
{
Log.Error($"NDI source not found on the network: {ndiUrl}");
return;
}
var ndiSettings = await NDISourceSettings.CreateAsync(VideoCapture1.GetContext(), match);
VideoCapture1.Video_Source = ndiSettings;
}
catch (Exception ex)
{
// All failures (discovery, settings creation, GStreamer element init, etc.)
Log.Error($"Failed to connect to NDI source: {ex.Message}");
}
Integration with Video Processing Workflows¶
NDI sources can be seamlessly integrated with other components of your video processing pipeline:
- Recording: Capture NDI streams to various file formats
- Live Streaming: Forward NDI content to streaming services
- Video Processing: Apply filters and effects to NDI sources in real-time
- Multi-view Composition: Combine multiple NDI sources into a single output
Sample Applications and Code References¶
To help you get started with NDI implementation, we provide several sample applications that demonstrate different aspects of NDI functionality.
Best Practices for NDI Implementation¶
To ensure optimal performance and reliability when working with NDI sources:
-
Perform Regular Source Enumeration: Network conditions and available sources can change; re-enumerate sources periodically.
-
Implement Connection Retry Logic: Network disruptions can occur; implement automatic reconnection attempts.
-
Monitor Stream Health: Track frame rates, latency, and connection stability to detect potential issues.
-
Handle Source Disconnections Gracefully: Implement event handlers for unexpected disconnections.
-
Test With Various NDI Sources: Different NDI implementations may have slight variations; test with various sources.
-
Package Android Native Libraries Per ABI: For Android receivers, include
libndi.sofor every ABI you ship. Missing ABI libraries produce runtime failures even if the APK builds. -
Respect Mobile Lifecycle: Stop playback when Android activities stop or MAUI pages/windows close, dispose the core, cancel source enumeration, and remove watcher event handlers.
Conclusion¶
NDI technology offers powerful capabilities for network video integration in .NET applications. With our SDK, you can easily incorporate high-quality, low-latency video from NDI sources into your software projects. Whether you're building a live production system, a video conferencing application, or any solution requiring network video, our NDI implementation provides the tools you need for success.
The code samples provided demonstrate the essential patterns for working with NDI sources, from enumeration and connection to capture and processing. By following these patterns and best practices, you can create robust NDI-enabled applications that deliver exceptional performance and reliability.
Related Documentation¶
- IP cameras overview — RTSP, ONVIF, and NDI source types at a glance
- RTSP camera source configuration — most common IP camera protocol
- ONVIF IP camera integration — standards-based IP camera discovery and PTZ control
- IP camera live preview tutorial — minimal working preview example
- RTSP protocol deep-dive — streaming protocol internals
- NDI streaming output guide — sending cameras, capture devices, and files to NDI
Visit our GitHub page to get more code samples.