Gstreamer Concat command line to code?

killerrats koreysjunkmail at
Thu Nov 1 18:09:31 UTC 2018

Success on building the pipeline to code. Just have to put each filesrc
elements in a list and pass to the pad-added function from demux and works.
Have to also connect the queue to the concat elements audio and video side.
There is a limit on storage because it seems to halt at a certain time. have
to figure that out. seems to be at different amounts of storage. it could do
10 files with 10 megabytes each. Different time I could only combine 3 of 50
megabyte files. So don't know what the difference is. Any one know?

class filesrcElements
		GstElement* filesrc
		,* qtdemux
		,* queue1
		,* queue2;
		std::string queue1Name, queue2Name, qtdemuxName,
bool VideoPipeline::SetupFilesrcElements()
	if (this->aFiles.size() == 0)
		return false;

	GstPad* srcPad, *sinkPad;
	GstElement* concat = gst_bin_get_by_name(GST_BIN(this->srcPipeline),
	,* concat2 = gst_bin_get_by_name(GST_BIN(this->srcPipeline),"concat2");

	std::string filesrcPipe;
	std::list<std::string>::iterator it = this->aFiles.begin();
	unsigned int index = 0;

	for (; it != this->aFiles.end(); it++)
		AddToConsoleOutputList("File: " + *it);
		filesrcElements file;
		std::string demuxName = "dem" + std::to_string(index);
		std::string filesrcName = "filesrc" + std::to_string(index);
		std::string queue1Name = "queue" + std::to_string(queueCount);
		std::string queue2Name = "queue" + std::to_string(queueCount);
		file.filesrcName = filesrcName;
		file.qtdemuxName = demuxName;
		file.queue1Name = queue1Name;
		file.queue2Name = queue2Name;

		file.queue1 = this->AssignElement("queue", queue1Name);
		file.queue2 = this->AssignElement("queue", queue2Name);
		file.filesrc = this->AssignElement("filesrc", filesrcName);
		file.qtdemux = this->AssignElement("qtdemux", demuxName);

		g_object_set(G_OBJECT(file.filesrc), "location", (*it).c_str(), NULL);
		gst_bin_add_many(GST_BIN(this->srcPipeline), file.filesrc,
file.qtdemux,file.queue1,file.queue2, NULL);

		gst_element_link(file.filesrc, file.qtdemux);

		sinkPad = gst_element_get_request_pad(concat,
		srcPad = gst_element_get_static_pad(file.queue1, "src");
		gst_pad_link(srcPad, sinkPad);

		sinkPad = gst_element_get_request_pad(concat2, ("sink_" +
		srcPad = gst_element_get_static_pad(file.queue2, "src");
		gst_pad_link(srcPad, sinkPad);

                //list so gstreamer has reference to

                // signal from demux and pass the file that was just added
to be connected to queues
		g_signal_connect(file.qtdemux, "pad-added",
G_CALLBACK(qtdemux_pad_added_cb), &this->filesSources.back());
	return true;
void VideoPipeline::qtdemux_pad_added_cb(GstElement* element,
	GstPad* pad,
	gpointer user_data)
	gchar *name;
	GstCaps * p_caps;
	GstElement* nextElement = NULL;
	filesrcElements* file = static_cast<filesrcElements*>(user_data);
	name = gst_pad_get_name(pad);
	//g_print("A new pad %s was created\n", name);
	p_caps = gst_pad_get_pad_template_caps(pad);

	if (strstr(name, "video") != NULL)
		std::cout << "\n------------------------ Video
			if (!gst_element_link_pads_filtered(element, name,file->queue1 ,
				std::cout << "\nFailed to link video element to src to sink\n";
	else if (strstr(name, "audio") != NULL)
		std::cout << "\n------------------------ Audio
		if (!gst_element_link_pads_filtered(element, name, file->queue2, "sink",
			std::cout << "\nFailed to link video element to src to sink\n";

Gstreamer 1.14.4
Sent from:

More information about the gstreamer-devel mailing list