# Timeshift plugin

**URL:** <https://discourse.gstreamer.org/t/timeshift-plugin/4928>\
**Category:** Plugin and library development\
**Created:** [August 1, 2025, 12:26pm UTC](https://discourse.gstreamer.org/t/timeshift-plugin/4928 "2025-08-01T12:26:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![acrilique](https://discourse.gstreamer.org/user_avatar/discourse.gstreamer.org/acrilique/32/583_2.png) [@acrilique](https://discourse.gstreamer.org/u/acrilique)\
**Post date:** [August 1, 2025, 12:26pm UTC](https://discourse.gstreamer.org/t/timeshift-plugin/4928/1 "2025-08-01T12:26:07Z")

</div>

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](https://github.com/IIMrd/gst-timeshift).

Thanks in advance

---

<div class="post-metadata">

**Author:** ![ocrete](https://discourse.gstreamer.org/user_avatar/discourse.gstreamer.org/ocrete/32/33_2.png) [@ocrete](https://discourse.gstreamer.org/u/ocrete)\
**Post date:** [August 1, 2025, 3:51pm UTC](https://discourse.gstreamer.org/t/timeshift-plugin/4928/2 "2025-08-01T15:51:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![acrilique](https://discourse.gstreamer.org/user_avatar/discourse.gstreamer.org/acrilique/32/583_2.png) [@acrilique](https://discourse.gstreamer.org/u/acrilique)\
**Post date:** [August 2, 2025, 11:09am UTC](https://discourse.gstreamer.org/t/timeshift-plugin/4928/3 "2025-08-02T11:09:33Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![acrilique](https://discourse.gstreamer.org/user_avatar/discourse.gstreamer.org/acrilique/32/583_2.png) [@acrilique](https://discourse.gstreamer.org/u/acrilique)\
**Post date:** [September 1, 2025, 11:18am UTC](https://discourse.gstreamer.org/t/timeshift-plugin/4928/4 "2025-09-01T11:18:14Z")

</div>

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)?
