Pipeline ends after 4 seconds with GST_MESSAGE_EOS

Using NVIDIA Jetson AGX Orin Developer Kit, JetPack 5.0.2 with Logitech C920 HD Pro Webcam.

Pipeline functions as expected, video displays on window and frame rate is good. However, drops in
about 4 seconds. I’ve been researching to flush and restart. I guess the object is to trap the EOS and then
flush, restart? This is my code. i don’t know exactly where to makes modifications. Any ideas or examples?


#include <gst/gst.h>

static GMainLoop *loop;

static gboolean my_bus_callback (GstBus * bus, GstMessage * message, gpointer data)
  g_print ("Got %s message\n", GST_MESSAGE_TYPE_NAME (message));

  switch (GST_MESSAGE_TYPE (message)) {
      GError *err;
      gchar *debug;

      gst_message_parse_error (message, &err, &debug);
      g_print ("Error: %s\n", err->message);
      g_error_free (err);
      g_free (debug);

      g_main_loop_quit (loop);
      /* end-of-stream */
      g_main_loop_quit (loop);
      /* unhandled message */
  return TRUE;

int main (int argc, char *argv[])
  GstElement *gst_pipeline;
  GstBus *bus;
  GstStateChangeReturn ret;
  const gchar *pipeline_description;
  GError *error = NULL; // NULL required or gst_parse_launch errors out
  guint bus_watch_id;

  /* Initialize GStreamer */
  gst_init (&argc, &argv);
  /* Create the pipeline */
  pipeline_description = "v4l2src device=/dev/video0 num-buffers=100 ! video/x-raw,format=YUY2,width=640,height=480,framerate=30/1 ! nvvidconv ! nvegltransform ! nveglglessink";
  gst_pipeline = gst_parse_launch(pipeline_description, &error);  
    g_print("Failed to parse launch: %s\n", error->message);
    return -1;
  if(error) g_error_free(error);  

  /* Start playing */
  g_print("STEP 1\n"); 
  ret = gst_element_set_state (gst_pipeline, GST_STATE_PLAYING);
    g_printerr ("Unable to set the pipeline to the playing state.\n");
    gst_object_unref (gst_pipeline);
    return -1;

  g_print("STEP 2\n");

  /* Wait until error or EOS */
  bus = gst_element_get_bus (gst_pipeline);
  bus_watch_id = gst_bus_add_watch (bus, my_bus_callback, NULL);
  gst_object_unref (bus);

  loop = g_main_loop_new (NULL, FALSE);
  g_main_loop_run (loop);

  /* clean up */
  gst_element_set_state (gst_pipeline, GST_STATE_NULL);
  gst_object_unref (gst_pipeline);
  g_source_remove (bus_watch_id);
  g_main_loop_unref (loop);
  return 0;

hello steven.sparks,

that’s due to you’ve created pipeline to assign number of buffers. it’ll terminate after 100 capture frames.

How silly of me! You may close this one. Thanks!!!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.