AW: AW: AW: Video break when using with splitmuxsink
ToanVnET
toanrd.vnet at gmail.com
Tue Sep 1 04:06:44 UTC 2020
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: http://gstreamer-devel.966125.n4.nabble.com/
More information about the gstreamer-devel
mailing list