Skip to content

Integrating RTSP Camera Streams in .NET Applications

Video Capture SDK .Net VideoCaptureCoreX VideoCaptureCore

Cross-platform support

The VideoCaptureCoreX engine runs on Windows, macOS, Linux, Android, and iOS via GStreamer; the classic VideoCaptureCore engine is Windows-only. See the platform support matrix for codec and hardware-acceleration details, and the Linux deployment guide for Ubuntu / NVIDIA Jetson / Raspberry Pi setup.

Setting Up Standard RTSP Camera Sources

Implementing RTSP camera streams in your .NET applications provides flexible access to network cameras and video streams. This powerful capability allows real-time monitoring, surveillance features, and video processing directly within your application.

For additional connection options and alternative protocols, please reference our detailed IP cameras documentation which covers a wide range of camera integration approaches.

// Create RTSP source settings object
var rtsp = await RTSPSourceSettings.CreateAsync(new Uri("rtsp://192.168.1.1:554/live"), "login", "password", true /*capture audio?*/);

// Set source to the VideoCaptureCoreX object
VideoCapture1.Video_Source = rtsp;

Optimizing for Low-Latency RTSP Streaming

Low latency is critical for many real-time applications including security monitoring, interactive systems, and live broadcasting. Our SDK provides specialized configurations to minimize delay between capture and display.

Our SDK includes a dedicated mode specifically engineered for low-latency RTSP streaming. When properly configured, this mode typically achieves latency under 250 milliseconds, making it ideal for time-sensitive applications.

// Create the source settings object.
var settings = new IPCameraSourceSettings();

// Configure IP address, username, password, etc.
// ...

// Set RTSP LowLatency mode.
settings.Type = IPSourceEngine.RTSP_LowLatency;

// Set UDP or TCP mode.
settings.RTSP_LowLatency_UseUDP = false; // true to use UDP, false to use TCP

// Set source to the VideoCaptureCore object.
VideoCapture1.IP_Camera_Source = settings;

Low latency mode (~150ms)

VideoCaptureCoreX includes a low-latency mode that cuts the RTSP jitter buffer from the default 500ms to 150ms. Set Latency to 150ms or less for an even smaller buffer. Use it for real-time surveillance, interactive monitoring, and security applications.

// Create RTSP source settings
var rtsp = await RTSPSourceSettings.CreateAsync(
    new Uri("rtsp://192.168.1.100:554/stream"), 
    "admin", 
    "password", 
    true); // enable audio

// Enable low latency mode - 150ms jitter buffer (default is 500ms)
rtsp.LowLatencyMode = true;

// Set source to VideoCaptureCoreX
VideoCapture1.Video_Source = rtsp;

How It Works: - Sets RTSP jitter buffer to 150ms (vs. default 500ms) - Optimizes internal queue buffering (2 frames max) - Disables packet reordering for minimal delay - Trade-off: Optimizes speed over stability

When to Use: - ✓ Real-time surveillance and monitoring - ✓ Live security systems - ✓ Interactive video applications - ✓ Remote control systems - ✗ Recording on unstable networks (use default) - ✗ Long-term archival capture (use default)

Advanced Configuration:

For fine-tuned control, you can manually configure latency parameters:

var rtsp = await RTSPSourceSettings.CreateAsync(uri, login, password, audioEnabled);

// Manual low latency configuration
rtsp.Latency = TimeSpan.FromMilliseconds(50);  // Custom buffer size
rtsp.BufferMode = RTSPBufferMode.None;          // No jitter buffering
rtsp.DropOnLatency = false;                     // Don't drop frames

Implementation Examples and Reference Applications

These sample projects demonstrate practical RTSP implementation patterns and can serve as starting points for your own development. Reviewing these examples will help you understand best practices for RTSP integration.

Troubleshooting RTSP Connections

When working with RTSP cameras, you may encounter connectivity issues related to network configuration, firewall settings, or authentication. Here are key factors to consider:

  • Verify network connectivity between your application and the camera
  • Ensure correct authentication credentials are provided
  • Check if firewalls are blocking required ports (typically 554 for RTSP)
  • Consider using TCP instead of UDP if experiencing packet loss
  • Test camera streams with VLC or similar tools to isolate application-specific issues
  • If VLC plays the stream but preview freezes or ends after about a minute, force TCP and, if that is not enough, send GET_PARAMETER keep-alives:

    rtsp.AllowedProtocols = RTSPSourceProtocol.TCP;
    rtsp.ForceCustomKeepAlive = true;
    

    ForceCustomKeepAlive is off by default. The RTSP Preview demo exposes both knobs (Auto / TCP / UDP, plus a Force custom keep-alive checkbox).

Need the RTSP URL for your camera? Browse our IP camera brands directory for brand-specific RTSP URLs and connection examples.