Create pipeline save files sink for each stream in multiple streams input

hello!

I’m here again! I success to saving output images for each stream by change somethings at create_sink_bin function, But do not know why all image are black and have nothing, although the output of inference notice have frame and detected ok.

static GstElement *
create_sink_bin (guint index, gchar * uri)
{ 
  /*Sink output video*/

  GstElement *bin = NULL, *queue_sink = NULL, *nvvidconv_sink = NULL, 
             *filter_sink = NULL, *videoconvert = NULL, *encoder = NULL, *sink = NULL;
  GstCaps *caps_filter_sink = NULL;
  gchar bin_name[16] = { };
  gchar folder_path[50] = { };
  GstPad *pad, *ghost_pad;

  g_snprintf (bin_name, 15, "sink-bin-%02d", index);
  /* Create a source GstBin to abstract this bin's content from the rest of the
   * pipeline */
  bin = gst_bin_new (bin_name);

  queue_sink = gst_element_factory_make("queue", "queue_sink");
  nvvidconv_sink = gst_element_factory_make("nvvideoconvert", "nvvidconv_sink");
  filter_sink = gst_element_factory_make("capsfilter", "filter_sink");
  g_object_set(G_OBJECT(filter_sink), "caps", caps_filter_sink, NULL);
  gst_caps_unref(caps_filter_sink);
  videoconvert = gst_element_factory_make("videoconvert", "videoconverter");
  
  /*this encoder used to for encoder sink images file jpg*/
  encoder = gst_element_factory_make("jpegenc", "jpeg-encoder");
  
  sink = gst_element_factory_make ("multifilesink", "multifiles-renderer");

/* Source element for reading from the uri.
   * We will use decodebin and let it figure out the container format of the
   * stream and the codec and plug the appropriate demux and decode plugins. */
  //uri_decode_bin = gst_element_factory_make ("uridecodebin", "uri-decode-bin");

  if (!bin || !queue_sink || !nvvidconv_sink || !filter_sink || !videoconvert || !encoder || !sink) {
    g_printerr ("One element in sink bin could not be created.\n");
    return NULL;
  }

  g_snprintf (folder_path, 50, "/workspace/iid-%d/", index);
  strcat(folder_path, "image_%d.jpg");
  g_object_set(G_OBJECT(sink), "location", folder_path, NULL);

  gst_bin_add_many (GST_BIN (bin), queue_sink, nvvidconv_sink,
    filter_sink, videoconvert, encoder, sink, NULL);

  gst_element_link_many (queue_sink, nvvidconv_sink,
    filter_sink, videoconvert, encoder, sink, NULL);

  pad = gst_element_get_static_pad (queue_sink, "sink");
  ghost_pad = gst_ghost_pad_new ("sink", pad);
  gst_pad_set_active (ghost_pad, TRUE);

  if (!gst_element_add_pad (bin, ghost_pad)) {
    g_printerr ("Failed to add ghost pad in sink bin\n");
    return NULL;
  }
  gst_object_unref (pad);

  return bin;
}

Here is output in GST_DEBUG mode.

0:00:09.610422026  5705 0x55820a06c0a0 ERROR   default video-frame.c:175:gst_video_frame_map_id: invalid buffer size 64 < 3686400
0:00:09.610450516  5705 0x55820a06c0a0 WARN    videofilter gstvideofilter.c:293:gst_video_filter_transform:<videoconverter> warning: invalid video buffer received

pipeline.pdf (42.4 KB)