Unable to link rtspsrc and tee

shyam shyam.krishna at philips.com
Sun Nov 17 16:24:23 UTC 2019


Hi Nicolas,

              I am very new to Gstreamer. I am trying to learn using
examples available in the net. The use-case I want to implement requires
display of live video streaming via RTSP and recording simultaneously in
metroska (mkv) format.Any guidance in this will be of great help.I still
need to get familiar with Gstreamer.


I got this code from internet. This works fine with source being
videotestsrc, but doesnot work with rtspsrc.
int main(int argc, char *argv[])
{
	/*******************************/
	if (!gst_debug_is_active()) {
		gst_debug_set_active(TRUE);
		GstDebugLevel dbglevel = gst_debug_get_default_threshold();
		if (dbglevel < GST_LEVEL_ERROR) {
			dbglevel = GST_LEVEL_ERROR;
			gst_debug_set_default_threshold(dbglevel);
		}
	}
	/*********************************/
	//signal(SIGINT, sigintHandler);
	gst_init(&argc, &argv);

	pipeline = gst_pipeline_new(NULL);

	src = gst_element_factory_make("rtspsrc", NULL);
	g_object_set(src, "location", "rtsp://location", NULL);

	tee = gst_element_factory_make("tee", "tee");

	encoder = gst_element_factory_make("x264enc", NULL);
	muxer = gst_element_factory_make("matroskamux", NULL);
	filesink = gst_element_factory_make("filesink", NULL);
	videoconvert = gst_element_factory_make("videoconvert", NULL);
	videosink = gst_element_factory_make("autovideosink", NULL);
	queue_display = gst_element_factory_make("queue", "queue_display");
	queue_record = gst_element_factory_make("queue", "queue_record");

	if (!pipeline || !src || !tee || !encoder || !muxer || !filesink ||
!videoconvert || !videosink || !queue_record || !queue_display) {
		g_error("Failed to create elements");
		return -1;
	}

	g_object_set(filesink, "location", "rec.mkv", NULL);
	g_object_set(encoder, "tune", 4, NULL); /* important, the encoder usually
takes 1-3 seconds to process this. Queue buffer is generally upto 1 second.
Hence, set tune=zerolatency (0x4) */

	gst_bin_add_many(GST_BIN(pipeline), src, tee, queue_record, encoder, muxer,
filesink, queue_display, videoconvert, videosink, NULL);
	if (!gst_element_link_many(src, tee, NULL)
		|| !gst_element_link_many(tee, queue_record, encoder, muxer, filesink,
NULL)
		|| !gst_element_link_many(tee, queue_display, videoconvert, videosink,
NULL)
		) {
		g_error("Failed to link elements");
		return -2;
	}

	loop = g_main_loop_new(NULL, FALSE);

	bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
	gst_bus_add_signal_watch(bus);
	g_signal_connect(G_OBJECT(bus), "message", G_CALLBACK(message_cb), NULL);
	gst_object_unref(GST_OBJECT(bus));

	gst_element_set_state(pipeline, GST_STATE_PLAYING);

	g_print("Starting loop");
	g_main_loop_run(loop);

	return 0;
}



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


More information about the gstreamer-devel mailing list