<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi everyone,<div class=""><br class=""><div class="">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 class=""><br class=""></div><div class=""><div style="margin: 0px; line-height: normal;" class=""><font face="Menlo" size="1" class="">gst-launch-1.0 souphttpsrc location="<a href="https://download.blender.org/durian/trailer/sintel_trailer-480p.mp4" class="">https://download.blender.org/durian/trailer/sintel_trailer-480p.mp4</a>" ! qtdemux name=demux demux. ! queue2 ! h264parse ! avdec_h264 ! autovideosink</font></div></div><div class=""><br class=""></div><div class="">And this is working fine, so my next step is to make the equivalent in c:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class="">#include <gst/gst.h></font></div><div style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><font size="1" class=""><br class=""></font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class="">/* Structure to contain all our information, so we can pass it around */</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class="">typedef struct _CustomData {</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>GstElement *pipeline; /* Our one and only pipeline */</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">      </span>GstElement *videosrc;</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><font size="1" class=""><br class=""></font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">      </span>GstElement *video_queue; //queue</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">   </span>GstElement *video_demuxer; //qtdemux</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">       </span>GstElement *video_decoder; //h264parse</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">     </span>GstElement *video_convert; //avdec_h264</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">    </span>GstElement *video_sink;</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><font size="1" class=""><br class=""></font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">    </span>GstState state; /* Current state of the pipeline */</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>gint64 duration; /* Duration of the clip, in nanoseconds */</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class="">} CustomData;</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><font size="1" class=""><br class=""></font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class="">static void pad_added_handler_qtdemux(GstElement *src, GstPad *pad,</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">              </span>CustomData *data) {</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><font size="1" class=""><br class=""></font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>g_print("Inside the pad_added_handler_qtdemux method \n");</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">       </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;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">                 </span>GST_ELEMENT_NAME(src));</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><font size="1" class=""><br class=""></font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">    </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;" class=""><font size="1" class=""><br class=""></font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">           </span>GstPad *sinkpad1 = gst_element_get_static_pad(data->video_queue,</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">                                </span>"sink");</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">         </span>gst_pad_link(pad, sinkpad1);</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">               </span>gst_object_unref(sinkpad1);</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">                </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;" class=""><font size="1" class=""><br class=""></font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>}</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class="">}</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><font size="1" class=""><br class=""></font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class="">int main(int argc, char *argv[]) {</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">     </span>CustomData data;</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">   </span>GstStateChangeReturn ret;</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">  </span>GstBus *bus;</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><font size="1" class=""><br class=""></font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">       </span>/* Initialize GStreamer */</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>gst_init(&argc, &argv);</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><font size="1" class=""><br class=""></font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">    </span>/* Initialize our data structure */</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>memset(&data, 0, sizeof(data));</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>data.duration = GST_CLOCK_TIME_NONE;</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><font size="1" class=""><br class=""></font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">       </span>/* Create the elements */</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">  </span>data.pipeline = gst_pipeline_new("Test");</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">        </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;" class=""><font size="1" class=""><br class=""></font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">   </span>data.video_demuxer = gst_element_factory_make("qtdemux", "video_demuxer");</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">     </span>data.video_queue = gst_element_factory_make("queue2", "video_queue2");</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>data.video_decoder = gst_element_factory_make("h264parse", "video_decoder");</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">   </span>data.video_convert = gst_element_factory_make("avdec_h264",</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">                      </span>"video_convert");</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">        </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;" class=""><font size="1" class=""><br class=""></font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">     </span>if (!data.pipeline) {</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">              </span>g_printerr("Not all elements could be created.\n");</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">              </span>return -1;</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>}</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><font size="1" class=""><br class=""></font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">  </span>/* Set the URI to play */</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">  </span>g_object_set(G_OBJECT(data.videosrc), "location",</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">                        </span>"<a href="https://download.blender.org/durian/trailer/sintel_trailer-480p.mp4" class="">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;" class=""><font size="1" class=""><br class=""></font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre"> </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;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">   </span>bus = gst_element_get_bus(data.pipeline);</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">  </span>gst_bus_add_signal_watch(bus);</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><font size="1" class=""><br class=""></font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">     </span>g_signal_connect(data.video_demuxer, "pad-added",</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">                        </span>G_CALLBACK (pad_added_handler_qtdemux), NULL);</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><font size="1" class=""><br class=""></font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">     </span>gst_object_unref(bus);</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><font size="1" class=""><br class=""></font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">     </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;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">                  </span>data.video_demuxer, data.video_decoder, data.video_convert,</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">                        </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;" class=""><font size="1" class=""><br class=""></font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>gst_element_link(data.videosrc, data.video_demuxer);</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><font size="1" class=""><br class=""></font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">       </span>gst_element_link_many(data.video_queue, data.video_decoder,</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">                        </span>data.video_convert, data.video_sink, NULL);</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><font size="1" class=""><br class=""></font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>/* Start playing */</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>ret = gst_element_set_state(data.pipeline, GST_STATE_PLAYING);</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">     </span>if (ret == GST_STATE_CHANGE_FAILURE) {</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">             </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;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">                </span>gst_object_unref(data.pipeline);</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">           </span>return -1;</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>}</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><font size="1" class=""><br class=""></font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">  </span>/* Free resources */</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">       </span>gst_element_set_state(data.pipeline, GST_STATE_NULL);</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">      </span>gst_object_unref(data.pipeline);</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><span class="Apple-tab-span" style="white-space:pre">   </span>return 0;</font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class="">}</font></div></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><br class=""></font></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><font size="1" class=""><br class=""></font></div><div style="margin: 0px; line-height: normal;" class=""><font class="">I can build it fine but when I run it I get the following errors:</font></div><div style="margin: 0px; line-height: normal;" class=""><font face="Menlo" size="1" class=""><br class=""></font></div><div style="margin: 0px; line-height: normal;" class=""><div style="font-family: Menlo; font-size: x-small; margin: 0px; line-height: normal;" class="">(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;" class=""><br class=""></div><div style="font-family: Menlo; font-size: x-small; margin: 0px; line-height: normal;" class="">(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;" class=""><br class=""></div><div style="font-family: Menlo; font-size: x-small; margin: 0px; line-height: normal;" class="">(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;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class="">I think I am doing exactly the same as gst-launch, but it is crashing.</div><div style="margin: 0px; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class="">Regards, </div><div style="margin: 0px; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class="">Dani</div><div style="margin: 0px; line-height: normal;" class=""><br class=""></div></div></div></body></html>