Nvv4l2h265enc SliceIntraRefreshInterval

Hi,

I would like to know what is the difference between the iframeinterval and the SliceIntraRefreshInterval properties of the h265 encoder, since both of them seem to output the same frame I-P frame structure, and this does not happen with the h264 encoder.

Here are the pipelines to reproduce:

gst-launch-1.0 videotestsrc num-buffers=100 ! nvvidconv ! nvv4l2h264enc iframeinterval=5 ! h264parse ! filesink location=i-5-frames.h264
gst-launch-1.0 videotestsrc num-buffers=100 ! nvvidconv ! nvv4l2h264enc SliceIntraRefreshInterval=5 ! h264parse ! filesink location=intra-5-frames.h264
gst-launch-1.0 videotestsrc num-buffers=100 ! nvvidconv ! nvv4l2h265enc iframeinterval=5 ! h265parse ! filesink location=i-5-frames.h265
gst-launch-1.0 videotestsrc num-buffers=100 ! nvvidconv ! nvv4l2h265enc SliceIntraRefreshInterval=5 ! h265parse ! filesink location=intra-5-frames.h265

Thanks in advance.

Hi,
idrinterval is interval of IDR frames. SliceIntraRefreshInterval is interval of I frames. IDR and I frames are slightly different.

Hi @DaneLLL ,

Thanks for your answer, but I asked about iframeinterval, not idrinterval. Could you explain the difference between the iframeinterval and SliceIntraRefreshInterval properties or they both do the same?

Hi,
SliceIntraRefreshInterval has to be set along with slice-header-spacing. Please refer to the sample pipeline:

$ gst-launch-1.0 videotestsrc num-buffers=100 pattern=1 ! video/x-raw,width=1920,height=1080 ! nvvidconv ! nvv4l2h264enc slice-header-spacing=900 SliceIntraRefreshInterval=30 iframeinterval=30 idrinterval=60 bitrate=12000000 ! h264parse ! video/x-h264,stream-format=byte-stream ! filesink location=b.h264

However, both SliceIntraRefreshInterval and iframeinterval take effect in the condition. So if you set the two properties to two different values, the interval of I frames may not be fixed. We would suggest set to identical value for avoid confusion.
Without setting slice-header-spacing, SliceIntraRefreshInterval does not take effect.

There is an issue about setting slice-header-spacing. If you would like to run in the mode, please apply the patch and rebuild libgstnvvideo4linux2.so:

diff --git a/gst-v4l2/gstv4l2h264enc.c b/gst-v4l2/gstv4l2h264enc.c
index fe2806c..6a6cfe7 100644
--- a/gst-v4l2/gstv4l2h264enc.c
+++ b/gst-v4l2/gstv4l2h264enc.c
@@ -634,7 +634,11 @@ gst_v4l2_h264_enc_slice_header_spacing (GstV4l2Object * v4l2object,
   struct v4l2_ext_controls ctrls;
   gint ret;
   v4l2_enc_slice_length_param param =
-      { bit_packetization, slice_header_spacing };
+      { V4L2_ENC_SLICE_LENGTH_TYPE_MBLK, slice_header_spacing };
+
+  if (bit_packetization) {
+    param.slice_length_type = V4L2_ENC_SLICE_LENGTH_TYPE_BITS;
+  }
 
   memset (&control, 0, sizeof (control));
   memset (&ctrls, 0, sizeof (ctrls));
diff --git a/gst-v4l2/gstv4l2h265enc.c b/gst-v4l2/gstv4l2h265enc.c
index 3ee6bcd..6ea8c1d 100644
--- a/gst-v4l2/gstv4l2h265enc.c
+++ b/gst-v4l2/gstv4l2h265enc.c
@@ -431,7 +431,11 @@ gst_v4l2_h265_enc_slice_header_spacing (GstV4l2Object * v4l2object,
   struct v4l2_ext_controls ctrls;
   gint ret;
   v4l2_enc_slice_length_param param =
-      { bit_packetization, slice_header_spacing };
+      { V4L2_ENC_SLICE_LENGTH_TYPE_MBLK, slice_header_spacing };
+
+  if (bit_packetization) {
+    param.slice_length_type = V4L2_ENC_SLICE_LENGTH_TYPE_BITS;
+  }
 
   memset (&control, 0, sizeof (control));
   memset (&ctrls, 0, sizeof (ctrls));