gst_segment_to_running_time call on new_sample_jpeg callback

Dwight Kulkarni dwight at
Tue Dec 7 20:01:19 UTC 2021

Hello everyone,

I have a pipeline which is making a *new-sample* callback, that is to say
when a frame arrives this function is invoked:

static GstFlowReturn new_sample_jpeg(GstElement *sink, MainContext *ctx)

I have a pipeline which every few seconds will use splitmuxsink to save the
video. For this I have a *format-location* callback with function signature:

static gchararray format_location_callback(GstElement* splitmux, guint
fragment_id, gpointer udata)

When this jpeg arrives, I need to know the exact place it is in that
current video in splitmuxsink.

@Nicolas Dufresne has very kindly pointed me to the
gst_segment_to_running_time(..) function or has recommended a custom time

i) Based on my understanding, I have to get a GstSegment and init it with
gst_segment_init  at the start of the current video (either in
format-location or new-sample)
ii) Then I reinit the GstSegment when the file is saved by splitmuxsink in

If this is correct, my next question is how do I get the GstSegment object
? Currently, the code samples I am seeing show the GstSegment as an input
into the function already.

Can it be obtained from GstElement or MainContext  ?

Thank you all. Best regards.


Dwight Kulkarni
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the gstreamer-devel mailing list