umlaeute / v4l2loopback

v4l2-loopback device
GNU General Public License v2.0
3.69k stars 523 forks source link

Error when using nvv4l2camerasrc to get data from a virtual device created by v4l2loopback #544

Closed tunghason closed 1 year ago

tunghason commented 1 year ago

Hi, I get errors when using nvv4l2camerasrc plugin to get data from a virtual device created by v4l2loopback.

My environment

Describe the problem:

Steps to reproduce:

  1. Create virtual devices:
     sudo modprove v4l2loopback devices=2
  2. Clone the data stream:
     gst-launch-1.0 nvv4l2camerasrc device=/dev/video0 ! 'video/x-raw(memory:NVMM), format=UYVY' \
        ! nvvidconv ! identity drop-allocation=true ! queue ! v4l2sink device=/dev/video2
  3. Get data from the virtual device /dev/video2 using nvv4l2camerasrc:
     gst-launch-1.0 nvv4l2camerasrc device=/dev/video2 ! 'video/x-raw(memory:NVMM), format=UYVY' \
        ! nvvideoconvert ! fpsdisplaysink video-sink=fakesink --verbose

Observed Results:

image

Expected Results:

umlaeute commented 1 year ago

does it still happen with current main (5eaff75d98e4695ce87db756e3fa4d81a657d785)?

tunghason commented 1 year ago

Yeah, if I build at main branch, it still happen. And one more issue at main branch is that I can not use nvv4l2camerasrc to clone data stream anymore, I must use v4l2src in this command below to clone data stream:

gst-launch-1.0 v4l2src device=/dev/video0 ! 'video/x-raw, format=UYVY' ! queue ! v4l2sink device=/dev/video2
tunghason commented 1 year ago

Hello @umlaeute, is this still in progress ? Is there any chance to use nvv4l2camerasrc to get data from loopback devices ?

umlaeute commented 1 year ago

i don't have a tegra-hardware, so I cannot test (nor solve) the issue. so: no, there's no active pursuit of this issue (from my side).

in any case: try adding tee and/or queue elements (they often take care of sync-problems between gst-elements).

apart from that: why do you need to access the loopback device with nvv4l2camerasrc instead of the normal v4l2src? due to the nature of the loopback device, i'm not sure whether it will give you any performance improvements...

tunghason commented 1 year ago

Ok, thank you. About "why need nvv4l2camerasrc", I've tested nvv4l2camerasrc on the source device (/dev/video0), and I see that nvv4l2camerasrc is better than v4l2src in the aspect of speed and CPU usage, so I expect I will get the same effect on virtual devices, too.

umlaeute commented 1 year ago

i did a quick google-check and found this:

The nvv4l2camerasrc plugin default currently supports only DMABUF (importer role) streaming I/O mode with V4L2_MEMORY_DMABUF.

the v4l2loopback device currently only supports V4L2_MEMORY_MMAP, so that might explain why it's not working.

i'm therefore closing this as a duplicate of https://github.com/umlaeute/v4l2loopback/issues/501 (in case you wonder: https://github.com/umlaeute/v4l2loopback/issues/501 is about the underlying issue, whereas this bug-report is about a symptom; hence i'm closing this one in favour of the other)