Gst for merging 4 webcams sometimes works, and sometimes it doesn't

Hi,
The nvcompositor plugin is open source from r32.5.1. Please apply this patch:

diff --git a/gst-nvcompositor/gstnvcompositor.c b/gst-nvcompositor/gstnvcompositor.c
index d0c23d7..c85c515 100644
--- a/gst-nvcompositor/gstnvcompositor.c
+++ b/gst-nvcompositor/gstnvcompositor.c
@@ -708,7 +708,9 @@ gst_nvcompositor_pad_init (GstNvCompositorPad * nvcompo_pad)
 enum
 {
   PROP_0,
-  PROP_BACKGROUND
+  PROP_BACKGROUND,
+  PROP_BACKGROUND_WIDTH,
+  PROP_BACKGROUND_HEIGHT
 };
 
 #define GST_TYPE_NVCOMPOSITOR_BACKGROUND (gst_nvcompositor_background_get_type())
@@ -784,6 +786,12 @@ gst_nvcompositor_set_property (GObject * object,
 //    gst_nvcompositor_parse_bgcolor (value, nvcomp);
       nvcomp->background = g_value_get_enum (value);
       break;
+    case PROP_BACKGROUND_WIDTH:
+      nvcomp->bg_width = g_value_get_int(value);
+      break;
+    case PROP_BACKGROUND_HEIGHT:
+      nvcomp->bg_height = g_value_get_int(value);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -808,6 +816,12 @@ gst_nvcompositor_get_property (GObject * object,
 //    gst_nvcompositor_get_bgcolor (value, nvcomp);
       g_value_set_enum (value, nvcomp->background);
       break;
+    case PROP_BACKGROUND_WIDTH:
+      g_value_set_int(value, nvcomp->bg_width);
+      break;
+    case PROP_BACKGROUND_HEIGHT:
+      g_value_set_int(value, nvcomp->bg_height);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -837,6 +851,7 @@ gst_nvcompositor_fixate_caps (GstAggregator * agg, GstCaps * caps)
   gint suitable_fps_n = -1, suitable_fps_d = -1;
   gint suitable_width = -1, suitable_height = -1;
   GstVideoAggregator *vagg = GST_VIDEO_AGGREGATOR (agg);
+  GstNvCompositor *nvcomp = GST_NVCOMPOSITOR (vagg);
 
   ret = gst_caps_make_writable (caps);
 
@@ -897,6 +912,10 @@ gst_nvcompositor_fixate_caps (GstAggregator * agg, GstCaps * caps)
     suitable_fps_n = 30;
     suitable_fps_d = 1;
   }
+  if (nvcomp->bg_width > 0 && nvcomp->bg_height > 0) {
+      suitable_width = nvcomp->bg_width;
+      suitable_height = nvcomp->bg_height;
+  }
 
   gst_structure_fixate_field_nearest_fraction (str, "framerate", suitable_fps_n,
       suitable_fps_d);
@@ -1421,6 +1440,15 @@ gst_nvcompositor_class_init (GstNvCompositorClass * klass)
           GST_TYPE_NVCOMPOSITOR_BACKGROUND,
           DEFAULT_BACKGROUND, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
+  g_object_class_install_property (gobject_class, PROP_BACKGROUND_WIDTH,
+      g_param_spec_int ("background-w", "Width", "Width of the background",
+          0, G_MAXINT, 0,
+          G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
+  g_object_class_install_property (gobject_class, PROP_BACKGROUND_HEIGHT,
+      g_param_spec_int ("background-h", "Height", "Height of the background",
+          0, G_MAXINT, 0,
+          G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
+
 /* TODO: Replace background property static enum with rgb boxed array */
 #if 0
   g_object_class_install_property (gobject_class, PROP_BACKGROUND,
@@ -1457,6 +1485,8 @@ gst_nvcompositor_init (GstNvCompositor * nvcomp)
   nvcomp->bg.g = 0;
   nvcomp->bg.b = 0;
   nvcomp->pool = NULL;
+  nvcomp->bg_width = 0;
+  nvcomp->bg_height = 0;
 }
 
 /* NvCompositor Element registration */
diff --git a/gst-nvcompositor/gstnvcompositor.h b/gst-nvcompositor/gstnvcompositor.h
index 60caa5c..90ad042 100644
--- a/gst-nvcompositor/gstnvcompositor.h
+++ b/gst-nvcompositor/gstnvcompositor.h
@@ -114,6 +114,8 @@ struct _GstNvCompositor
 
   GstNvCompBgcolor bg;
   GstNvCompositorBackground background;
+  gint bg_width;
+  gint bg_height;
 
   gboolean nvcomppool;
   GstBufferPool *pool;

And rebuild/replace the prebuilt lib. So that you can set background width and height. Please set the properties and try again.

Here is a related topic for reference:
Gstreamer using nvcomposer to filesink hangs, but nvcomposer to nvoverlaysink works fine - #19 by DaneLLL