elsampsa / valkka-core

Valkka - Create video surveillance, management and analysis programs with PyQt
GNU Lesser General Public License v3.0
181 stars 35 forks source link

Extracting NTP timestamp from rtsp #27

Closed nik13 closed 2 years ago

nik13 commented 2 years ago

While using RTSP for playback from an onvif device, the playback does not play accurately.

From this manual: https://www.onvif.org/specs/stream/ONVIF-Streaming-Spec.pdf

In order to allow clients to report a stable and accurate timestamp for each frame played back regardless of the direction of playback, it is necessary to associate an absolute timestamp with each packet, or each group of packets with the same RTP timestamp (e.g. a video frame). This is achieved using an RTP header extension containing an NTP timestamp.

I followed this: https://stackoverflow.com/questions/28022432/receiving-rtp-packets-after-rtsp-setup , but no success.

How can I decode the headers or fetch the NTP timestamp from the packets or frames?

elsampsa commented 2 years ago

https://elsampsa.github.io/valkka-examples/_build/html/lesson_4.html#client-side-opencv

There is meta.mstimestamp

nik13 commented 2 years ago

Hi @elsampsa , thanks for the replay.

What I'm looking for is the time when the feed was recording in an onvif device. If I'm not wrong, this timestamp is the presentation time to the user wrt to when the stream was played?

Correct me if I'm wrong.

elsampsa commented 2 years ago

What on earth is "time when the feed was recording in an onvif device" ? Something that some onvif device (camera? server?) has recorded internally?

There is no ready-made thing in libValkka to handle something that has been recorded on some onvif device.

We're just getting live streams from RTSP cameras here.

If you need to play with OnVif, please take a look at this

nik13 commented 2 years ago

By "time when the feed was recording in an onvif device" I mean the video playback options that are generally available in onvif devices. You can have a look here: https://www.onvif.org/specs/stream/ONVIF-Streaming-Spec.pdf in the playback section.

Thanks for the help anyway. I solved it by using plain socket requests.

And yes. Awesome library 👍