implementation of v4l2loopback for devkit onboard csi camera

Hi Andrey,
Please start a new thread for Xavier.

the below works

cd /usr/src/linux-headers-4.9.108-tegra/kernel-4.9
mkdir v4l2loopback
cd v4l2loopback/
git clone https://github.com/umlaeute/v4l2loopback.git
cd v4l2loopback
make
make install
modprobe v4l2loopback devices=1 video_nr=2 exclusive_caps=1
echo options v4l2loopback devices=1 video_nr=2 exclusive_caps=1 > /etc/modprobe.d/v4l2loopback.conf
echo v4l2loopback > /etc/modules
update-initramfs -u

that works [thx to honey_patoceoul who helped determine that]:

sudo apt-get install v4l-utils
v4l2-ctl -d /dev/video2 --all
Driver Info (not using libv4l2):
	Driver name   : v4l2 loopback
	Card type     : Dummy video device (0x0000)
	Bus info      : platform:v4l2loopback-000
	Driver version: 4.9.108
	Capabilities  : 0x85208002
		Video Output
		Video Memory-to-Memory
		Read/Write
		Streaming
		Extended Pix Format
		Device Capabilities
	Device Caps   : 0x85208002
		Video Output
		Video Memory-to-Memory
		Read/Write
		Streaming
		Extended Pix Format
		Device Capabilities
Priority: 0
Video output: 0 (loopback in)
Format Video Output:
	Width/Height      : 8192/8192
	Pixel Format      : 'YVYU'
	Field             : None
	Bytes per Line    : 16384
	Size Image        : 134217728
	Colorspace        : sRGB
	Transfer Function : Default (maps to sRGB)
	YCbCr/HSV Encoding: Default (maps to ITU-R 601)
	Quantization      : Default (maps to Limited Range)
	Flags             : 
Streaming Parameters Video Capture:
	Frames per second: 30.000 (30/1)
	Read buffers     : 8
Streaming Parameters Video Output:
	Frames per second: 30.000 (30/1)
	Write buffers    : 8

User Controls

                    keep_format 0x0098f900 (bool)   : default=0 value=0
              sustain_framerate 0x0098f901 (bool)   : default=0 value=0
                        timeout 0x0098f902 (int)    : min=0 max=100000 step=1 default=0 value=0
               timeout_image_io 0x0098f903 (bool)   : default=0 value=0

Hi Andrey,
I hit the error:

nvidia@jetson-0422418042113:/usr/src/linux-headers-4.9.108-tegra/kernel/v4l2loopback/v4l2loopback$ make
Building v4l2-loopback driver...
make -C /lib/modules/`uname -r`/build M=/usr/src/linux-headers-4.9.108-tegra/kernel/v4l2loopback/v4l2loopback modules
make[1]: Entering directory '/usr/src/linux-headers-4.9.108-tegra'
  CC [M]  /usr/src/linux-headers-4.9.108-tegra/kernel/v4l2loopback/v4l2loopback/v4l2loopback.o
/bin/sh: 1: scripts/basic/fixdep: Exec format error
scripts/Makefile.build:303: recipe for target '/usr/src/linux-headers-4.9.108-tegra/kernel/v4l2loopback/v4l2loopback/v4l2loopback.o' failed
make[2]: *** [/usr/src/linux-headers-4.9.108-tegra/kernel/v4l2loopback/v4l2loopback/v4l2loopback.o] Error 2
Makefile:1527: recipe for target '_module_/usr/src/linux-headers-4.9.108-tegra/kernel/v4l2loopback/v4l2loopback' failed
make[1]: *** [_module_/usr/src/linux-headers-4.9.108-tegra/kernel/v4l2loopback/v4l2loopback] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.9.108-tegra'
Makefile:42: recipe for target 'v4l2loopback.ko' failed
make: *** [v4l2loopback.ko] Error 2

Do you have idea how to overcome it?

Hi,
Please find in the following topic how to overcome it.
https://devtalk.nvidia.com/default/topic/1042391/is-it-possible-to-build-kernel-module-in-xavier-/

Regards

DaneLLL, r u using 4.1.1 Jetpack release or 4.1?
freshly flashed with 4.1.1 Jetson seems to build modules as per default.
U r using

/usr/src/linux-headers-4.9.108-tegra/kernel/

It succeeds with

/usr/src/linux-headers-4.9.108-tegra/kernel-4.9# make modules_prepare

The latter path exists in 4.1.1 generated filesystem, while the former exists in 4.1 Jetpack generated filesystem, as it seems to me.
Therefore the solution will be :

  1. install Jetpack 4.1.1 and flash a jetson with it
  2. switch to sudo and navigate to /usr/src/linux-headers-4.9.108-tegra/kernel-4.9 and try again (GOTO POST N1).
    Regards,
    Andrei

Hi Andrey,
I am able to probe v4l2loopback with below steps:

$ sudo su
$ apt-get install v4l2loopback-utils
$ cd /usr/src/linux-headers-4.9.108-tegra/kernel/
$ make -C /lib/modules/"$(uname -r)"/build modules_prepare
$ mkdir v4l2loopback
$ cd v4l2loopback
$ git clone https://github.com/umlaeute/v4l2loopback.git
$ cd v4l2loopback
$ make
$ make install
$ modprobe v4l2loopback

And can reproduce the error. Will check and update.

It seems that v4l2loopback version 0.9 may be worth checking , I will check and update.

what works as well is


sudo apt-get install v4l2loopback-dkms v4l2loopback-utils

The issue has been resolved
with help of DaneLLL and Honey_Patouceul.
The solution that will allow to use onboard CSI devkit camera OV5693 as web chat camera for use within Internet Browser is listed below:

sudo su
cd /usr/src/linux-headers-4.9.108-tegra/kernel-4.9
make modules_prepare
mkdir v4l2loopback
git clone https://github.com/umlaeute/v4l2loopback.git v4l2loopback
cd v4l2loopback
make
make install
apt-get install v4l2loopback-dkms v4l2loopback-utils
modprobe v4l2loopback devices=1 video_nr=2 exclusive_caps=1
echo options v4l2loopback devices=1 video_nr=2 exclusive_caps=1 > /etc/modprobe.d/v4l2loopback.conf
echo v4l2loopback > /etc/modules
update-initramfs -u
TERMINAL 1:
gst-launch-1.0 -v nvarguscamerasrc ! 'video/x-raw(memory:NVMM), format=NV12, width=1920, height=1080, framerate=30/1' ! nvvidconv ! 'video/x-raw, width=640, height=480, format=I420, framerate=30/1' ! videoconvert ! identity drop-allocation=1 ! 'video/x-raw, width=640, height=480, format=RGB, framerate=30/1' ! v4l2sink device=/dev/video2
TERMINAL 2:
export DISPLAY=:0
chromium-browser
1 Like

as the issue got resolved, checking the next idea:

wget https://gstreamer.freedesktop.org/src/gstreamer/gstreamer-1.14.4.tar.xz
 tar -xvf gstreamer-1.14.4.tar.xz
cd gstreamer-1.14.4/
./configure --libdir=/usr/lib/arm-linux-gnueabihf/
make
make install

 wget https://gstreamer.freedesktop.org/src/gst-rtsp-server/gst-rtsp-server-1.14.4.tar.xz
tar -xvf gst-rtsp-server-1.14.4.tar.xz 

 cd gst-rtsp-server-1.14.4/
./configure --libdir=/usr/lib/arm-linux-gnueabihf/
checking for GST... no
configure: Requested 'gstreamer-1.0 >= 1.14.4' but version of GStreamer is 1.14.1
configure: error: no gstreamer-1.0 >= 1.14.4 (GStreamer) found

trying other way:

sudo apt-get install libgstrtspserver-1.0 libgstreamer1.0-dev
gcc test-launch.c -o test-launch $(pkg-config --cflags --libs gstreamer-1.0 gstreamer-rtsp-server-1.0)
 ./test-launch "( nvcamerasrc sensor-id=0 ! video/x-raw(memory:NVMM), width=1920, height=1080, framerate=30/1, format=I420 ! nvvidconv flip-method=4 ! video/x-raw, width=720, height=480, framerate=30/1, 
format=I420 ! timeoverlay ! omxh265enc ! rtph265pay name=pay0 pt=96 )"
stream ready at rtsp://127.0.0.1:8554/test

However, outputs are:

gst-launch-1.0 rtspsrc location=rtsp://127.0.0.1:8554/test  ! 'application/x-rtp, media=(string)video' ! decodebin ! videoconvert ! ximagesink
ERROR: pipeline could not be constructed: no element "rtspsrc".
nvidia@jetson-0wert:~/gst-rtsp-server-1.14.4/examples$ vlc
VLC media player 3.0.4 Vetinari (revision 3.0.4-0-gf615db6332)
[00000055af802580] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.
[00000055af890a70] main playlist: playlist is empty
Created new TCP socket 40 for connection
[0000007f50001110] live555 demux error: Failed to connect with rtsp://localhost:8554/test

trying other way:

wget https://gstreamer.freedesktop.org/src/gst-rtsp/gst-rtsp-server-1.14.1.tar.xz
tar -xvf gst-rtsp-server-1.14.1.tar.xz 
./configure --libdir=/usr/lib/arm-linux-gnueabihf/
make
make install
/gst-rtsp-server-1.14.1$ gst-launch-1.0 rtspsrc location=rtsp://127.0.0.1:8554/test  ! 'application/x-rtp, media=(string)video' ! decodebin ! videoconvert ! ximagesink

(gst-plugin-scanner:4252): GStreamer-WARNING **: 04:15:11.681: Failed to load plugin '/usr/lib/arm-linux-gnueabihf/gstreamer-1.0/libgstcoreelements.so': /usr/lib/arm-linux-gnueabihf/gstreamer-1.0/libgstcoreelements.so: undefined symbol: gst_type_find_helper_get_range_full
ERROR: pipeline could not be constructed: no element "rtspsrc".

seems that something [plugins?] are missed

./test-launch "( nvcamerasrc sensor-id=0 ! video/x-raw(memory:NVMM), width=1920, height=1080, framerate=30/1, format=I420 ! nvvidconv flip-method=4 ! video/x-raw, width=720, height=480, framerate=30/1, 
format=I420 ! timeoverlay ! omxh265enc ! rtph265pay name=pay0 pt=96 )"

(gst-plugin-scanner:4264): GStreamer-WARNING **: 04:19:43.324: Failed to load plugin '/usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstopengl.so': /usr/lib/aarch64-linux-gnu/libgbm.so.1: undefined symbol: drmGetDevice2

(gst-plugin-scanner:4264): GStreamer-WARNING **: 04:19:43.426: Failed to load plugin '/usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstkms.so': /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstkms.so: undefined symbol: drmModeGetFB

(gst-plugin-scanner:4264): GStreamer-WARNING **: 04:19:43.628: Failed to load plugin '/usr/lib/aarch64-linux-gnu/gstreamer-1.0/libcluttergst3.so': /usr/lib/aarch64-linux-gnu/libgbm.so.1: undefined symbol: drmGetDevice2

(gst-plugin-scanner:4264): GStreamer-WARNING **: 04:19:43.636: Failed to load plugin '/usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstopenglmixers.so': /usr/lib/aarch64-linux-gnu/libgbm.so.1: undefined symbol: drmGetDevice2
stream ready at rtsp://127.0.0.1:8554/test

and the below causes vlc to crash:

./test-launch "videotestsrc ! omxh265enc ! rtph265pay name=pay0 pt=96"
vlc
VLC media player 3.0.4 Vetinari (revision 3.0.4-0-gf615db6332)
[0000005582a00580] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.
[0000005582a8ea70] main playlist: playlist is empty
Gtk-Message: 04:23:16.017: GtkDialog mapped without a transient parent. This is discouraged.
Created new TCP socket 42 for connection
Bus error (core dumped)

I also see the vlc crash on Xavier, but vlc 2.2.2 Weatherwax on host succeeds to read the rtsp stream from Xavier, so it rather looks related to vlc itself.

./test-launch "nvarguscamerasrc ! video/x-raw(memory:NVMM), format=NV12, width=1920, height=1080, framerate=30/1 ! nvvidconv ! video/x-raw, width=640, height=480, format=NV12, framerate=30/1 ! omxh265enc ! rtph265pay name=pay0 pt=96 config-interval=1"

If you want to display it on Xavier, you can use:

gst-launch-1.0 rtspsrc location=rtsp://127.0.0.1:8554/test ! queue ! decodebin ! videoconvert ! xvimagesink

or, if you really want to see it in vlc on Xavier, using v4l2loopback so that with vlc you’ll open it as video capture device:

gst-launch-1.0 rtspsrc location=rtsp://127.0.0.1:8554/test ! queue ! decodebin ! videoconvert ! v4l2sink device=/dev/video1