issue with mp4 player

Daniel Marfil danimarfil0 at gmail.com
Tue Oct 20 21:58:49 PDT 2015


Ok thanks for your advices! I will solve it asap!

Regards

Dani
> El 20 oct 2015, a las 23:01, Chuck Crisler <ccrisler at mutualink.net> escribió:
> 
> You have several problems, some serious and some not, but that indicate a lack of understanding on your part. For example, your element named video_decoder is created as an h264parser, which parses the H264 data but doesn't decode it. That isn't critical and would work, but it is confusing to the reader. The same applies to video_convert.
> 
> Based on the way you have the pipeline organized, it seems that you intend to add audio support soon/next. You don't need the demuxer name and the queue if you only handle video. However, if you want audio later, you will need a 'T' (tee) element after the demuxer and 2 queues, one for each branch. But that is future and not why it isn't working now.
> 
> The errors that are reported suggest that one of your element creation operations is not succeeding and you never test that they do. Never assume that something worked. Always check that the creation worked. Your check of the pipeline for creation is not sufficient. Since g_object_set(), gst_bin_add_many() and gst_element_link_pads_full() are failing, I suspect that the video_src element creation is failing. Since it works with gst_launch-1.0, I can't immediately guess why it is failing from C. You can enable logging. Check the documentation for GST-INFO.
> 
> I think that the reason that you crash is when you de-reference data in your callback function. When you register the callback you are passing NULL for the data item, so that item in your callback will also be NULL. In the register, change the NULL to data. I think that you won't crash, but it won't work until you fix the assertions.
> 
> On Tue, Oct 20, 2015 at 2:11 PM, Daniel Marfil <danimarfil0 at gmail.com <mailto:danimarfil0 at gmail.com>> wrote:
> 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="https://download.blender.org/durian/trailer/sintel_trailer-480p.mp4 <https://download.blender.org/durian/trailer/sintel_trailer-480p.mp4>" ! 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),
> 			GST_ELEMENT_NAME(src));
> 
> 	if (g_str_has_prefix(gst_pad_get_name(pad), "video/x-h264")) {
> 
> 		GstPad *sinkpad1 = gst_element_get_static_pad(data->video_queue,
> 				"sink");
> 		gst_pad_link(pad, sinkpad1);
> 		gst_object_unref(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",
> 			"video_convert");
> 	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",
> 			"https://download.blender.org/durian/trailer/sintel_trailer-480p.mp4 <https://download.blender.org/durian/trailer/sintel_trailer-480p.mp4>", NULL);
> 
> 	/* Instruct the bus to emit signals for each received message, and connect to the interesting signals */
> 	bus = gst_element_get_bus(data.pipeline);
> 	gst_bus_add_signal_watch(bus);
> 
> 	g_signal_connect(data.video_demuxer, "pad-added",
> 			G_CALLBACK (pad_added_handler_qtdemux), NULL);
> 
> 	gst_object_unref(bus);
> 
> 	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);
> 	if (ret == GST_STATE_CHANGE_FAILURE) {
> 		g_printerr("Unable to set the pipeline to the playing state.\n");
> 		gst_object_unref(data.pipeline);
> 		return -1;
> 	}
> 
> 	/* Free resources */
> 	gst_element_set_state(data.pipeline, GST_STATE_NULL);
> 	gst_object_unref(data.pipeline);
> 	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.
> 
> Regards, 
> 
> Dani
> 
> 
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org <mailto:gstreamer-devel at lists.freedesktop.org>
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel <http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel>
> 
> 
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20151021/2c534440/attachment-0001.html>


More information about the gstreamer-devel mailing list