Timestamp buffers with times in the past?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Timestamp buffers with times in the past?

Lawrence Troup
I have a Gstreamer video source element, which is mostly live - i.e. reading video frames from a camera, and outputting them on the Gstreamer pipeline. So normally, it uses the Gstreamer pipeline-clock, and just starts with the first frame at time 0, second 33ms later etc.

However, in a certain setup, when the Gstreamer pipeline stops, there are already some video frames cached in memory (with timestamps in the past), which need sending out on the Gstreamer pipeline, before it continues as normal sending video frames live from its start time. The frames in the past should be sent out instantaneously (i.e. shouldn't hold up sending out the live frames); and all frames should be timestamped correctly - e.g. with 33ms between each frame.

The issue I'm encountering is that the DTS/PTS timestamps are GstClockTime which is unsigned - so I can't use negative timestamps to represent times in the past.

What is the correct way to handle this? Should I be using a different clock from the pipeline clock, i.e. one for which 'zero' is a long time in the past? Do I need to create my own GstClock instance to do this? Or are there standard approaches for achieving?

Thanks,
Lawrence
Reply | Threaded
Open this post in threaded view
|

Re: Timestamp buffers with times in the past?

mariannasb
I think the only way to do it is to add an offset to the timestamps.

x264enc fx does this, it offsets all timestamps by 1000hours, in order to allow for negative DTS and "corrects" it by sending a proper segment (which removes the offset).