How to create loopback device for nvcamerasrc for TX1?

Hi, may I know is that possible to have somethings similar to v4l2loopback for nvcamerasrc?

hello leong,

we did not tried this before, may i know did you able to create an additional video device by v4l2loopback on TX1 yet?
if yes, please share the device information by v4l2-ctl, thanks

v4l2-ctl -d /dev/videoX -l

hello leong,

FYI, the nvcamerasrc is the only supported gstreamer component for CSI camera.

since without actual hw connected, the loopback device you created would be regard as a USB camera.
you should use v4l2src to access it instead. thanks

gst-launch-1.0 v4l2src device="/dev/video1" ! "video/x-raw,width=640,height=480,format=I420" ! nvoverlaysink

hello JerryChang,

I managed to create multiple v4l2loopback device by using the v4l2loopback module from this link https://github.com/umlaeute/v4l2loopback

But I failed to get the video stream from the v4l2loopback device.

The Gstreamer pipeline that I used to pass video stream from USB camera to v4l2loopback device can work on Intel platform but failed to work on either TK1 or TX1.

Thanks

hello leong,

had you done the necessary setup here: https://github.com/umlaeute/v4l2loopback ?

i’ll suggest you to lower the fps, input a timeout image to confirm your loopback node works.

v4l2loopback-ctl set-fps 1 /dev/videoX
v4l2loopback-ctl set-timeout-image test.jpg /dev/videoX

Hi leong

Have you managed get the video stream from the v4l2loopback device?
Any further suggestion required?

Thanks

Hi Kayccc and JerryChang,

we created a v4l2loopback with the following modprobe command:
sudo modprobe v4l2loopback devices=1

a device /dev/video3 is then created.

we set the FPS to 1
ubuntu@tegra-ubuntu:~/Pictures$ sudo v4l2loopback-ctl set-fps 1 /dev/video3
OK

and then set the timeout image (snap.jpg) as follow:
ubuntu@tegra-ubuntu:~/Pictures$ sudo v4l2loopback-ctl set-timeout-image snap.jpg /dev/video3
Reading from file:///home/ubuntu/Pictures/snap.jpg
Setting pipeline to PAUSED …
Pipeline is PREROLLING …
Pipeline is PREROLLED …
Setting pipeline to PLAYING …
New clock: GstSystemClock
ERROR: from element /GstPipeline:pipeline0/GstIdentity:identity0: Failed after iterations as requested.
Additional debug info:
gstidentity.c(659): gst_identity_transform_ip (): /GstPipeline:pipeline0/GstIdentity:identity0
Execution ended after 0:00:00.003276667
Setting pipeline to PAUSED …
Setting pipeline to READY …

(gst-launch-1.0:2928): GStreamer-CRITICAL **: gst_object_unref: assertion ‘((GObject *) object)->ref_count > 0’ failed
Setting pipeline to NULL …
Freeing pipeline …
timeout: 3000

we use gst-launch-1.0 to sink from /dev/video0 (Logitech USB Webcam c930e) to the created loopback /dev/video3

ubuntu@tegra-ubuntu:~/Pictures$ gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw, format=I420, framerate=30/1, width=640, height=480 ! v4l2sink device=/dev/video3
Setting pipeline to PAUSED …
libv4l2: error getting pixformat: Invalid argument
Pipeline is live and does not need PREROLL …
Setting pipeline to PLAYING …
New clock: GstSystemClock

we then use gst-launch-1.0 to open the loopback /dev/video3

ubuntu@tegra-ubuntu:~$ gst-launch-1.0 v4l2src device=/dev/video3 ! video/x-raw, format=I420, framerate=30/1, width=640, height=480 ! xvimagesink
Setting pipeline to PAUSED …
Pipeline is live and does not need PREROLL …
Setting pipeline to PLAYING …
New clock: GstSystemClock
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data flow error.
Additional debug info:
gstbasesrc.c(2948): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
streaming task paused, reason not-negotiated (-4)
Execution ended after 0:00:00.001606354
Setting pipeline to PAUSED …
Setting pipeline to READY …
Setting pipeline to NULL …
Freeing pipeline …

Please advice how we should proceed on this?

P.S: guvcview (Guvcview version 2.0.2) has no problem to open the loopback /dev/video3 BTW.

gst-launch-1.0 --version
gst-launch-1.0 version 1.8.1
GStreamer 1.8.2
https://launchpad.net/distros/ubuntu/+source/gstreamer1.0

hello leong,

could you please try using the nvoverlaysink for your loopback device?

for example.
sink the usb-camera frame buffer to your loopback node at 1st terminal

gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw, format=I420, framerate=30/1, width=640, height=480 ! v4l2sink device=/dev/video3

launch the preview to show loopback device at 2nd terminal

gst-launch-1.0 v4l2src device=/dev/video3 ! video/x-raw, format=I420, width=640, height=480 ! nvoverlaysink

Hi JerryChang,

The FPS is set to 1
ubuntu@tegra-ubuntu:~$ sudo v4l2loopback-ctl set-fps 1 /dev/video3
OK

At 1st terminal,
ubuntu@tegra-ubuntu:~/Pictures$ gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw, format=I420, framerate=30/1, width=640, height=480 ! v4l2sink device=/dev/video3
Setting pipeline to PAUSED …
libv4l2: error getting pixformat: Invalid argument
Pipeline is live and does not need PREROLL …
Setting pipeline to PLAYING …
New clock: GstSystemClock

At 2nd terminal,
ubuntu@tegra-ubuntu:~$ gst-launch-1.0 v4l2src device=/dev/video3 ! video/x-raw, format=I420, width=640, height=480 ! nvoverlaysink
Setting pipeline to PAUSED …
Inside NvxLiteH264DecoderLowLatencyInitNvxLiteH264DecoderLowLatencyInit set DPB and MjstreamingInside NvxLiteH265DecoderLowLatencyInitNvxLiteH265DecoderLowLatencyInit set DPB and MjstreamingPipeline is live and does not need PREROLL …
Setting pipeline to PLAYING …
New clock: GstSystemClock
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Failed to allocate a buffer
Additional debug info:
gstv4l2src.c(884): gst_v4l2src_create (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0
Execution ended after 0:00:01.008322760
Setting pipeline to PAUSED …
Setting pipeline to READY …
Setting pipeline to NULL …
Freeing pipeline …

It only shows one frame and then terminated.

Is there anythings else we should test?

hello leong,

could you please try to reproduce this issue on desktop instead?

Hi JerryChang,

I tried reproduce this issue using laptop with processor Intel Core i5-4200U CPU@1.60GHz x 4

I had tested with Ubuntu 14.04 LTS, Ubuntu 15.10, and Ubuntu 16.04 LTS but I only managed to get the video stream from the v4l2loopback device by using Ubuntu 15.10.

The procedure to reproduce this issue is as follow:
A USB webcam (Logitech c930e) is connected to laptop and refer as /dev/video0
ubuntu@ubuntu:~/Downloads/v4l2loopback$ ls /dev/video*
/dev/video0

A v4l2loopback device is created with the following modprobe command:
ubuntu@ubuntu:~/Downloads/v4l2loopback$ sudo modprobe v4l2loopback device=1

The loopback device is refer as /dev/video1
ubuntu@ubuntu:~/Downloads/v4l2loopback$ ls /dev/video*
/dev/video0 /dev/video1

For ubuntu 14.04.05 LTS
ubuntu@ubuntu:~/Downloads/v4l2loopback$ uname -a
Linux ubuntu 4.4.0-31-generic #50~14.04.1-Ubuntu SMP Wed Jul 13 01:07:32 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

ubuntu@ubuntu:~/Downloads/v4l2loopback$ gst-launch-1.0 --version
gst-launch-1.0 version 1.2.4
GStreamer 1.2.4
https://launchpad.net/distros/ubuntu/+source/gstreamer1.0

At 1st terminal
ubuntu@ubuntu:~/Downloads/v4l2loopback$ gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw, format=I420, framerate=30/1, width=640, height=480 ! v4l2sink device=/dev/video1
Setting pipeline to PAUSED …
libv4l2: error getting pixformat: Invalid argument
Pipeline is live and does not need PREROLL …
Setting pipeline to PLAYING …
New clock: GstSystemClock

At 2nd terminal
ubuntu@ubuntu:~$ gst-launch-1.0 v4l2src device=/dev/video1 ! video/x-raw, format=I420, framerate=30/1, width=640, height=480 ! videoconvert ! xvimagesink sync=false
Setting pipeline to PAUSED …
Pipeline is live and does not need PREROLL …
Setting pipeline to PLAYING …
New clock: GstSystemClock
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data flow error.
Additional debug info:
gstbasesrc.c(2865): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
streaming task paused, reason error (-5)
Execution ended after 0:00:00.028176082
Setting pipeline to PAUSED …
Setting pipeline to READY …
Setting pipeline to NULL …
Freeing pipeline …

For Ubuntu 15.10
ubuntu@ubuntu:~$ uname -a
Linux ubuntu 4.2.0-16-generic #19-Ubuntu SMP Thu Oct 8 15:35:06 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

ubuntu@ubuntu:~$ gst-launch-1.0 --version
gst-launch-1.0 version 1.6.0
GStreamer 1.6.3
https://launchpad.net/distros/ubuntu/+source/gstreamer1.0

At 1st terminal
ubuntu@ubuntu:~$ gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw, format=I420, framerate=30/1, width=640, height=480 ! v4l2sink device=/dev/video1
Setting pipeline to PAUSED …
libv4l2: error getting pixformat: Invalid argument
Pipeline is live and does not need PREROLL …
Setting pipeline to PLAYING …
New clock: GstSystemClock

At 2nd terminal
ubuntu@ubuntu:~$ gst-launch-1.0 v4l2src device=/dev/video1 ! video/x-raw, format=I420, framerate=30/1, width=640, height=480 ! videoconvert ! xvimagesink sync=false
Setting pipeline to PAUSED …
Pipeline is live and does not need PREROLL …
Setting pipeline to PLAYING …
New clock: GstSystemClock
^Chandling interrupt.
Interrupt: Stopping pipeline …
Execution ended after 0:00:03.668339317
Setting pipeline to PAUSED …
Setting pipeline to READY …
Setting pipeline to NULL …
Freeing pipeline …

For Ubuntu 16.04 LTS
ubuntu@ubuntu:~$ uname -a
Linux ubuntu 4.4.0-31-generic #50-Ubuntu SMP Wed Jul 13 00:07:12 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

ubuntu@ubuntu:~$ gst-launch-1.0 --version
gst-launch-1.0 version 1.8.2
GStreamer 1.8.2
https://launchpad.net/distros/ubuntu/+source/gstreamer1.0

At 1st terminal
ubuntu@ubuntu:~$ gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw, format=I420, framerate=30/1, width=640, height=480 ! v4l2sink device=/dev/video1
Setting pipeline to PAUSED …
libv4l2: error getting pixformat: Invalid argument
Pipeline is live and does not need PREROLL …
Setting pipeline to PLAYING …
New clock: GstSystemClock

At 2nd terminal
ubuntu@ubuntu:~$ gst-launch-1.0 v4l2src device=/dev/video1 ! video/x-raw, format=I420, framerate=30/1, width=640, height=480 ! videoconvert ! xvimagesink sync=false
Setting pipeline to PAUSED …
Pipeline is live and does not need PREROLL …
Setting pipeline to PLAYING …
New clock: GstSystemClock
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Failed to allocate a buffer
Additional debug info:
gstv4l2src.c(884): gst_v4l2src_create (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0
Execution ended after 0:00:00.032129266
Setting pipeline to PAUSED …
Setting pipeline to READY …
Setting pipeline to NULL …
Freeing pipeline …

P.S: guvcview has no problem to open the v4l2loopback device /dev/video1 in Ubuntu 14.04 LTS, Ubuntu 15.10, and Ubuntu 16.04 LTS

hello leong,

this should be the bugs about the v4l2src, which did not own by NV side.

you can also add –gst-debug-level to gather more information from v4l2src.
for example.

gst-launch-1.0 --gst-debug-level=2 -v v4l2src device=/dev/video1 ! "video/x-raw, width=640, height=480, format=I420" ! autovideosink

Hi JerryChang,

The issue solved after I downgrade the v4l2loopback module from version 0.10 to 0.9.

I shall try:

sudo apt-get install v4l2loopback-dkms

return is:

Unpacking v4l2loopback-dkms (0.9.1-4) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up dkms (2.2.0.3-2ubuntu11.3) ...
Setting up v4l2loopback-dkms (0.9.1-4) ...
Loading new v4l2loopback-0.9.1 DKMS files...
First Installation: checking all kernels...
dpkg: warning: version '*-*' has bad syntax: version number does not start with digit
It is likely that 4.4.15-tegra belongs to a chroot's host
Building initial module for 4.4.15-tegra
ERROR (dkms apport): kernel package linux-headers-4.4.15-tegra is not supported
Error! Bad return status for module build on kernel: 4.4.15-tegra (aarch64)
Consult /var/lib/dkms/v4l2loopback/0.9.1/build/make.log for more information.

Perhaps github distribution shall be used.

neither it successfully performs make command at once, as it seems to me

@leong: could you describe the method to install the v4l2loopback from the github, please?

Hi Andrey1984,

The v4l2loopback driver is a third party driver and need to be build with the Board Support Package (BSP) if you are using a custom kernal Image.

Are you using the carrier board from Nvidia or from other company? Different company will have their own custom kernel Image for TX1. The overall idea is you need to build the “v4l2loopback.c” file within the custom kernel Image to produce the “v4l2loopback.ko” file.

In general,

  1. You need to copy paste the “v4l2loopback.c” file under the source “/drivers/misc” directory
  2. Edit the drivers/misc/Makefile file
  3. Add the entry “obj-m +=v4l2loopback.o”
  4. Then build the modules “make modules”
  5. Now the modules “v4l2loopback.ko” will be built
  6. Copy paste the “v4l2loopback.ko” to the TX1 carrier board and using insmod you can insert the "“v4l2loopback.ko” module

Please refer to the guideline provided by the manufacture of Board Support Package to build the v4l2loopback driver, if any.

Hi leong,
Thank you for your response.

I am using the default devboard by nvidia [tx2] with the onboard camera , and I am trying to achieve some extended functionality : like to use it with skype or with guvcview.

I shall try the “in general” model, as it seems to me.

Thanks
Andrey

when you say|:
“1. You need to copy paste the “v4l2loopback.c” file under the source “/drivers/misc” directory”

do you refer to the Jetpack /drivers/misc source folder which is located at Host OS or the “/driver/misc” folder is supposed to be located into the source of the v4l2loopback ,or some other source is meant?

Could you explain, what is the source "/driver/misc/ directory and where to locate it, please?

it seems that you refer to the source folder located at Host OS.
Thanks