Preview and recording of IP cameras and URL sources
Preview and recording of IP cameras and URL sources
Description
Preview and recording of IP cameras and URL sources
Note: with IP cameras supporting the ONVIF protocol no need to know RTSP URL syntax anymore, you can open the RTSP URL by specifying the onvif:// protocol following by the IP address or domain name and port
Preview only:
VideoGrabber.VideoSource = vs_IPCamera
VideoGrabber.OpenURLAsync = true; // default, so the connection does not block the main thread
VideoGrabber.IPCameraURL = "onvif://192.168.0.25:80" // if the port is not specified the default port 80 is used
VideoGrabber.SetAuthentication (at_IPCamera, "root", "admin")
VideoGrabber.AudioDeviceRendering = true // optional, if audio rendering is needed
VideoGrabber.FrameGrabber = fg_Disabled // if no overlay or frame capture is required, saves CPU
VideoGrabber.StartPreview()
Preview and recording:
VideoGrabber.VideoSource = vs_IPCamera
VideoGrabber.OpenURLAsync = true; // default, so the connection does not block the main thread
VideoGrabber.IPCameraURL = "onvif://192.168.0.25:80" // if the port is not specified the default port 80 is used
VideoGrabber.SetAuthentication (at_IPCamera, "root", "admin")
VideoGrabber.FrameGrabber = fg_Disabled // if no overlay or frame capture is required, saves CPU
VideoGrabber.RecordingInNativeFormat = true
VideoGrabber.RecordingMethod = rm_MP4
VideoGrabber.AudioRecording = true // optional, if the URL has audio and audio recording is needed
VideoGrabber.StartRecording()
Recording only (no decoding, saves CPU):
VideoGrabber.VideoSource = vs_IPCamera
VideoGrabber.OpenURLAsync = true; // default, so the connection does not block the main thread
VideoGrabber.IPCameraURL = "onvif://192.168.0.25:80" // if the port is not specified the default port 80 is used
VideoGrabber.SetAuthentication (at_IPCamera, "root", "admin")
VideoGrabber.RecordingInNativeFormat = true
VideoGrabber.RecordingMethod = rm_MP4
VideoGrabber.FrameGrabber = fg_Disabled
VideoGrabber.VideoRenderer = vr_None
VideoGrabber.StartRecording()
To close the current file and start recording to a new file while the recording is running, invoke RecordToNewFileNow, this will generate a new file on the fly without loosing frames.
Alternatively it is possible to enable the RecordingTimer to periodically close the current file and generate a new file.
In this case the file name is generated automatically, however the file names can be renamed on the fly from the OnRecordingCompleted event.
RTSP, RTMP, HTTP, UDP, MMS, RTP sources and other streaming protocols
The sample code is the same, e.g.:
IPCameraURL = "rtsp://192.168.5.25/axis-media/media.amp?videocodec=h264&audio=1"
IPCameraURL = "udp://192.168.0.25"
IPCameraURL = "mmsh://192.168.0.25"
IPCameraURL = "rtmp://192.168.0.25/live"
IPCameraURL = "rtp://192.168.0.25"
IPCameraURL = "http://192.168.0.25/url"
etc...