GRAY8 source with nvvidconv and nvv4l2h264enc produces video with wrong color format (washed out)

Hello , I am on r32.7 release, this is pipeline i am debugging on

videotestsrc ! 'video/x-raw, format=(string)GRAY8, width=(int)1920, height=(int)1080' ! nvvidconv ! nvv4l2h264enc ! h264parse ! matroskamux ! filesink location=video.mkv

Resulting video should have proper B/W levels, but instead it is washed out like this :

What to do to fix it? Currently it is our last “blocker” and we are about to go in production next week . Any help would be greatly appreciated.

Tested on jetson nano dev kit

cat /etc/nv_tegra_release 
# R32 (release), REVISION: 7.2, GCID: 30192233, BOARD: t210ref, EABI: aarch64, DATE: Wed Apr 20 21:34:48 UTC 2022

Hi,
The result seems correct. Do you have expected image for reference?

Sure, this is correct : (its standard SMPTE 100% color bars from videotestsrc element)

Using this pipeline works

gst-launch-1.0 videotestsrc ! 'video/x-raw, format=(string)GRAY8, width=(int)1920, height=(int)1080' ! videoconvert ! 'video/x-raw, format=(string)I420' ! nvvidconv ! nvv4l2h264enc ! h264parse ! matroskamux ! filesink location=video.mkv

in other words using videoconvert element to get it from gray8 to i420 .

Did you guys deprecated it somehow?

I am very confident it was working in previous releases.

Using software conversion with videoconvert element is very expensive (costs about 0.5 CPU on jetson nano) , while using nvvidconv only consumes about 0.2 CPU.

Any help would be greatly appreciated

Hi,
It looks fine to use videoconvert plugin for the conversion. Since nvvidconv plugin is open source, please download and check source code if you would like to make further improvement. The source code is in
https://developer.nvidia.com/embedded/linux-tegra-r3272

L4T Driver Package (BSP) Sources

Thank you @DaneLLL unfortunatelly we have no team who is able to understand the source coude, nor fix it.

Is there a possibility that you guys will have an eye on this?

Since I showed you that nvvidconv has problem with color conversion from gray, i would suggest to classify it as a bug at least .

Thank you very much in advance

Hi,
Since the plugins are open source, it would be great if you can take a look.

Using videoconvert plugin looks to be a valid solution.

Hi,
Please apply this patch and rebuild libgstnvvidconv.so for a try:

@@ -3191,6 +3191,8 @@ gst_nvvconv_transform (GstBaseTransform * btrans, GstBuffer * inbuf,
             input_params.height = GST_ROUND_UP_2 (space->from_height);
             input_params.layout = NvBufferLayout_Pitch;
             input_params.colorFormat = space->in_pix_fmt;
+            if (input_params.colorFormat == NvBufferColorFormat_GRAY8)
+              input_params.colorFormat = NvBufferColorFormat_YUV420;
             input_params.payloadType = NvBufferPayload_SurfArray;
             input_params.nvbuf_tag = NvBufferTag_VIDEO_CONVERT;
 
@@ -3211,6 +3213,16 @@ gst_nvvconv_transform (GstBaseTransform * btrans, GstBuffer * inbuf,
             goto done;
           }
 
+if ((space->in_pix_fmt == NvBufferColorFormat_GRAY8) &&
+  (space->out_pix_fmt == NvBufferColorFormat_YUV420)) {
+  ret = gst_nvvconv_do_clearchroma (space, space->interbuf.idmabuf_fd);
+  if (ret != TRUE) {
+    GST_ERROR ("%s: Clear chroma failed \n", __func__);
+    flow_ret = GST_FLOW_ERROR;
+    goto done;
+  }
+}
+
           retn = NvBufferTransform (space->interbuf.idmabuf_fd, omem->buf->dmabuf_fd, &space->transform_params);
           if (retn != 0) {
             g_print ("%s: NvBufferTransform Failed \n", __func__);
@@ -3218,15 +3230,6 @@ gst_nvvconv_transform (GstBaseTransform * btrans, GstBuffer * inbuf,
             goto done;
           }
 
-          if ((space->in_pix_fmt == NvBufferColorFormat_GRAY8) &&
-              (space->out_pix_fmt == NvBufferColorFormat_YUV420)) {
-            ret = gst_nvvconv_do_clearchroma (space, omem->buf->dmabuf_fd);
-            if (ret != TRUE) {
-              GST_ERROR ("%s: Clear chroma failed \n", __func__);
-              flow_ret = GST_FLOW_ERROR;
-              goto done;
-              }
-          }
         } else {
           ret = gst_nvvconv_do_raw2nvconv (space, inmap.data, omem->buf->dmabuf_fd);
           if (ret != TRUE) {

thanks! i will try and let you know

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.