gst-launch pipeline vs its exact C analog

Sergei Vorobyov sergei.vorobyov at facilitylabs.com
Wed Mar 28 02:13:21 PDT 2012


Hi!

Your help will be greatly appreciated.

I am struggling to understand and wondering why

gst-launch filesrc location=file.avi ! decodebin2 ! ffmpegcolorspace !
autovideosink

works just fine as expected, whereas its straightforward C-programmed analog

  src = gst_element_factory_make ("filesrc", "source");
  g_object_set (src, "location", "file.avi", NULL);

  dec = gst_element_factory_make ("decodebin2", "decoder"); // won't
link to the next
  conv = gst_element_factory_make ("ffmpegcolorspace", "ffmpeg-colorspace");
  sink = gst_element_factory_make ("autovideosink", "sink");

  gst_bin_add_many (GST_BIN (pipeline),
		    src,
		    dec,
		    conv,
		    sink, NULL);

  if (!gst_element_link (src, dec)) {
    g_print("cannot link src and dec\n");
    return -1;
  }

  if (!gst_element_link (dec, conv)) { // FAILS here
    g_print("cannot link dec and conv\n");
    return -1;
  }

reports "cannot link dec and conv", i.e., gst_element_link (dec, conv) FAILS.

If I take away return -1, allowing it to proceed, it results in:

Error from element avidemux0: Internal data stream error.
Debug: gstavidemux.c(5204): gst_avi_demux_loop ():
/GstPipeline:length/GstDecodeBin2:decoder/GstAviDemux:avidemux0:
streaming stopped, reason not-linked

caught in the callback for the loop/pipeline


    if (msg_type & GST_MESSAGE_ERROR) {
      g_print ("ERROR message\n");
      gchar *debug;
      GError *err;

      gst_message_parse_error (msg, &err, &debug);
      g_free (debug);

      g_print ("Error from element %s: %s\n",
	       GST_OBJECT_NAME (msg->src),
	       err->message);
      g_print ("Debug: %s\n", (debug) ? debug : "none");
      g_error_free (err);
      g_free (debug);

      g_main_loop_quit (loop);
    }


More information about the gstreamer-devel mailing list