issue with mp4 player

Daniel Marfil danimarfil0 at
Tue Oct 20 11:11:08 PDT 2015

Hi everyone,

I am trying to implement a simple mp4 video player without audio. To do this, first I have done it with gst-launch this way:

gst-launch-1.0 souphttpsrc location="" ! qtdemux name=demux demux. ! queue2 ! h264parse ! avdec_h264 ! autovideosink

And this is working fine, so my next step is to make the equivalent in c:

#include <gst/gst.h>

/* Structure to contain all our information, so we can pass it around */
typedef struct _CustomData {
	GstElement *pipeline; /* Our one and only pipeline */
	GstElement *videosrc;

	GstElement *video_queue; //queue
	GstElement *video_demuxer; //qtdemux
	GstElement *video_decoder; //h264parse
	GstElement *video_convert; //avdec_h264
	GstElement *video_sink;

	GstState state; /* Current state of the pipeline */
	gint64 duration; /* Duration of the clip, in nanoseconds */
} CustomData;

static void pad_added_handler_qtdemux(GstElement *src, GstPad *pad,
		CustomData *data) {

	g_print("Inside the pad_added_handler_qtdemux method \n");
	g_print("Received new pad '%s' from '%s':\n", GST_PAD_NAME(pad),

	if (g_str_has_prefix(gst_pad_get_name(pad), "video/x-h264")) {

		GstPad *sinkpad1 = gst_element_get_static_pad(data->video_queue,
		gst_pad_link(pad, sinkpad1);
		g_print("|| I create a  '%s'|| \n", gst_pad_get_name(pad));


int main(int argc, char *argv[]) {
	CustomData data;
	GstStateChangeReturn ret;
	GstBus *bus;

	/* Initialize GStreamer */
	gst_init(&argc, &argv);

	/* Initialize our data structure */
	memset(&data, 0, sizeof(data));
	data.duration = GST_CLOCK_TIME_NONE;

	/* Create the elements */
	data.pipeline = gst_pipeline_new("Test");
	data.videosrc = gst_element_factory_make("souphttpsrc", "http-src");

	data.video_demuxer = gst_element_factory_make("qtdemux", "video_demuxer");
	data.video_queue = gst_element_factory_make("queue2", "video_queue2");
	data.video_decoder = gst_element_factory_make("h264parse", "video_decoder");
	data.video_convert = gst_element_factory_make("avdec_h264",
	data.video_sink = gst_element_factory_make("autovideosink", "video_sink");

	if (!data.pipeline) {
		g_printerr("Not all elements could be created.\n");
		return -1;

	/* Set the URI to play */
	g_object_set(G_OBJECT(data.videosrc), "location",
			"", NULL);

	/* Instruct the bus to emit signals for each received message, and connect to the interesting signals */
	bus = gst_element_get_bus(data.pipeline);

	g_signal_connect(data.video_demuxer, "pad-added",
			G_CALLBACK (pad_added_handler_qtdemux), NULL);


	gst_bin_add_many(GST_BIN(data.pipeline), data.videosrc, data.video_queue,
			data.video_demuxer, data.video_decoder, data.video_convert,
			data.video_sink, NULL); //data.audio_queue, data.audio_decoder, data.audio_convert, data.audio_sink, NULL);

	gst_element_link(data.videosrc, data.video_demuxer);

	gst_element_link_many(data.video_queue, data.video_decoder,
			data.video_convert, data.video_sink, NULL);

	/* Start playing */
	ret = gst_element_set_state(data.pipeline, GST_STATE_PLAYING);
		g_printerr("Unable to set the pipeline to the playing state.\n");
		return -1;

	/* Free resources */
	gst_element_set_state(data.pipeline, GST_STATE_NULL);
	return 0;

I can build it fine but when I run it I get the following errors:

(mp4-player-wo-gtk:4563): GLib-GObject-CRITICAL **: g_object_set: assertion 'G_IS_OBJECT (object)' failed

(mp4-player-wo-gtk:4563): GStreamer-CRITICAL **: gst_bin_add_many: assertion 'GST_IS_ELEMENT (element_1)' failed

(mp4-player-wo-gtk:4563): GStreamer-CRITICAL **: gst_element_link_pads_full: assertion 'GST_IS_ELEMENT (src)’ failed

I think I am doing exactly the same as gst-launch, but it is crashing.



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the gstreamer-devel mailing list