Timeshift plugin

I’ve developed a gstreamer plugin with 2 elements that provide timeshift functionality: timeshiftsink and timeshiftsrc. The former creates a ring buffer and the latter is able to access it if a pointer to the timeshiftsink element is given in the “sink” property.

To use them, you must split your pipeline in two:

  • A live pipeline which ends in the timeshiftsink element
  • Another pipeline whose source is the timeshiftsrc element

Remember to set the “sink” property of timeshiftsrc to a GstElement* to the timeshiftsink, to connect both elements.

When used correctly, this setup allows seeking freely within the ring-buffer.

Here’s an example pipeline pair which I have tested successfully:

  • dvbsrc ! queue ! tsparse set-timestamps=true ! timeshiftsink (this also works if I swap dvbsrc ! queue with udpsrc ! rtpjitterbuffer ! rtpmp2tdepay)
  • timeshiftsrc ! decodebin name=decoder decoder. ! videoconvert ! autovideosink decoder. ! audioconvert ! autovideosink

To my understanding, the “set-timestamps” property of tsparse here is key. GstBuffers that go into the ring buffer already have timestamps representing the time when they were received. This information is then used by timeshiftsrc to enable playing and seeking.

I want to get feedback/criticism on these elements so I got authorized by my employer to make them public. I would be very glad to receive comments, either here or in the issues page of the GitHub repository.

Thanks in advance

Hi,

This is something that has been missing for a long time. Do you want to submit it as a MR to GStreamer itself?

Having built a few systems like those in the past, the hairy difficulties come when you want to timeshift encoded video, where you need to seek to a keyframe in the buffer. And then it becomes hairy when you have both encded video and audio and you want to seek to both together. But I think your code is clean and can be a good base to add future features.

Olivier

@ocrete thanks a lot for taking a look. I like the idea of merging this into gstreamer. Probably won’t do the merge request until late August/early September because everyone in my departament is on holiday starting today.
Until then, any feature suggestions/issues can be submitted here as a comment or in the GitHub page.

Hello, after talking with my supervisor I got authorized to present the timeshift plugin as a MR to GStreamer. I’ve added some more info in the copyright/license headers that was requested by them. How should I exactly proceed with the MR?
My current assumption is that this should go to the monorepo, inside subprojects/gst-plugins-bad/gst; so should I present a MR with a new subfolder called timeshift (with the contents of the github repo above)?