AW: AW: AW: AW: Video break when using with splitmuxsink
Thornton, Keith
keith.thornton at zeiss.com
Tue Sep 1 06:02:48 UTC 2020
Hi,
why not replace all these
gst_element_send_event(source, gst_event_new_eos()); ...
with
gst_element_send_event(pipeline, gst_event_new_eos());
Then add a message handler along the lines of
GstBusSyncReply GstreamerCamera:: BusFunc(GstBus* bus, GstMessage* message, gpointer user_data)
{
(void)bus;
GstBusSyncReply busReply = GST_BUS_PASS;
switch (GST_MESSAGE_TYPE(message))
{
case GST_MESSAGE_EOS:
{
pRecorder->setEosReceived();
}
break;
}
They you must wait for EOS. Use a condition variable or promise and future or sum such event before setting the pipeline state.
-----Ursprüngliche Nachricht-----
Von: gstreamer-devel <gstreamer-devel-bounces at lists.freedesktop.org> Im Auftrag von ToanVnET
Gesendet: Dienstag, 1. September 2020 06:07
An: gstreamer-devel at lists.freedesktop.org
Betreff: Re: AW: AW: AW: Video break when using with splitmuxsink
Hi,
This is my code simple version:
static gchar* cb_FormatLocation(GstElement* splitmuxsink, guint fragment_id, const int* offset){
//Set filename
return filename;
}
gboolean timeout_callback(gpointer data){
if ( //meet signal stop video ){
g_main_loop_quit((GMainLoop*)data);
return FALSE;
}
return TRUE;
}
int main(int argc, char * argv[]){
GstElement *pipeline, *source, *frameratefilter_, *h264parse, *encoder, *splitmuxsink;
/* Initialize GStreamer */
gst_init (&argc, &argv);
loop = g_main_loop_new ( NULL , FALSE );
/* Create the empty pipeline */
pipeline = gst_pipeline_new ("test-pipeline");
/* Create the elements */
source = gst_element_factory_make ("imxv4l2src", NULL);
h264parse = gst_element_factory_make("h264parse",NULL);
encoder = gst_element_factory_make("vpuenc_h264",NULL);
frameratefilter = gst_element_factory_make("capsfilter", NULL);
splitmuxsink = gst_element_factory_make("splitmuxsink", NULL);
// Set parameters for some elements
g_object_set(G_OBJECT(source), "device", "/dev/video0", NULL);
g_object_set(G_OBJECT(splitmuxsink), "location", filename, NULL);
g_object_set(G_OBJECT(splitmuxsink), "max-size-time", nanoDuration, NULL);
g_object_set(G_OBJECT(splitmuxsink), "async-handling", 1, NULL);
g_signal_connect (G_OBJECT(splitmuxsink), "format-location", G_CALLBACK(cb_FormatLocation), &offset);
g_object_set(G_OBJECT(frameratefilter_write), "caps", gst_caps_from_string("video/x-raw,format=
(string)NV12,width=640,height=480,framerate=(fraction)30/1"), NULL);
/* Build the pipeline */
gst_bin_add_many (GST_BIN (pipeline), source, overlay, frameratefilter, encoder, h264parse, splitmuxsink, NULL);
if ( gst_element_link_many(source, overlay, frameratefilter, encoder, h264parse, splitmuxsink, NULL) != TRUE ){
g_error("Failed to link save elements!");
gst_object_unref (pipeline);
return -1;
}
/* Start playing */
ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
if (ret == GST_STATE_CHANGE_FAILURE) {
g_printerr ("Unable to set the pipeline to the playing state.\n");
gst_object_unref (pipeline);
return -1;
}
g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, 1 , timeout_callback , loop, NULL);
g_main_loop_run (loop);
g_main_loop_unref(loop);
bus = gst_element_get_bus (pipeline);
gst_element_send_event(source, gst_event_new_eos());
gst_element_send_event(tee, gst_event_new_eos());
gst_element_send_event(queue_write, gst_event_new_eos());
gst_element_set_state (splitmuxsink, GST_STATE_PAUSED);
gst_element_set_state (splitmuxsink, GST_STATE_READY);
gst_element_set_state (splitmuxsink, GST_STATE_NULL);
gst_element_send_event(splitmuxsink, gst_event_new_eos());
gst_element_send_event(frameratefilter, gst_event_new_eos());
gst_element_send_event(encoder, gst_event_new_eos());
gst_element_send_event(h264parse, gst_event_new_eos());
gst_element_send_event(pipeline, gst_event_new_eos());
gst_object_unref (bus);
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (pipeline);
return 0;
}
--
Sent from: https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgstreamer-devel.966125.n4.nabble.com%2F&data=02%7C01%7C%7C2721801169704c30c8df08d84e361e82%7C28042244bb514cd680347776fa3703e8%7C1%7C0%7C637345341626441390&sdata=aaAA9bWel4KzwX%2FiaoygpFDWzdVCuyuRpG03werSB2o%3D&reserved=0
_______________________________________________
gstreamer-devel mailing list
gstreamer-devel at lists.freedesktop.org
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Fgstreamer-devel&data=02%7C01%7C%7C2721801169704c30c8df08d84e361e82%7C28042244bb514cd680347776fa3703e8%7C1%7C0%7C637345341626441390&sdata=kPnKPmx3TRuZMzKsSL0AobqnrHxx7CP%2B5rOXYCt2QxE%3D&reserved=0
More information about the gstreamer-devel
mailing list