Skip to main content

IP cameras

Products: Video Capture SDK .Net

SDK supports IP cameras as a source. You can use the following types of IP cameras:

Using IP cameras as a source

// set source
VideoCapture1.IP_Camera_Source = new IPCameraSourceSettings
{
URL = "url",
Login = "login",
Password = "password",
settings.AudioCapture = true, // true to capture audio, false to ignore audio
Type = VFIPSource.Auto_VLC
};

The type of the source can be set to:

  • Auto_VLC - use the VLC engine
  • Auto_FFMPEG - use the FFMPEG engine
  • Auto_LAV - use the LAV engine
  • MMS_WMV - use the Windows Media Video engine
  • RTSP_LowLatency - use the RTSP engine with low latency mode
  • NDI - use the NDI engine

Low-latency RTSP source

SDK has a special mode for low-latency RTSP streaming. Usually, the latency is less than 250 ms.

// set source
var settings = new IPCameraSourceSettings
// ...
settings.Type = IPSourceEngine.RTSP_LowLatency;
settings.RTSP_LowLatency_UseUDP = false; // true to use UDP, false to use TCP

VideoCapture1.IP_Camera_Source = settings;

Low-latency MJPEG source

SDK has a special mode for low-latency MJPEG streaming. Usually, the latency is less than 100 ms.

// set source
var settings = new IPCameraSourceSettings
// ...
settings.Type = IPSourceEngine.HTTP_MJPEG_LowLatency;

VideoCapture1.IP_Camera_Source = settings;

FFMPEG source

Using the FFMPEG source, you can set custom parameters using the FFMPEG_CustomOptions property. The avformat_open_input call will use these parameters in the dictionary when opening a stream.

The sample below shows how to set the rtsp_transport and timeout parameters.

VideoCapture1.IP_Camera_Source.FFMPEG_CustomOptions.Add("rtsp_transport", "tcp");
VideoCapture1.IP_Camera_Source.FFMPEG_CustomOptions.Add("timeout", "3000000");

Network disconnect event

SDK can detect network disconnects and reconnects. To enable this feature, set DisconnectEventInterval to 5 seconds or more.

Use the OnNetworkSourceDisconnect event to handle disconnects.

private void VideoCapture1_OnNetworkSourceDisconnect(object sender, EventArgs e)
{
Invoke((Action)(
async () =>
{
await VideoCapture1.StopAsync();

MessageBox.Show(this, "Network source stopped or disconnected!");
}));
}

Visit our GitHub page to get more code samples.