When should I send a starting seek?

amindfv at mailbox.org amindfv at mailbox.org
Wed Apr 20 19:28:15 UTC 2022


I've spent quite a lot of time attempting to debug this with no breakthrough. It may be that I'm missing something very obvious in the documentation, but it's not from lack of trying or RTFM-ing!

Below (and attached) is a smallish reproducer case, the smallest I can make it. It creates a pipeline successfully with "uridecodebin" but fails to with "nleurisource". Any help would be very appreciated!

Any help would be very appreciated!

Thanks,
Tom

---

#include <gst/gst.h>

static void pad_added_handler (GstElement * src, GstPad * pad, GstPad * sink_pad);

int main (int argc, char *argv[]) {
  GstElement *decodebin0;
  GstElement *decodebin1;
  GstElement *alphacombine;
  GstElement *videoconvert;
  GstElement *compositor;
  GstElement *autovideosink;
  GstElement *pipeline;
  GstBus *bus;
  GstMessage *msg;
  GstBin *bin;
  gboolean terminate = FALSE;

  gst_init (&argc, &argv);

  // If you change these "nleurisource"s to "uridecodebin"s it all works fine:
  decodebin0 = gst_element_factory_make("nleurisource", NULL);
  decodebin1 = gst_element_factory_make("nleurisource", NULL);

  alphacombine = gst_element_factory_make("alphacombine", NULL);
  compositor = gst_element_factory_make("compositor", NULL);
  videoconvert = gst_element_factory_make("videoconvert", NULL);
  autovideosink = gst_element_factory_make("autovideosink", NULL);

  g_object_set(decodebin0, "uri", "file:///home/foo/foo.mp4", NULL);
  g_object_set(decodebin1, "uri", "file:///home/foo/bar.mp4", NULL);

  // Comment these out if using "uridecodebin":
  g_object_set(decodebin0, "inpoint", 10000000000, NULL);
  g_object_set(decodebin0, "duration",10000000000, NULL);
  g_object_set(decodebin1, "inpoint", 10000000000, NULL);
  g_object_set(decodebin1, "duration",10000000000, NULL);

  g_object_set(compositor, "background", 1, NULL);

  g_signal_connect(decodebin0, "pad-added", G_CALLBACK(pad_added_handler), gst_element_get_static_pad(alphacombine, "sink"));
  g_signal_connect(decodebin1, "pad-added", G_CALLBACK(pad_added_handler), gst_element_get_static_pad(alphacombine, "alpha"));

  pipeline = gst_pipeline_new(NULL);
  bin = GST_BIN(pipeline);
  gst_bin_add_many(bin, decodebin0, decodebin1, alphacombine, compositor, videoconvert, autovideosink, NULL);

  if (!gst_element_link_many (alphacombine, compositor, videoconvert, autovideosink, NULL)) {
    g_printerr ("Elements could not be linked.\n");
    gst_object_unref(pipeline);
    return -1;
  };

  gst_element_set_state (pipeline, GST_STATE_PLAYING);

  bus = gst_element_get_bus (pipeline);
  do {
    msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, GST_MESSAGE_STATE_CHANGED | GST_MESSAGE_ERROR | GST_MESSAGE_EOS);

    if (msg != NULL) {
      GError *err;
      gchar *debug_info;

      switch (GST_MESSAGE_TYPE (msg)) {
        case GST_MESSAGE_ERROR:
          gst_message_parse_error (msg, &err, &debug_info);
          g_printerr ("Error received from element %s: %s\n", GST_OBJECT_NAME (msg->src), err->message);
          g_printerr ("Debugging information: %s\n", debug_info ? debug_info : "none");
          g_clear_error (&err);
          g_free (debug_info);
          terminate = TRUE;
          break;
        case GST_MESSAGE_EOS:
          g_print ("End-Of-Stream reached.\n");
          terminate = TRUE;
          break;
      }
      gst_message_unref (msg);
    }
  } while (!terminate);

  gst_message_unref (msg);
  gst_object_unref (bus);
  gst_element_set_state (pipeline, GST_STATE_NULL);
  gst_object_unref (pipeline);
  return 0;
}


static void pad_added_handler (GstElement * src, GstPad * new_pad, GstPad * sink_pad)
{
  GstPadLinkReturn ret;
  GstCaps *new_pad_caps = NULL;
  GstStructure *new_pad_struct = NULL;
  const gchar *new_pad_type = NULL;

  g_print ("Received new pad '%s' from '%s':\n", GST_PAD_NAME (new_pad), GST_ELEMENT_NAME (src));

  if (gst_pad_is_linked (sink_pad)) {
    gst_object_unref (sink_pad);
    return;
  }

  new_pad_caps = gst_pad_get_current_caps (new_pad);
  new_pad_struct = gst_caps_get_structure (new_pad_caps, 0);
  new_pad_type = gst_structure_get_name (new_pad_struct);
  if (!g_str_has_prefix (new_pad_type, "video/x-raw")) {
    g_print ("It has type '%s' which is not raw video. Ignoring.\n", new_pad_type);
    gst_caps_unref (new_pad_caps);
    gst_object_unref (sink_pad);
  } else {
    ret = gst_pad_link(new_pad, sink_pad);
    if (GST_PAD_LINK_FAILED (ret)) {
      g_print ("Type is '%s' but link failed.\n", new_pad_type);
    } else {
      g_print ("Link succeeded (type '%s').\n", new_pad_type);
    }
  }
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: repro.c
Type: text/x-csrc
Size: 4114 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20220420/c401509c/attachment-0001.c>


More information about the gstreamer-devel mailing list