Il'ya Zhenin
Il'ya Zhenin

Reputation: 1332

How to get camera timestamp for received frame?

I have gstreamer pipeline that accepts input from RTSP stream, converts it and sinks it into appsink:

data.source = gst_element_factory_make("uridecodebin", "source");
data.convert = gst_element_factory_make("videoconvert", "conv");
data.app_sink = gst_element_factory_make("appsink", "app_sink");

I learnt how to extract media buffer into my app, but the thing Im wondering is timestamping it. The media comes with what I think camera hardware pre-rendered clock in bottom left corner, is there a way for me to get that time? I looked over RTP header and it supposed to have Timestamp info in it. I looked over Gstreamer info and tutorials and buffer description which has pts and dts timestamps but I dont think that it is what I need, it sounds like local machine time.

To summarize question, how to extract camera timestamp from RTSP stream?

Upvotes: 2

Views: 2473

Answers (1)

Yağız Yaşar
Yağız Yaşar

Reputation: 71

You can retrieve RTP timestamps for each frame doing some work with PTS variable. For example if your camera is 25 FPS, you should multiply PTS by 9/1000000 to get the RTP timestamp. This is not what you want but it is handy.

In order to see the actual timestamp, you would like to use RTCPBuffer and retrieve each RTCPPacket, which is the Real-time Transport Control Protocol Packets including NTP and RTP timestamps, in buffer to see these timestamps using gst_rtcp_packet_sr_get_sender_info(...) method. Then, you would synchronize NTP and RTP timestamps each time you receive a new RTCP packet.

You would have to do a calculation to find what the RTP timestamp intervals correspond in NTP time to do this synchronization.

Upvotes: 7

Related Questions