Gstreamer and v4l2loopback

In a jetson nano, I’ve created a video loopback device with the command:

modprobe v4l2loopback exclusive_caps=1

and try to send to this device the result of decode an mp4 file, using the nvv4l2decoder element for gstreamer:

gst-launch-1.0 -v filesrc location=test.mp4 ! qtdemux ! h264parse ! nvv4l2decoder ! nvvidconv ! video/x-raw, format=I420 ! v4l2sink device=/dev/video0

however, it crashes with error:

Setting pipeline to PAUSED …
Opening in BLOCKING MODE
Caught SIGSEGV
#0 0x0000007faf08bd5c in __waitpid (pid=, stat_loc=0x7ffb0bb814, options=) at …/sysdeps/unix/sysv/linux/waitpid.c:30
#1 0x0000007faf0c72a0 in g_on_error_stack_trace ()
#2 0x0000005590279c3c in ()
#3 0x0000000000008600 in ()
Spinning. Please run ‘gdb gst-launch-1.0 15159’ to continue debugging, Ctrl-C to quit, or Ctrl-\ to dump core.

any hint ?

I’ve checked with a simple video producer:

gst-launch-1.0 -v videotestsrc ! v4l2sink device=/dev/video0

and consumer:

gst-launch-1.0 -v v4l2src device=/dev/video0 ! xvimagesink

and result is ok, a window with the video appears.

====

Additional info 1:

The complete call stack, as show by gdb is:

$ gdb gst-launch-1.0

(gdb) run -v filesrc location=test.mp4 qtdemux ! h264parse ! nvv4l2decoder ! nvvidconv ! videoconvert ! ‘video/x-raw, format=I420’ ! identity drop-allocation=true ! v4l2sink device=/dev/video0
Starting program: /usr/bin/gst-launch-1.0 -v filesrc location=test.mp4 qtdemux ! h264parse ! nvv4l2decoder ! nvvidconv ! videoconvert ! ‘video/x-raw, format=I420’ ! identity drop-allocation=true ! v4l2sink device=/dev/video0
[Thread debugging using libthread_db enabled]
Using host libthread_db library “/lib/aarch64-linux-gnu/libthread_db.so.1”.
Setting pipeline to PAUSED …
Opening in BLOCKING MODE
[New Thread 0x7fb19161f0 (LWP 8394)]

Thread 1 “gst-launch-1.0” received signal SIGSEGV, Segmentation fault.
0x0000007fb4e49090 in ?? ()
from /usr/lib/aarch64-linux-gnu/libv4l/plugins/nv/libv4l2_nvargus.so
(gdb) bt
#0 0x0000007fb4e49090 in ()
at /usr/lib/aarch64-linux-gnu/libv4l/plugins/nv/libv4l2_nvargus.so
#1 0x0000007fb4e49f9c in ()
at /usr/lib/aarch64-linux-gnu/libv4l/plugins/nv/libv4l2_nvargus.so
#2 0x0000007fb4e488f8 in ()
at /usr/lib/aarch64-linux-gnu/libv4l/plugins/nv/libv4l2_nvargus.so
#3 0x0000007fb4e486b8 in ()
at /usr/lib/aarch64-linux-gnu/libv4l/plugins/nv/libv4l2_nvargus.so
#4 0x0000007fb7017b20 in () at /usr/lib/aarch64-linux-gnu/libv4l2.so.0
#5 0x0000007fb70136c0 in v4l2_fd_open ()
at /usr/lib/aarch64-linux-gnu/libv4l2.so.0
#6 0x0000007fb4f2463c in ()
at /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstvideo4linux2.so
#7 0x0000005555851b90 in ()
(gdb)

====

Additional info 2:

The result of v4l2-ctl after install module is:

$ v4l2-ctl -d /dev/video0 --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.201
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 : 0/0
Pixel Format : ‘BGR4’
Field : None
Bytes per Line : 0
Size Image : 0
Colorspace : sRGB
Transfer Function : Default (maps to sRGB)
YCbCr/HSV Encoding: Default (maps to ITU-R 601)
Quantization : Default (maps to Full 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

You would use identity drop-allocation=true before v4l2sink such as:

gst-launch-1.0 -v filesrc location=test.mp4 ! qtdemux ! h264parse ! nvv4l2decoder ! nvvidconv ! video/x-raw, format=I420 !  identity drop-allocation=true ! v4l2sink device=/dev/video0

Be sure that the v4l2loopback node is really /dev/video0. It may only happen if having no video device.

1 Like

Thanks for your interest in the issue.

After reboot, I can check /dev/video* doesn’t exist:

# ls -l /dev/video*
ls: cannot access ‘/dev/video*’: No such file or directory

and it is created after module load:

# modprobe v4l2loopback exclusive_caps=1
# ls -l /dev/video*
crw-rw----+ 1 root video 81, 0 abr 14 23:59 /dev/video0

thus, I conclude the correct device is /dev/video0

Trying with the command you suggest, same error happens:

$ gst-launch-1.0 -v filesrc location=test.mp4 qtdemux ! h264parse ! nvv4l2decoder ! nvvidconv ! videoconvert ! ‘video/x-raw, format=I420’ ! identity drop-allocation=true ! v4l2sink device=/dev/video0
Setting pipeline to PAUSED …
Opening in BLOCKING MODE
Caught SIGSEGV
#0 0x0000007fb59f2d5c in __waitpid (pid=, stat_loc=0x7fd721bb24, options=) at …/sysdeps/unix/sysv/linux/waitpid.c:30
#1 0x0000007fb5a2e2a0 in g_on_error_stack_trace ()
#2 0x000000555f253c3c in ()
#3 0x0000000000008600 in ()
Spinning. Please run ‘gdb gst-launch-1.0 7928’ to continue debugging, Ctrl-C to quit, or Ctrl-\ to dump core.

have you tested it ?

Hi,
Please check if it works with avdec_h264. See if it is specific to using nvv4l2decoder.

Hi,

Thanks for your support.

The following video producer:

gst-launch-1.0 -v filesrc location=test.mp4 ! qtdemux ! h264parse ! avdec_h264 ! videoconvert ! v4l2sink device=/dev/video0

doesn’t crash and its video can be correctly seen with the consumer:

gst-launch-1.0 -v v4l2src device=/dev/video0 ! xvimagesink

Problem seems related to usage of nvXXX elements together with v4l2sink and/or v4l2loopback.

As workaround, I’ve removed the softlink /usr/lib/aarch64-linux-gnu/libv4l/plugins/nv/libv4l2_nvargus.so and the crash disappears, no SIGSEGV.

1 Like

Thanks for sharing, this is good information.
I had not tested as I was away from any Jetson, but now for NVIDIA reference with a reproducible scenario, I see the same on Xavier NX running R32.5.1, with a /dev/video2 v4l2loopback (dkms 0.10.0) device:

gst-launch-1.0 -v filesrc location=/home/nvidia/Videos/Big_Buck_Bunny_1080_10s_30MB.mp4 ! qtdemux ! h264parse ! nvv4l2decoder ! nvvidconv ! video/x-raw, format=BGRx ! identity drop-allocation=true ! v4l2sink device=/dev/video2 
Setting pipeline to PAUSED ...
Opening in BLOCKING MODE
Available Sensor modes :
Resolution: 3264 x 2464 ; Framerate = 21,000000; Analog Gain Range Min 1,000000, Max 10,625000, Exposure Range Min 13000, Max 683709000

Resolution: 3264 x 1848 ; Framerate = 28,000001; Analog Gain Range Min 1,000000, Max 10,625000, Exposure Range Min 13000, Max 683709000

Resolution: 1920 x 1080 ; Framerate = 29,999999; Analog Gain Range Min 1,000000, Max 10,625000, Exposure Range Min 13000, Max 683709000

Resolution: 1640 x 1232 ; Framerate = 29,999999; Analog Gain Range Min 1,000000, Max 10,625000, Exposure Range Min 13000, Max 683709000

Resolution: 1280 x 720 ; Framerate = 59,999999; Analog Gain Range Min 1,000000, Max 10,625000, Exposure Range Min 13000, Max 683709000

ERROR: Pipeline doesn't want to pause.
ERROR: from element /GstPipeline:pipeline0/GstV4l2Sink:v4l2sink0: Device '/dev/video2' is not a output device.
Additional debug info:
v4l2_calls.c(639): gst_v4l2_open (): /GstPipeline:pipeline0/GstV4l2Sink:v4l2sink0:
Capabilities: 0x4201000
Setting pipeline to NULL ...
Freeing pipeline ...

and after removing it, works fine:

sudo mv /usr/lib/aarch64-linux-gnu/libv4l/plugins/nv/libv4l2_nvargus.so /usr/lib/aarch64-linux-gnu/libv4l/plugins/nv/libv4l2_nvargus.so.disabled

gst-launch-1.0 -v filesrc location=/home/nvidia/Videos/Big_Buck_Bunny_1080_10s_30MB.mp4 ! qtdemux ! h264parse ! nvv4l2decoder ! nvvidconv ! video/x-raw, format=BGRx ! identity drop-allocation=true ! v4l2sink device=/dev/video2 
Setting pipeline to PAUSED ...
Opening in BLOCKING MODE 
Opening in BLOCKING MODE 
Pipeline is PREROLLING ...
/GstPipeline:pipeline0/GstH264Parse:h264parse0.GstPad:sink: caps = video/x-h264, stream-format=(string)avc, alignment=(string)au, level=(string)5.1, profile=(string)high, codec_data=(buffer)01640033ffe1001d67640033ac728440780227e5c044000003000400000300f03c60c6118001000768e84386cb22c0, width=(int)1920, height=(int)1080, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)1/1
/GstPipeline:pipeline0/GstH264Parse:h264parse0.GstPad:src: caps = video/x-h264, stream-format=(string)byte-stream, alignment=(string)au, level=(string)5.1, profile=(string)high, width=(int)1920, height=(int)1080, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive, chroma-format=(string)4:2:0, bit-depth-luma=(uint)8, bit-depth-chroma=(uint)8, parsed=(boolean)true
NvMMLiteOpen : Block : BlockType = 261 
NVMEDIA: Reading vendor.tegra.display-size : status: 6 
NvMMLiteBlockCreate : Block : BlockType = 261 
/GstPipeline:pipeline0/nvv4l2decoder:nvv4l2decoder0.GstPad:sink: caps = video/x-h264, stream-format=(string)byte-stream, alignment=(string)au, level=(string)5.1, profile=(string)high, width=(int)1920, height=(int)1080, framerate=(fraction)30/1, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive, chroma-format=(string)4:2:0, bit-depth-luma=(uint)8, bit-depth-chroma=(uint)8, parsed=(boolean)true
/GstPipeline:pipeline0/nvv4l2decoder:nvv4l2decoder0.GstPad:src: caps = video/x-raw(memory:NVMM), format=(string)NV12, width=(int)1920, height=(int)1080, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, chroma-site=(string)mpeg2, colorimetry=(string)bt709, framerate=(fraction)30/1
/GstPipeline:pipeline0/Gstnvvconv:nvvconv0.GstPad:src: caps = video/x-raw, width=(int)1920, height=(int)1080, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)30/1, format=(string)BGRx, colorimetry=(string)sRGB
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:src: caps = video/x-raw, width=(int)1920, height=(int)1080, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)30/1, format=(string)BGRx, colorimetry=(string)sRGB
/GstPipeline:pipeline0/GstIdentity:identity0.GstPad:src: caps = video/x-raw, width=(int)1920, height=(int)1080, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)30/1, format=(string)BGRx, colorimetry=(string)sRGB
/GstPipeline:pipeline0/GstV4l2Sink:v4l2sink0.GstPad:sink: caps = video/x-raw, width=(int)1920, height=(int)1080, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)30/1, format=(string)BGRx, colorimetry=(string)sRGB
/GstPipeline:pipeline0/GstIdentity:identity0.GstPad:sink: caps = video/x-raw, width=(int)1920, height=(int)1080, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)30/1, format=(string)BGRx, colorimetry=(string)sRGB
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:sink: caps = video/x-raw, width=(int)1920, height=(int)1080, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, framerate=(fraction)30/1, format=(string)BGRx, colorimetry=(string)sRGB
/GstPipeline:pipeline0/Gstnvvconv:nvvconv0.GstPad:sink: caps = video/x-raw(memory:NVMM), format=(string)NV12, width=(int)1920, height=(int)1080, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, chroma-site=(string)mpeg2, colorimetry=(string)bt709, framerate=(fraction)30/1
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock

What would be the limitations if disabling this link ?

1 Like

Thanks, it is very useful to know it is not a problem specific of my system.

About the effects of the workaround, I supose we are disabling all or some physical cameras.

Seems at least argus_camera and gstreamer plugin nvarguscamerasrc still work without. Someone from NVIDIA may further tell.

Hi,
After removing libv4l2_nvargus.so, nvarguscamerasrc should work well.

Could you check if replacing this prebuilt lib helps:
Libv4l2_nvargus.so source code - #19 by JerryChang

1 Like

Thanks Dane for the link. It does work for this case.
However it also results in q4vl no longer working (unless using -R).

Yes, this version of the library fixes the problem.

Thanks a lot.