How to convert a 16 bit grayscale image to RGB and then stream it over H264

How do I convert the following pipeline:

gst-launch-1.0 -v v4l2src device="/dev/video2" ! queue ! nvvidconv ! 'video/x-raw(memory:NVMM),format=NV12'  ! nvv4l2h264enc maxperf-enable=1 insert-sps-pps=1 idrinterval=1 ! h264parse ! queue ! rtph264pay ! udpsink port=5000 host=192.168.12.187 sync=false

to one that works for grayscale images?

I know I need to convert to an RGB or YUV image and then pass to nvvidconv but the following pipeline gives me negotiation errors:

gst-launch-1.0 -v v4l2src device="/dev/video0" ! video/x-raw,format=GRAY16_LE, width=848, height=480  ! videoconvert ! video/x-raw,format=RGBA, width=848, height=480 ! nvvidconv ! 'video/x-raw(memory:NVMM),format=NV12'  ! nvv4l2h264enc maxperf-enable=1 insert-sps-pps=1 idrinterval=1 ! h264parse ! queue ! rtph264pay ! udpsink port=5000 host=192.168.12.187 sync=false

I get the following errors when GST_DEBUG=2:

0:00:00.326558789 17749   0x55b09932a0 WARN                    v4l2 gstv4l2object.c:2375:gst_v4l2_object_add_interlace_mode:0x55b09492b0 Failed to determine interlace mode
0:00:00.326635301 17749   0x55b09932a0 WARN                    v4l2 gstv4l2object.c:2375:gst_v4l2_object_add_interlace_mode:0x55b09492b0 Failed to determine interlace mode
0:00:00.326676657 17749   0x55b09932a0 WARN                    v4l2 gstv4l2object.c:2375:gst_v4l2_object_add_interlace_mode:0x55b09492b0 Failed to determine interlace mode
0:00:00.326771086 17749   0x55b09932a0 WARN                    v4l2 gstv4l2object.c:4434:gst_v4l2_object_probe_caps:<nvv4l2h264enc0:src> Failed to probe pixel aspect ratio with VIDIOC_CROPCAP: Unknown error -1
Pipeline is live and does not need PREROLL ...
0:00:00.328923066 17749   0x55b0978000 WARN                 basesrc gstbasesrc.c:3055:gst_base_src_loop:<v4l2src0> error: Internal data stream error.
0:00:00.328966505 17749   0x55b0978000 WARN                 basesrc gstbasesrc.c:3055:gst_base_src_loop:<v4l2src0> error: streaming stopped, reason not-negotiated (-4)
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data stream error.
Additional debug info:
gstbasesrc.c(3055): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
streaming stopped, reason not-negotiated (-4)

Hi,
For debugging we suggest break down the gstreamer pipeline. You may run and check if this pipeline works:

gst-launch-1.0 -v v4l2src device="/dev/video0" ! video/x-raw,format=GRAY16_LE, width=848, height=480  ! videoconvert ! video/x-raw,format=RGBA, width=848, height=480 ! fakesink

It does not work

$ GST_DEBUG=2 gst-launch-1.0 -v v4l2src device="/dev/video0" ! video/x-raw,format=GRAY16_LE, width=848, height=480  ! videoconvert ! video/x-raw,format=RGBA, width=848, height=480 ! fakesink
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
0:00:00.229140273 24887   0x559498bde0 WARN                 basesrc gstbasesrc.c:3055:gst_base_src_loop:<v4l2src0> error: Internal data stream error.
0:00:00.229186264 24887   0x559498bde0 WARN                 basesrc gstbasesrc.c:3055:gst_base_src_loop:<v4l2src0> error: streaming stopped, reason not-negotiated (-4)
New clock: GstSystemClock
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data stream error.
Additional debug info:
gstbasesrc.c(3055): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
streaming stopped, reason not-negotiated (-4)
Execution ended after 0:00:00.000301778
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...

Hi,
Looks like the sensor mode is not set correctly. Please run v4l2-ctl to show supported formats and set exact mode to the capability. There are steps for reference in Jetson Nano FAQ
Q: I have a USB camera. How can I launch it on Jetson Nano?

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