Nvv4l2h265enc memory leak when changing caps

Hi,
For changing frame rate, please apply the patch and rebuild/replace libgstnvvideo4linux2.so:

diff --git a/gst-v4l2/gstv4l2videoenc.c b/gst-v4l2/gstv4l2videoenc.c
index 1120f93..54b5362 100644
--- a/gst-v4l2/gstv4l2videoenc.c
+++ b/gst-v4l2/gstv4l2videoenc.c
@@ -128,7 +128,8 @@ enum
   PROP_MAX_PERF,
   PROP_IDR_FRAME_INTERVAL,
   PROP_FORCE_INTRA,
-  PROP_FORCE_IDR
+  PROP_FORCE_IDR,
+  PROP_FRATE
 #endif
 };
 
@@ -235,6 +236,20 @@ gst_v4l2_video_enc_set_property_tegra (GObject * object,
       self->peak_bitrate = g_value_get_uint (value);
       break;
 
+    case PROP_FRATE:
+    {
+      struct v4l2_streamparm streamparm;
+      memset (&streamparm, 0x00, sizeof (struct v4l2_streamparm));
+      streamparm.type = self->v4l2output->type;
+      /* Note: V4L2 wants the frame interval, we have the frame rate */
+      streamparm.parm.capture.timeperframe.denominator =
+          gst_value_get_fraction_numerator (value);
+      streamparm.parm.capture.timeperframe.numerator =
+          gst_value_get_fraction_denominator (value);
+      self->v4l2output->ioctl (self->v4l2output->video_fd, VIDIOC_S_PARM, &streamparm);
+      break;
+    }
+
     case PROP_QUANT_RANGE:
       gst_v4l2_video_enc_parse_quantization_range (self,
           g_value_get_string (value));
@@ -418,6 +433,9 @@ gst_v4l2_video_enc_get_property_tegra (GObject * object,
     case PROP_IDR_FRAME_INTERVAL:
       g_value_set_uint (value, self->idrinterval);
       break;
+
+    case PROP_FRATE:
+      break;
 #endif
 
       /* By default read from output */
@@ -1698,6 +1716,14 @@ gst_v4l2_video_enc_class_init (GstV4l2VideoEncClass * klass)
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
           GST_PARAM_MUTABLE_READY));
 
+  g_object_class_install_property (gobject_class, PROP_FRATE,
+      gst_param_spec_fraction ("framerate", "On-the-fly frame rate",
+          "Set frame rate on the fly",
+          0, 1, G_MAXINT, 1,
+          30, 1,
+          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_MUTABLE_PLAYING)
+      );
+
   g_object_class_install_property (gobject_class, PROP_INTRA_FRAME_INTERVAL,
       g_param_spec_uint ("iframeinterval", "Intra Frame interval",
           "Encoding Intra Frame occurance frequency",

And please also apply this:
Memory Leak (Alloc/free mismatch) in Tegra multimedia API (encoder) - #6 by DaneLLL

We don’t support changing resolution in runtime by default. It is not handled and verified. For changing resolution, we would suggest re-initialize the whole pipeline. If you have to enable this use-case, may need to check the source code and see if it is possible to do customization.