(DS 4.0/ Nano) What to put between v4l2src and nvstreammux? Neither nvvideoconvert nor nvvidconv works.

When I do this:

gst-launch-1.0 v4l2src ! nvvidconv ! m.sink_0 nvstreammux name=m width=640 height=360 batch-size=1 ! fakesink

I get:

Setting pipeline to PAUSED …
Pipeline is live and does not need PREROLL …
Setting pipeline to PLAYING …
New clock: GstSystemClock
nvbufsurface: invalid colorFormat 0
nvbufsurface: Error in allocating buffer
Error(-1) in buffer allocation

** (gst-launch-1.0:8226): CRITICAL **: 14:13:13.433: gst_nvds_buffer_pool_alloc_buffer: assertion ‘mem’ failed
ERROR: from element /GstPipeline:pipeline0/GstNvStreamMux:m: Failed to allocate the buffers inside the Nvstreammux output pool
Additional debug info:
/dvs/git/dirty/git-master_linux/deepstream/sdk/src/gst-plugins/gst-nvmultistream/gstnvstreammux.c(565): gst_nvstreammux_alloc_output_buffers (): /GstPipeline:pipeline0/GstNvStreamMux:m
Execution ended after 0:00:00.008727160
Setting pipeline to PAUSED …
Setting pipeline to READY …
Setting pipeline to NULL …
Freeing pipeline …

And when I do this:

gst-launch-1.0 v4l2src ! nvvideoconvert ! m.sink_0 nvstreammux name=m width=640 height=360 batch-size=1 ! fakesink

I get:

Setting pipeline to PAUSED …
Pipeline is live and does not need PREROLL …
Setting pipeline to PLAYING …
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.000113286
Setting pipeline to PAUSED …
Setting pipeline to READY …
Setting pipeline to NULL …
Freeing pipeline …

Hi,
Please refer to

$ gst-launch-1.0 v4l2src device=/dev/video1 num-buffers=300 ! video/x-raw,format=YUY2,width=640,height=360,framerate=30/1 ! videoconvert ! nvvideoconvert ! 'video/x-raw(memory:NVMM),format=NV12' ! m.sink_0 nvstreammux name=m width=640 height=360 batch-size=1 ! fakesink

We run Logitech USB camera outputting frames in YUYV(defined YUY2 in gstreamer). You have to adapt it to your camera.

Reference code is in deepstream_sdk_v4.0_jetson\sources\apps\apps-common\src\deepstream_source_bin.c