Using from TVideoGrabber
To use the filter with the Datastead TVideoGrabber SDK you can ignore the DirectShow chapters of this documentation: you just need to install the filter (or simply copy its binaries under the application folder), then use the sample code below.
How the filter is configured from TVideoGrabber
When used in TVideoGrabber, the configuration of the RTSP filter is done by TVideoGrabber itself: the filter's configuration interface (IDatasteadRtspSourceConfig) is not used directly. However it is possible to control most of the specific filter parameters by adding and combining them at the end of the URL, prefixed by a > (or !) character, e.g.:
VideoGrabber.IPCameraURL = "rtsp://192.168.5.1/live.sdp>buffer=0>autoreconnect=0"
The parameters that can be passed this way are the ones listed with a "url param" name in the Parameter identifiers section (see also Configuration through URL parameters).
Note: the TVideoGrabber SDK starts by default the RTSP filter asynchronously, so invoking StartPreview() or StartRecording() returns true if the URL syntax is correct and exits immediately without waiting for the connection to complete. A notification occurs later when the preview or recording starts, through the OnPreviewStarted or OnRecordingStarted events (a connection that fails is reported by the OnLog event).
To make the connection synchronous and wait when invoking StartPreview, disable the VideoGrabber.OpenURLAsync property.
Preview of an ONVIF camera
VideoGrabber.VideoSource = vs_IPCamera
VideoGrabber.IPCameraURL = "onvif://192.168.0.25"
VideoGrabber.SetAuthentication (at_IPCamera, "onvifuser", "onvifpassword");
VideoGrabber.StartPreview()
Sending a PTZ "Pan" continuous move command to an ONVIF camera
Assuming the camera is previewing (sample code above):
VideoGrabber.ONVIFPTZStartMove ("Pan", true, 0.5, 300)
Recording of an ONVIF camera, without preview (saves CPU)
VideoGrabber.VideoSource = vs_IPCamera
VideoGrabber.IPCameraURL = "onvif://192.168.0.25"
VideoGrabber.SetAuthentication (at_IPCamera, "onvifuser", "onvifpassword");
VideoGrabber.VideoRenderer = vr_None;
VideoGrabber.FrameGrabber = fg_Disabled;
VideoGrabber.RecordingMethod = rm_MP4;
VideoGrabber.StartRecording()
Preview of a RTSP URL
VideoGrabber.VideoSource = vs_IPCamera
VideoGrabber.IPCameraURL = "rtsp://192.168.0.25/axis-media/media.amp?videocodec=h264"
VideoGrabber.SetAuthentication (at_IPCamera, "root", "admin");
VideoGrabber.StartPreview()
Preview + audio rendering
VideoGrabber.VideoSource = vs_IPCamera
VideoGrabber.IPCameraURL = "rtsp://192.168.0.25/axis-media/media.amp?videocodec=h264&audio=1"
VideoGrabber.SetAuthentication (at_IPCamera, "root", "admin");
VideoGrabber.AudioDeviceRendering = true
VideoGrabber.StartPreview()
Preview + MP4 recording (video only)
VideoGrabber.VideoSource = vs_IPCamera
VideoGrabber.IPCameraURL = "rtsp://192.168.0.25/axis-media/media.amp?videocodec=h264"
VideoGrabber.SetAuthentication (at_IPCamera, "root", "admin");
VideoGrabber.RecordingMethod = rm_MP4
VideoGrabber.RecordingFileName = "c:\thefolder\thefilename.MP4"
VideoGrabber.StartRecording()
Preview + audio rendering + MP4 audio/video recording
VideoGrabber.VideoSource = vs_IPCamera
VideoGrabber.IPCameraURL = "rtsp://192.168.0.25/axis-media/media.amp?videocodec=h264&audio=1"
VideoGrabber.SetAuthentication (at_IPCamera, "root", "admin");
VideoGrabber.AudioDeviceRendering = true
VideoGrabber.RecordingMethod = rm_MP4
VideoGrabber.AudioRecording = true
VideoGrabber.RecordingFileName = "c:\thefolder\thefilename.MP4"
VideoGrabber.StartRecording()
Recording in native format (without transcoding)
With IP cameras it is usually preferable to record the native frames received (H264, H265/HEVC, AAC...) without recompression:
VideoGrabber.VideoSource = vs_IPCamera
VideoGrabber.IPCameraURL = "onvif://192.168.5.1>buffer=0>autoreconnect=0"
VideoGrabber.SetAuthentication (at_IPCamera, "user", "password");
VideoGrabber.RecordingInNativeFormat = true
VideoGrabber.RecordingMethod = rm_MP4
VideoGrabber.StartRecording ();
Generating a new file name on the fly
(we suppose the recording is currently running)
VideoGrabber.RecordToNewFileNow("c:\thefolder\thenewfilename.mp4", true)
To let TVideoGrabber generate the file names automatically pass an empty string as file name.
To pause the recording, pass a "nul" file name with the same extension and without file path, e.g.:
VideoGrabber.RecordToNewFileNow("nul.mp4", true)
Switching filter settings on the fly
Some filter settings can be changed while the graph is running, e.g. to decode only the key frames to save CPU:
VideoGrabber.ONVIF_SetBool ("RTSP_VideoStream_Decode_KeyFrames_Only_bool", true)
Sending audio to the camera backchannel
See Sending audio to the camera backchannel from TVideoGrabber.