Issue when try to use v4l2loopback and nvv4l2camerasrc

Hi,
It is fine when I run the pipeline below using nvv4l2camerasrc and /dev/video0:

GST_DEBUG=3 gst-launch-1.0 nvv4l2camerasrc device=/dev/video0 ! 'video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080, framerate=(fraction)30/1, format=(string)UYVY' ! nvvideoconvert ! 'video/x-raw(memory:NVMM), format=(string)NV12' ! fakesink

But when I clone /dev/video0 into /dev/video2 using v4l2sink (like the below command), then running the pipeline again with device=/dev/video2, it will log the errors like the image:

gst-launch-1.0 v4l2src device=/dev/video0 ! 'video/x-raw, width=1920, height=1080, framerate=(fraction)30/1, format=UYVY' ! v4l2sink device=/dev/video2

However, if I use v4l2src instead of nvv4l2camerasrc to get data from the clone /dev/video2, it works fine:

gst-launch-1.0 v4l2src device=/dev/video2 ! 'video/x-raw, width=(int)1920, height=(int)1080, framerate=(fraction)30/1, format=(string)UYVY' ! fakesink

My question: Is there a way to use nvv4l2camerasrc to get data from virtual device created by v4l2loopback ?

For more information, it also logs errors when I try to clone device using nvv4l2camerasrc:

gst-launch-1.0 nvv4l2camerasrc device=/dev/video0 ! 'video/x-raw(memory:NVMM), width=1920, height=1080,framerate=30/1, format=UYVY' ! nvvideoconvert ! identity drop-allocation=true ! v4l2sink device=/dev/video2

What’s the camera type? USB? MIPI CSI YUV sensor?

Hi, it’s MIPI.

Any use case need to fix this finding?

Yeah, I have a pipeline running fine on /dev/video0:

gst-launch-1.0 nvv4l2camerasrc device=/dev/video0 ! 'video/x-raw(memory:NVMM), format=UYVY' ! nvvideoconvert ! 'video/x-raw(memory:NVMM), format=NV12' ! nvv4l2h265enc ! rtph265pay ! udpsink host=127.0.0.1 port=5000

But it will get errors when running on the virtual device /dev/video2 created by v4l2loopback:

Camera’s infor using “v4l2-ctl -d /dev/video0 --list-formats-ext”:
image

I mean why need create virtual device?

I’m not sure. I was told to do that, using nvv4l2camerasrc to get data from a virtual device.
Perhaps he would like to clone /dev/video0 into more virtual devices, one is for streaming and others are for doing something else.

Any reason to use nvv4l2camerasrc instead of v4l2src?

Yeah, nvv4l2camerasrc is a NVIDIA HW accelerated plugin.
In my testing, I see that using nvv4l2camerasrc can reduce the pipeline’s latency and CPU usage.
BTW, are those questions able to help us solve my issue ?

Dose using nvv4l2camerasrc clone virtual device and use v4l2src able work?

Hi,
As I mentioned in the question in 1st post, I could not clone virtual device using nvv4l2camerasrc at that time.
Howerver, I’ve found that I built v4l2loopback at main branch then I rebuilt it at v0.12.7, the latest version, I can clone virtual device using nvv4l2camerasrc now.
And as you say, v4l2src works on the virtual device, but nvv4l2camerasrc doesn’t.
Is there any report that indicates nvv4l2camerasrc can get data from virtual devices created by v4l2loopback ? I’ve searched but couldn’t find one.

Please try simple pipeline of nvv4l2camerasrc to breakdown the problem like below command.

GST_DEBUG=3 gst-launch-1.0 nvv4l2camerasrc device=/dev/video2 ! 'video/x-raw(memory:NVMM), format=UYVY' ! nvvidconv ! fpsdisplaysink video-sink=fakesink --verbose

Hi,
When running the command, I get errors:

Setting pipeline to PAUSED …
Pipeline is live and does not need PREROLL …
0:00:00.193085440 52951 0xaaaad1c6f000 FIXME default gstutils.c:3980:gst_pad_create_stream_id_internal:nvv4l2camerasrc0:src Creating random stream-id, consider implementing a deterministic way of creating a stream-id
0:00:00.194779712 52951 0xaaaad1c6f000 ERROR nvv4l2camerasrc gstnvv4l2camerasrc.cpp:844:gst_nv_v4l2_camera_set_caps: VIDIOC_REQBUFS on /dev/video2 device
0:00:00.194889568 52951 0xaaaad1c6f000 WARN basesrc gstbasesrc.c:3072:gst_base_src_loop: error: Internal data stream error.
0:00:00.194936032 52951 0xaaaad1c6f000 WARN basesrc gstbasesrc.c:3072:gst_base_src_loop: error: streaming stopped, reason not-negotiated (-4)
/GstPipeline:pipeline0/GstFPSDisplaySink:fpsdisplaysink0/GstXvImageSink:xvimagesink0: sync = true
ERROR: from element /GstPipeline:pipeline0/GstNvV4l2CameraSrc:nvv4l2camerasrc0: Internal data stream error.
Additional debug info:
gstbasesrc.c(3072): gst_base_src_loop (): /GstPipeline:pipeline0/GstNvV4l2CameraSrc:nvv4l2camerasrc0:
streaming stopped, reason not-negotiated (-4)
ERROR: pipeline doesn’t want to preroll.
Setting pipeline to NULL …
Freeing pipeline …

Please add identity drop-allocation=1 in server command to try.

gst-launch-1.0 ....... ! identity drop-allocation=1 ! v4l2sink ...
``

Hi,
The command I used already include it:

gst-launch-1.0 nvv4l2camerasrc device=/dev/video0 ! 'video/x-raw(memory:NVMM), format=UYVY' ! nvvideoconvert ! identity drop-allocation=true ! queue ! v4l2sink device=/dev/video2

What’s your release version?
How about change the nvvideoconvert to nvvidconv?

Version details:
• DeepStream Version: 6.1.1
• JetPack Version (valid for Jetson only): 5.0.2
• TensorRT Version: 8.4.1.5
•V4l2loopback: built at v.0.12.7.
Changing nvvideoconvert to nvvidconv doesn’t work, either.

Hi,
nvv4l2camerasrc is not designed for the use-case. It seems invalid to run like:

v4l2src ! ... ! v4l2sink
nvv4l2camerasrc ! ... ! v4l2sink

Since the source is already a v4l2 source, it seems strange to link to v4l2sink. You can simply run the pipeline to get frame data:

gst-launch-1.0 v4l2src device=/dev/video0 ! ...
1 Like

Hi,
So it means that it is not possible to use nvv4l2camerasrc to get data from a virtual device created by v4l2loopback yet, right?
Anw, thank you for your supports.

Not sure, but how did you build your v4l2loopback driver ? Did you try using dkms ?

You may better tell your case…What sensor/connection/driver and use case…there may be other options…