Gstreamer-1.0 Mp4 video RTSP streaming - appsrc

Shaf shaf.nttf at gmail.com
Mon Mar 18 06:48:03 UTC 2019


Hi Stephen,

I am trying change the file source from the below pipeline when the
currently running pipeline come to EOS.


****** Pipeline ************

GstElement *playbin = gst_parse_launch(
		"filesrc name=media_source ! "
		"qtdemux name=mdemux ! h264parse ! video/x-h264,stream-format=byte-stream
! "
		"appsink name=video_sink  emit-signals=FALSE sync=TRUE drop=TRUE
num-buffers=2000 ", &error);

if (!playbin) {
	g_print("Parse error: %s\n", error->message);
	exit(1);
}

filesrc = gst_bin_get_by_name(GST_BIN(playbin), "media_source");
g_object_set(filesrc, "location", argv[0], NULL);
g_object_unref(filesrc);

***************** bus callback  -- seeking to beginning of file is working 

gboolean bus_callback(GstBus *bus, GstMessage *msg, gpointer data) {
	GstElement *pipeline = GST_ELEMENT(data);
	switch (GST_MESSAGE_TYPE(msg)) {
	case GST_MESSAGE_EOS:
		if (!gst_element_seek(pipeline,
			1.0, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH,
			GST_SEEK_TYPE_SET, 1000000000,
			GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE)) {
			g_message("Seek failed!");
		}
		break;
	default:
		break;
	}
	return TRUE;
}


******but changing the file source in bus call back is not working. The
video gets stuck after playing once.

Here is how the file source is changed in bus call-back.

gboolean bus_callback(GstBus *bus, GstMessage *msg, gpointer data)
{
	App *pipeline_data = (App*)data;

	GstElement *pipeline = GST_ELEMENT(pipeline_data->playbin);
	switch (GST_MESSAGE_TYPE(msg)) {
	case GST_MESSAGE_EOS:		
		gst_element_set_state(pipeline, GST_STATE_NULL);
		// get the filesrc bin using name "media_source"
     g_object_set(gst_bin_get_by_name(GST_BIN(pipeline), "media_source"),
"location", "C:\\Videos\\test.mp4", NULL);	

        // set the pipeline to playing		
		gst_element_set_state(pipeline, GST_STATE_PLAYING);
		break;
	default:
		break;
	}
	return TRUE;
}

(The pipeline STATE is displayed as ASYNC while printing the STATE)

Is this possible ? 

Note :
I was able to change the video source using the below pipeline (But I need
to use Qtdemuxer, as above pipeline)

	// Playbin, setup and configuration
	GstElement *playbin = gst_element_factory_make("playbin", "play");

	app->videosink = gst_element_factory_make("appsink", "video_sink");
	g_object_set(G_OBJECT(app->videosink), "emit-signals", FALSE, "sync", TRUE,
NULL);
	g_object_set(G_OBJECT(playbin), "video-sink", app->videosink, NULL);
	gst_app_sink_set_drop(GST_APP_SINK(app->videosink), TRUE);
	gst_app_sink_set_max_buffers(GST_APP_SINK(app->videosink), 1);
	bus = gst_pipeline_get_bus(GST_PIPELINE(playbin));
	gst_bus_add_watch(bus, bus_callbackz, playbin);
	g_object_set(G_OBJECT(playbin), "uri", mp4_file_src, NULL);
	gst_element_set_state(playbin, GST_STATE_PLAYING);




--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/


More information about the gstreamer-devel mailing list