Skip to content

NTP time of IP cameras

The filter reports the NTP time of the video frames: the time of each frame on the clock of the camera, expressed in 100 ns units since 1970-01-01 (Unix epoch). It requires an RTSP source whose camera sends RTCP sender reports.

Reading the NTP time

NTP time of the last video frame delivered by the filter:

__int64 FrameNTPTime;
IDatasteadRTSPSourceConfig3->GetInt64 ("RTSP_VideoStream_Frame_NTP_time_100ns_int64", &FrameNTPTime);

NTP time of the first video frame written to the file currently being recorded:

__int64 FirstRecordedNTPTime;
HRESULT hr = IDatasteadRTSPSourceConfig3->GetInt64 ("RTSP_VideoStream_First_Frame_NTP_time_Recorded_100ns_int64", &FirstRecordedNTPTime);
  • the value is set again for each new file, RTSP_Action_RecordToNewFileNow included; GetInt64 returns E_NOT_SET until it is known,
  • when the first frame of the file has an NTP time, the value is already set when the EC_RTSP_PARAM1_RECORDTONEWFILE_STARTED notification is sent,
  • when the file starts before the first RTCP sender report, the value is set later, extrapolated back from the first frame that has an NTP time.

The NTP timestamp callback reports the NTP time of each video frame delivered.

Reception time or RTP timestamp

Mode NTP time of a frame What it includes
Reception time (default) time of reception of the frame, converted to the clock of the camera: NTP time of the last RTCP sender report + local time elapsed since that report the latency of the camera encoder and of the network, and the arrival jitter
RTP timestamp computed from the RTP timestamp of the frame and the RTCP sender reports of the camera (RFC 3550) the time stamped by the camera (RTP timestamp): no network latency, no arrival jitter

The RTP timestamp mode is enabled by RTSP_VideoStream_NTP_time_From_RTP_Timestamp_bool (default: disabled), set before opening the URL:

IDatasteadRTSPSourceConfig->SetBool ("RTSP_VideoStream_NTP_time_From_RTP_Timestamp_bool", true);

or by the ntpfromrtp URL parameter (see Configuration through URL parameters):

rtsp://user:pass@192.168.1.20:554/stream1>ntpfromrtp=1

See Parameter identifiers.

Sender reports and reconnections

  • in both modes, no NTP time is available before the first RTCP sender report of the camera: RTSP_VideoStream_Frame_NTP_time_100ns_int64 returns 0 and the callback is not invoked,
  • after a reconnection, the reception time is used until the next sender report, in both modes,
  • in the reception time mode, with a stream that contains B-frames, the NTP times of consecutive frames may not be in increasing order (decoding order of the packets); the RTP timestamp mode is not affected.

Clock of the camera

  • if an NTP server is configured on the camera, the values are the current Unix epoch time, comparable with the time of the PC when both are synchronized,
  • otherwise the values may start from an arbitrary time, but the difference between the NTP times of two frames remains valid.

From TVideoGrabber

With the TVideoGrabber SDK: GetFrameInfo (0, fi_NTPFrameTime), GetFrameInfo (0, fi_First_NTP_time_Recorded) and the OnNTPTimeStamp event; the RTP timestamp mode is enabled by appending >ntpfromrtp=1 to the URL (see Using from TVideoGrabber).