gst_segment_to_running_time call on new_sample_jpeg callback

Dwight Kulkarni dwight at realtime-7.com
Wed Dec 8 18:54:08 UTC 2021


Hi all,

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.

I have three functions below:

//this is the call back from splitmuxsink to set the video file name
*format_location_callback(..) *{

//at the end of this call back where we save the video, I will reset the
GstSegment
if(currsegment != NULL) { gst_segment_free(currsegment); }   //destroy the
old segment
currsegment = gst_segment_new(); //get a new segment
gst_segment_init(currsegment, GST_FORMAT_TIME); //I tell the segment to use
time format
gst_segment_set_running_time(currsegment, GST_FORMAT_TIME, 0);  //I set the
time to 0 for the current segment
}

//this is the call back function when a new-sample frame arrives
*new_sample_jpeg(..)*{


guint64 pos;
*gst_element_query_position(gstreamer_main_video_pipeline, GST_FORMAT_TIME,
&pos); *//I query my position in the pipeline
*guint64 curr_time = gst_segment_to_running_time(currsegment,
GST_FORMAT_TIME, pos);*

}

//this is the function where I setup the gstreamer pipeline, callbacks, and
start the pipeline
*init_gstreamer_pipeline(..)*{

currsegment = gst_segment_new(); //I setup a new segment
gst_segment_init(currsegment, GST_FORMAT_TIME); //I tell the segment to use
time format
gst_segment_set_running_time(currsegment, GST_FORMAT_TIME, 0);  //I set the
time to 0 for the current segment
//I start the gstreamer pipeline after this code block ^^^

}


*Question 1:*

gst_element_query_position(gstreamer_main_video_pipeline, GST_FORMAT_TIME,
&pos);

Will this give me the global time in the pipeline ?  I was the position
since the last splitmuxsink save occurred


*Question 2:*

guint64 curr_time = gst_segment_to_running_time(currsegment,
GST_FORMAT_TIME, pos);

How do I interpret curr_time ?   Is this is nanoseconds ?  The docs don't
seem to say.


Thank you all in advance. Best regards.

On Tue, Dec 7, 2021 at 3:01 PM Dwight Kulkarni <dwight at realtime-7.com>
wrote:

> 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
> function.
>
> 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
> format
>
> 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.
>
> --
> Sincerely,
>
> Dwight Kulkarni
>
>

-- 
Sincerely,

Dwight Kulkarni
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20211208/04de4ef2/attachment.htm>


More information about the gstreamer-devel mailing list