<div dir="ltr"><div dir="ltr">Hi all,<br></div><div dir="ltr"><br></div><div>I think I have found the right approach but would appreciate if some Gstreamer Guru can confirm if this is correct and clarify my two questions.</div><div><br></div><div>I have three functions below:</div><div><br></div><div>//this is the call back from splitmuxsink to set the video file name</div><div><b>format_location_callback(..) </b>{</div><div><br></div><div>//at the end of this call back where we save the video, I will reset the GstSegment</div><div>if(currsegment != NULL) { gst_segment_free(currsegment); }   //destroy the old segment<br></div><div>currsegment = gst_segment_new(); //get a new segment  <br></div><div><div>gst_segment_init(currsegment, GST_FORMAT_TIME); //I tell the segment to use time format<br></div><div>gst_segment_set_running_time(currsegment, GST_FORMAT_TIME, 0);  //I set the time to 0 for the current segment</div></div><div>}</div><div><br></div><div>//this is the call back function when a new-sample frame arrives</div><div><b>new_sample_jpeg(..)</b>{</div><div><br></div><div><br></div><div>guint64 pos;</div><div><b>gst_element_query_position(gstreamer_main_video_pipeline, GST_FORMAT_TIME, &pos); </b>//I query my position in the pipeline</div><div><b>guint64 curr_time = gst_segment_to_running_time(currsegment, GST_FORMAT_TIME, pos);</b><br></div><div><br></div><div>}</div><div><br></div><div>//this is the function where I setup the gstreamer pipeline, callbacks, and start the pipeline</div><div><b>init_gstreamer_pipeline(..)</b>{</div><div><br></div><div>currsegment = gst_segment_new(); //I setup a new segment    <br></div><div>gst_segment_init(currsegment, GST_FORMAT_TIME); //I tell the segment to use time format<br></div><div>gst_segment_set_running_time(currsegment, GST_FORMAT_TIME, 0);  //I set the time to 0 for the current segment<br></div><div>//I start the gstreamer pipeline after this code block ^^^</div><div><br></div><div>}</div><div><br></div><div><br></div><div><b>Question 1:</b></div><div><br></div><div>gst_element_query_position(gstreamer_main_video_pipeline, GST_FORMAT_TIME, &pos);<br></div><div><br></div><div>Will this give me the global time in the pipeline ?  I was the position since the last splitmuxsink save occurred </div><div><br></div><div><br></div><div><b>Question 2:</b></div><div><br></div><div>guint64 curr_time = gst_segment_to_running_time(currsegment, GST_FORMAT_TIME, pos);<br></div><div><br></div><div>How do I interpret curr_time ?   Is this is nanoseconds ?  The docs don't seem to say.</div><div><br></div><div><br></div><div>Thank you all in advance. Best regards.</div><div><br></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Dec 7, 2021 at 3:01 PM Dwight Kulkarni <<a href="mailto:dwight@realtime-7.com">dwight@realtime-7.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hello everyone,<div><br></div><div>I have a pipeline which is making a <b>new-sample</b> callback, that is to say when a frame arrives this function is invoked:</div><div><br></div><div>static GstFlowReturn new_sample_jpeg(GstElement *sink, MainContext *ctx)</div><div><br></div><div>I have a pipeline which every few seconds will use splitmuxsink to save the video. For this I have a <b>format-location</b> callback with function signature:</div><div><br></div><div>static gchararray format_location_callback(GstElement* splitmux, guint fragment_id, gpointer udata)</div><div><br></div><div><br></div><div>When this jpeg arrives, I need to know the exact place it is in that current video in splitmuxsink.</div><div><br></div><div>@Nicolas Dufresne has very kindly pointed me to the gst_segment_to_running_time(..) function or has recommended a custom time function.</div><div><br></div><div>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)</div><div>ii) Then I reinit the GstSegment when the file is saved by splitmuxsink in format</div><div><br></div><div>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.</div><div><br></div><div>Can it be obtained from GstElement or MainContext  ?</div><div><br></div><div>Thank you all. Best regards.</div><div><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><span style="font-size:12.8px">Sincerely,</span><div><br></div><div>Dwight Kulkarni                </div><div><br></div></div></div></div></div></div></div></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><span style="font-size:12.8px">Sincerely,</span><div><br></div><div>Dwight Kulkarni  </div></div></div></div></div></div></div></div>