<div dir="ltr"><div><div><div>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.<br><br></div>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.<br><br></div>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.<br><br></div>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.<br><div><div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 20, 2015 at 2:11 PM, Daniel Marfil <span dir="ltr"><<a href="mailto:danimarfil0@gmail.com" target="_blank">danimarfil0@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hi everyone,<div><br><div>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:</div><div><br></div><div><div style="margin:0px;line-height:normal"><font face="Menlo" size="1">gst-launch-1.0 souphttpsrc location="<a href="https://download.blender.org/durian/trailer/sintel_trailer-480p.mp4" target="_blank">https://download.blender.org/durian/trailer/sintel_trailer-480p.mp4</a>" ! qtdemux name=demux demux. ! queue2 ! h264parse ! avdec_h264 ! autovideosink</font></div></div><div><br></div><div>And this is working fine, so my next step is to make the equivalent in c:</div><div><br></div><div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1">#include <gst/gst.h></font></div><div style="margin:0px;line-height:normal;font-family:Menlo;min-height:13px"><font size="1"><br></font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1">/* Structure to contain all our information, so we can pass it around */</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1">typedef struct _CustomData {</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">      </span>GstElement *pipeline; /* Our one and only pipeline */</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">      </span>GstElement *videosrc;</font></div><div style="margin:0px;line-height:normal;font-family:Menlo;min-height:13px"><font size="1"><br></font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">       </span>GstElement *video_queue; //queue</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">   </span>GstElement *video_demuxer; //qtdemux</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">       </span>GstElement *video_decoder; //h264parse</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">     </span>GstElement *video_convert; //avdec_h264</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">    </span>GstElement *video_sink;</font></div><div style="margin:0px;line-height:normal;font-family:Menlo;min-height:13px"><font size="1"><br></font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">     </span>GstState state; /* Current state of the pipeline */</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">        </span>gint64 duration; /* Duration of the clip, in nanoseconds */</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1">} CustomData;</font></div><div style="margin:0px;line-height:normal;font-family:Menlo;min-height:13px"><font size="1"><br></font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1">static void pad_added_handler_qtdemux(GstElement *src, GstPad *pad,</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">               </span>CustomData *data) {</font></div><div style="margin:0px;line-height:normal;font-family:Menlo;min-height:13px"><font size="1"><br></font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap"> </span>g_print("Inside the pad_added_handler_qtdemux method \n");</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">       </span>g_print("Received new pad '%s' from '%s':\n", GST_PAD_NAME(pad),</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">                 </span>GST_ELEMENT_NAME(src));</font></div><div style="margin:0px;line-height:normal;font-family:Menlo;min-height:13px"><font size="1"><br></font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">     </span>if (g_str_has_prefix(gst_pad_get_name(pad), "video/x-h264")) {</font></div><div style="margin:0px;line-height:normal;font-family:Menlo;min-height:13px"><font size="1"><br></font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">            </span>GstPad *sinkpad1 = gst_element_get_static_pad(data->video_queue,</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">                                </span>"sink");</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">         </span>gst_pad_link(pad, sinkpad1);</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">               </span>gst_object_unref(sinkpad1);</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">                </span>g_print("|| I create a  '%s'|| \n", gst_pad_get_name(pad));</font></div><div style="margin:0px;line-height:normal;font-family:Menlo;min-height:13px"><font size="1"><br></font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">      </span>}</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1">}</font></div><div style="margin:0px;line-height:normal;font-family:Menlo;min-height:13px"><font size="1"><br></font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1">int main(int argc, char *argv[]) {</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">      </span>CustomData data;</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">   </span>GstStateChangeReturn ret;</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">  </span>GstBus *bus;</font></div><div style="margin:0px;line-height:normal;font-family:Menlo;min-height:13px"><font size="1"><br></font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">        </span>/* Initialize GStreamer */</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap"> </span>gst_init(&argc, &argv);</font></div><div style="margin:0px;line-height:normal;font-family:Menlo;min-height:13px"><font size="1"><br></font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">     </span>/* Initialize our data structure */</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">        </span>memset(&data, 0, sizeof(data));</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">        </span>data.duration = GST_CLOCK_TIME_NONE;</font></div><div style="margin:0px;line-height:normal;font-family:Menlo;min-height:13px"><font size="1"><br></font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">        </span>/* Create the elements */</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">  </span>data.pipeline = gst_pipeline_new("Test");</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">        </span>data.videosrc = gst_element_factory_make("souphttpsrc", "http-src");</font></div><div style="margin:0px;line-height:normal;font-family:Menlo;min-height:13px"><font size="1"><br></font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">    </span>data.video_demuxer = gst_element_factory_make("qtdemux", "video_demuxer");</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">     </span>data.video_queue = gst_element_factory_make("queue2", "video_queue2");</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap"> </span>data.video_decoder = gst_element_factory_make("h264parse", "video_decoder");</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">   </span>data.video_convert = gst_element_factory_make("avdec_h264",</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">                      </span>"video_convert");</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">        </span>data.video_sink = gst_element_factory_make("autovideosink", "video_sink");</font></div><div style="margin:0px;line-height:normal;font-family:Menlo;min-height:13px"><font size="1"><br></font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">      </span>if (!data.pipeline) {</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">              </span>g_printerr("Not all elements could be created.\n");</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">              </span>return -1;</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap"> </span>}</font></div><div style="margin:0px;line-height:normal;font-family:Menlo;min-height:13px"><font size="1"><br></font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">   </span>/* Set the URI to play */</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">  </span>g_object_set(G_OBJECT(data.videosrc), "location",</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">                        </span>"<a href="https://download.blender.org/durian/trailer/sintel_trailer-480p.mp4" target="_blank">https://download.blender.org/durian/trailer/sintel_trailer-480p.mp4</a>", NULL);</font></div><div style="margin:0px;line-height:normal;font-family:Menlo;min-height:13px"><font size="1"><br></font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">   </span>/* Instruct the bus to emit signals for each received message, and connect to the interesting signals */</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">   </span>bus = gst_element_get_bus(data.pipeline);</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">  </span>gst_bus_add_signal_watch(bus);</font></div><div style="margin:0px;line-height:normal;font-family:Menlo;min-height:13px"><font size="1"><br></font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">      </span>g_signal_connect(data.video_demuxer, "pad-added",</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">                        </span>G_CALLBACK (pad_added_handler_qtdemux), NULL);</font></div><div style="margin:0px;line-height:normal;font-family:Menlo;min-height:13px"><font size="1"><br></font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">      </span>gst_object_unref(bus);</font></div><div style="margin:0px;line-height:normal;font-family:Menlo;min-height:13px"><font size="1"><br></font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">      </span>gst_bin_add_many(GST_BIN(data.pipeline), data.videosrc, data.video_queue,</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">                  </span>data.video_demuxer, data.video_decoder, data.video_convert,</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">                        </span>data.video_sink, NULL); //data.audio_queue, data.audio_decoder, data.audio_convert, data.audio_sink, NULL);</font></div><div style="margin:0px;line-height:normal;font-family:Menlo;min-height:13px"><font size="1"><br></font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap"> </span>gst_element_link(data.videosrc, data.video_demuxer);</font></div><div style="margin:0px;line-height:normal;font-family:Menlo;min-height:13px"><font size="1"><br></font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">        </span>gst_element_link_many(data.video_queue, data.video_decoder,</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">                        </span>data.video_convert, data.video_sink, NULL);</font></div><div style="margin:0px;line-height:normal;font-family:Menlo;min-height:13px"><font size="1"><br></font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap"> </span>/* Start playing */</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">        </span>ret = gst_element_set_state(data.pipeline, GST_STATE_PLAYING);</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">     </span>if (ret == GST_STATE_CHANGE_FAILURE) {</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">             </span>g_printerr("Unable to set the pipeline to the playing state.\n");</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">                </span>gst_object_unref(data.pipeline);</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">           </span>return -1;</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap"> </span>}</font></div><div style="margin:0px;line-height:normal;font-family:Menlo;min-height:13px"><font size="1"><br></font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">   </span>/* Free resources */</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">       </span>gst_element_set_state(data.pipeline, GST_STATE_NULL);</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">      </span>gst_object_unref(data.pipeline);</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><span style="white-space:pre-wrap">   </span>return 0;</font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1">}</font></div></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><br></font></div><div style="margin:0px;line-height:normal;font-family:Menlo"><font size="1"><br></font></div><div style="margin:0px;line-height:normal"><font>I can build it fine but when I run it I get the following errors:</font></div><div style="margin:0px;line-height:normal"><font face="Menlo" size="1"><br></font></div><div style="margin:0px;line-height:normal"><div style="font-family:Menlo;font-size:x-small;margin:0px;line-height:normal">(mp4-player-wo-gtk:4563): GLib-GObject-CRITICAL **: g_object_set: assertion 'G_IS_OBJECT (object)' failed</div><div style="font-family:Menlo;font-size:x-small;margin:0px;line-height:normal;min-height:13px"><br></div><div style="font-family:Menlo;font-size:x-small;margin:0px;line-height:normal">(mp4-player-wo-gtk:4563): GStreamer-CRITICAL **: gst_bin_add_many: assertion 'GST_IS_ELEMENT (element_1)' failed</div><div style="font-family:Menlo;font-size:x-small;margin:0px;line-height:normal;min-height:13px"><br></div><div style="font-family:Menlo;font-size:x-small;margin:0px;line-height:normal">(mp4-player-wo-gtk:4563): GStreamer-CRITICAL **: gst_element_link_pads_full: assertion 'GST_IS_ELEMENT (src)’ failed</div><div style="font-family:Menlo;font-size:x-small;margin:0px;line-height:normal"><br></div><div style="margin:0px;line-height:normal">I think I am doing exactly the same as gst-launch, but it is crashing.</div><div style="margin:0px;line-height:normal"><br></div><div style="margin:0px;line-height:normal">Regards, </div><div style="margin:0px;line-height:normal"><br></div><div style="margin:0px;line-height:normal">Dani</div><div style="margin:0px;line-height:normal"><br></div></div></div></div><br>_______________________________________________<br>
gstreamer-devel mailing list<br>
<a href="mailto:gstreamer-devel@lists.freedesktop.org">gstreamer-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel" rel="noreferrer" target="_blank">http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a><br>
<br></blockquote></div><br></div></div></div></div></div></div>