How to modify deepstream_sink_bin.c to support rtmp?I get error!

I moidfy sink bin to support rtmp and get a error:

0:00:00.039978927 11816      0x14aec00 INFO        GST_ELEMENT_PADS gstutils.c:1771:gst_element_link_pads_full: trying to link element sink_sub_bin_encoder3:(any) to element flvmux3:(any)
0:00:00.040002566 11816      0x14aec00 INFO        GST_ELEMENT_PADS gstutils.c:1225:gst_element_get_compatible_pad:<flvmux3> Could not find a compatible pad to link to sink_sub_bin_encoder3:src
Segmentation fault (core dumped)

my code like this:

...
  bin->encoder = gst_element_factory_make (NVDS_ELEM_ENC_H264, encode_name);
  bin->flvmux = gst_element_factory_make ("flvmux", flvmux_name);

  bin->sink = gst_element_factory_make ("rtmpsink", elem_name);
  if (!bin->sink) {
    NVGSTDS_ERR_MSG_V ("Failed to create '%s'", elem_name);
    goto done;
  }

  g_object_set (G_OBJECT (bin->sink), "location", "rtmp://127.0.0.1:1935/live/stream2", "sync", FALSE, NULL);
...

   gst_bin_add_many (GST_BIN (bin->bin),
      bin->queue, bin->cap_filter, bin->transform,
      bin->encoder, bin->flvmux, bin->sink, NULL);
  g_print("ready to gst_bin_add_many.....\n");

  NVGSTDS_LINK_ELEMENT (bin->queue, bin->transform);
  NVGSTDS_LINK_ELEMENT (bin->transform, bin->cap_filter);
  NVGSTDS_LINK_ELEMENT (bin->cap_filter, bin->encoder);
  NVGSTDS_LINK_ELEMENT (bin->encoder, bin->flvmux);
  
  NVGSTDS_LINK_ELEMENT (bin->flvmux, bin->sink);

  NVGSTDS_BIN_ADD_GHOST_PAD (bin->bin, bin->queue, "sink");

It’s seem that I can’t link nvv4l2h264enc to flvmux. but I notice that x264enc and link flvmux.when I inspect them ,I found this:

x264enc :


Pad Templates:
  SINK template: 'sink'
    Availability: Always
    Capabilities:
      video/x-raw
              framerate: [ 0/1, 2147483647/1 ]
                  width: [ 16, 2147483647 ]
                 height: [ 16, 2147483647 ]
                 format: { (string)Y444, (string)Y42B, (string)I420, (string)YV12, (string)NV12, (string)Y444_10LE, (string)I422_10LE, (string)I420_10LE }


and  
 nvv4l2h264enc's sink:

Pad Templates:
  SINK template: 'sink'
    Availability: Always
    Capabilities:
      video/x-raw(memory:NVMM)
                  width: [ 1, 2147483647 ]
                 height: [ 1, 2147483647 ]
                 format: { (string)I420, (string)NV12, (string)P010_10LE }
              framerate: [ 0/1, 2147483647/1 ]

How can I modify them to get correct ?

Hi,
Please try ‘nvv4l2h264enc ! h264parse ! flvmux ! rtmpsink’