Issue with RTSP streaming and decoding to v4l2loopback

I am having some trouble specifically using a loopback device with an RTSP stream.

Both of these video pipelines work (I confirmed each with a video output)

RTSP to screen:
gst-launch-1.0 rtspsrc latency=0 location='rtsp://192.168.1.101:554/user=admin&password=admin123&channel=1&stream=0.sdp?' ! rtph265depay ! queue ! h265parse ! nvv4l2decoder ! nvvidconv ! videoconvert ! autovideosink

RTSP to Loopback with SOFTWARE DECODING:
gst-launch-1.0 rtspsrc latency=0 location='rtsp://192.168.1.101:554/user=admin&password=admin123&channel=1&stream=0.sdp?' ! rtph265depay ! queue ! h265parse ! avdec_h265 ! videoconvert ! v4l2sink device=/dev/video41

However, this does not work:
RTSP to Loopback with HARDWARE DECODING:
gst-launch-1.0 rtspsrc latency=0 location='rtsp://192.168.1.101:554/user=admin&password=admin123&channel=1&stream=0.sdp?' ! rtph265depay ! queue ! h265parse ! nvv4l2decoder ! nvvidconv ! videoconvert ! v4l2sink device=/dev/video41

Bizarrely, it appears to attempt to write to many different loopback devices:

Setting pipeline to PAUSED ...
Failed to open /dev/video4: No such file or directory
Failed to open /dev/video5: No such file or directory
Failed to open /dev/video6: No such file or directory
Failed to open /dev/video7: No such file or directory
Failed to open /dev/video8: No such file or directory
Failed to open /dev/video9: No such file or directory
Failed to open /dev/video10: No such file or directory
Failed to open /dev/video11: No such file or directory
Failed to open /dev/video12: No such file or directory
Failed to open /dev/video13: No such file or directory
Failed to open /dev/video14: No such file or directory
Failed to open /dev/video15: No such file or directory
Failed to open /dev/video16: No such file or directory
Failed to open /dev/video17: No such file or directory
Failed to open /dev/video18: No such file or directory
Failed to open /dev/video19: No such file or directory
Failed to open /dev/video20: No such file or directory
Failed to open /dev/video21: No such file or directory
Failed to open /dev/video22: No such file or directory
Failed to open /dev/video23: No such file or directory
Failed to open /dev/video24: No such file or directory
Failed to open /dev/video25: No such file or directory
Failed to open /dev/video26: No such file or directory
Failed to open /dev/video27: No such file or directory
Failed to open /dev/video28: No such file or directory
Failed to open /dev/video29: No such file or directory
Failed to open /dev/video30: No such file or directory
Failed to open /dev/video31: No such file or directory
Failed to open /dev/video32: No such file or directory
Failed to open /dev/video33: No such file or directory
Failed to open /dev/video34: No such file or directory
Failed to open /dev/video35: No such file or directory
Failed to open /dev/video36: No such file or directory
Failed to open /dev/video37: No such file or directory
Failed to open /dev/video38: No such file or directory
Failed to open /dev/video39: No such file or directory
Failed to open /dev/video40: No such file or directory
Opening in BLOCKING MODE
(Argus) Error EndOfFile: Unexpected error in reading socket (in src/rpc/socket/client/ClientSocketManager.cpp, function recvThreadCore(), line 266)
(Argus) Error EndOfFile: Receive worker failure, notifying 1 waiting threads (in src/rpc/socket/client/ClientSocketManager.cpp, function recvThreadCore(), line 339)
(Argus) Error InvalidState: Argus client is exiting with 1 outstanding client threads (in src/rpc/socket/client/ClientSocketManager.cpp, function recvThreadCore(), line 355)
(Argus) Error EndOfFile: Receiving thread terminated with error (in src/rpc/socket/client/ClientSocketManager.cpp, function recvThreadWrapper(), line 368)
(Argus) Error EndOfFile: Client thread received an error from socket (in src/rpc/socket/client/ClientSocketManager.cpp, function send(), line 145)
(Argus) Error EndOfFile:  (propagating from src/rpc/socket/client/SocketClientDispatch.cpp, function dispatch(), line 91)
ArgusV4L2_Open failed: No such file or directory
Opening in BLOCKING MODE 
libv4l2: error getting pixformat: Invalid argument
Opening in BLOCKING MODE 
Pipeline is live and does not need PREROLL ...
Progress: (open) Opening Stream
Progress: (connect) Connecting to rtsp://192.168.1.101:554/user=admin&password=admin123&channel=1&stream=0.sdp?
Progress: (open) Retrieving server options
Progress: (open) Retrieving media info
Progress: (request) SETUP stream 0
Progress: (request) SETUP stream 1
Progress: (open) Opened Stream
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Progress: (request) Sending PLAY request
Progress: (request) Sending PLAY request
Progress: (request) Sent PLAY request
NvMMLiteOpen : Block : BlockType = 279 
NVMEDIA: Reading vendor.tegra.display-size : status: 6 
NvMMLiteBlockCreate : Block : BlockType = 279

It also crashes the nvargus-daemon service running in the background…

May 08 16:27:04 tegra-ubuntu systemd[1]: Started Argus daemon.
May 08 16:53:40 tegra-ubuntu nvargus-daemon[22820]: === NVIDIA Libargus Camera Service (0.98.3)=== Listening for connections...=== gst-launch-1.0[27726]: Connection established (FFFFA2>
May 08 16:53:40 tegra-ubuntu nvargus-daemon[22820]: SCF: Error ResourceError:  (propagating from src/services/power/PowerService.cpp, function startService(), line 52)
May 08 16:53:40 tegra-ubuntu nvargus-daemon[22820]: SCF: Error ResourceError:  (propagating from src/components/ServiceHost.cpp, function startServices(), line 162)
May 08 16:53:40 tegra-ubuntu nvargus-daemon[22820]: SCF: Error InvalidState: Service not running (in src/services/power/PowerService.cpp, function stopService(), line 70)
May 08 16:53:40 tegra-ubuntu nvargus-daemon[22820]: SCF: Error InvalidState:  (propagating from src/components/ServiceHost.cpp, function stopServicesInternal(), line 214)
May 08 16:53:40 tegra-ubuntu nvargus-daemon[22820]: SCF: Error ResourceError:  (propagating from src/api/CameraDriver.cpp, function initialize(), line 178)
May 08 16:53:40 tegra-ubuntu nvargus-daemon[22820]: SCF: Error InvalidState: Services are already stopped (in src/components/ServiceHost.cpp, function stopServicesInternal(), line 193)
May 08 16:53:40 tegra-ubuntu nvargus-daemon[22820]: SCF: Error ResourceError:  (propagating from src/api/CameraDriver.cpp, function getCameraDriver(), line 119)
May 08 16:53:40 tegra-ubuntu nvargus-daemon[22820]: (Argus) Error ResourceError:  (propagating from src/api/GlobalProcessState.cpp, function createCameraProvider(), line 210)
May 08 16:53:40 tegra-ubuntu nvargus-daemon[22820]: === gst-launch-1.0[27726]: CameraProvider initialized (0xffff9c0bb2c0)=== gst-launch-1.0[27726]: CameraProvider destroyed (0xffff9c0>
May 08 16:53:40 tegra-ubuntu systemd[1]: nvargus-daemon.service: Main process exited, code=killed, status=11/SEGV
May 08 16:53:40 tegra-ubuntu systemd[1]: nvargus-daemon.service: Failed with result 'signal'.
May 08 16:53:40 tegra-ubuntu systemd[1]: nvargus-daemon.service: Scheduled restart job, restart counter is at 2.
May 08 16:53:40 tegra-ubuntu systemd[1]: Stopped Argus daemon.
May 08 16:53:40 tegra-ubuntu systemd[1]: Started Argus daemon.

Any suggestions about what to test next would be greatly appreciated. Thanks!

It may be related to your v4l2loopback version.

It works in my case using 0.12.3 built with dkms such as Gstreamer v4l2loopback hw mjpeg stream - #5 by Honey_Patouceul. (this post was building 0.12.5).

I made RTSP server with test-launch:

./test-launch "videotestsrc ! nvvidconv ! nvv4l2h265enc insert-sps-pps=1 insert-vui=1 idrinterval=15 ! h265parse ! rtph265pay name=pay0"

Then installed v4l2loopback. Note that if you change format, framerate or else you may have to unload the module with rmmod and reinstall.
Then launched a pipeline connecting to RTSP server, decoding and sending to v4l2sink. Note that you would use identity with drop-allocation property set:

sudo rmmod v4l2loopback
sudo modprobe v4l2loopback

#My AGX had no camera, so the virtual node is video0
gst-launch-1.0 rtspsrc latency=0 location=rtsp://127.0.0.1:8554/test ! rtph265depay ! queue ! h265parse ! nvv4l2decoder ! nvvidconv ! videoconvert ! identity drop-allocation=1 ! v4l2sink device=/dev/video0

v4l2-ctl -d0 --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
	Type: Video Capture

	[0]: 'YUYV' (YUYV 4:2:2)
		Size: Discrete 320x240
			Interval: Discrete 0.033s (30.000 fps)

and using the virtual video node works, although a bit slow:

gst-launch-1.0 v4l2src device=/dev/video0 ! videoconvert ! autovideosink

The messages failed to open /dev/video4: No such file or directory… are because you gave number 41 to your virtual node, but there are many available nodes with lower number. Probably using /dev/video4 for v4l2loopback would fix this.

1 Like

Hi jdberg2003,

Let me jump in with some humble suggestions.

  • Is there anything useful from the GStreamer debug log? Can you please share the output?
GST_DEBUG=2 gst-launch-1.0 rtspsrc latency=0 location='rtsp://192.168.1.101:554/user=admin&password=admin123&channel=1&stream=0.sdp?' ! rtph265depay ! queue ! h265parse ! nvv4l2decoder ! nvvidconv ! videoconvert ! v4l2sink device=/dev/video41
  • Does this command work? Meaning there are buffers being decoded (you should see a continuous output log of the received buffers with its corresponding timestamps, etc)
GST_DEBUG=2 gst-launch-1.0 rtspsrc latency=0 location='rtsp://192.168.1.101:554/user=admin&password=admin123&channel=1&stream=0.sdp?' ! rtph265depay ! queue ! h265parse ! nvv4l2decoder ! nvvidconv ! videoconvert ! fakesink silent=false -v

Jafet Chaves,
Embedded SW Engineer at RidgeRun
Contact us: support@ridgerun.com
Developers wiki: https://developer.ridgerun.com/
Website: www.ridgerun.com

Thank you both for your suggestions!

@Honey_Patouceul you were right, the “failed to open” messages were a red herring. I am unfortunately stuck with that device designation for project reasons…

I was actually able to solve the issue with the identity drop-allocation=1 parameter as you suggested! For anyone else lurking around, here is the working pipeline:

gst-launch-1.0 rtspsrc latency=0 location=‘rtsp://192.168.1.101:554/user=admin&password=admin123&channel=1&stream=0.sdp?’ ! rtph265depay ! queue ! h265parse ! nvv4l2decoder ! nvvidconv ! videoconvert ! identity drop-allocation=1 ! v4l2sink device=/dev/video41

On an unrelated note, do you have any working examples for sending h265 data to the loopback using v4l2sink, and then displaying the video using v4l2src in another terminal??? That would be great.

Thanks again so much for your help!

1 Like

Hello Jafet. Thanks for your input!

Although someone else came in with the parameter I needed to solve the problem, I am using your suggestions to troubleshoot a different, unrelated issue right now. I definitely appreciate your help.

1 Like

The support for H265 in v4l2loopback may be limited.

I am able to create an H265 virtual camera from videostestsrc:

gst-launch-1.0 videotestsrc ! nvvidconv ! nvv4l2h265enc insert-sps-pps=1 insert-vui=1 idrinterval=15 ! h265parse ! video/x-h265,stream-format=byte-stream,alignment=au ! identity drop-allocation=1 ! v4l2sink device=/dev/video0

and it gives correct info and runs fine:

v4l2-ctl -d0 --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
	Type: Video Capture

	[0]: 'HEVC' (HEVC, compressed)
		Size: Discrete 320x240
			Interval: Discrete 0.033s (30.000 fps)

gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-h265,stream-format=byte-stream,alignment=au ! h265parse ! nvv4l2decoder ! nvvidconv ! autovideosink
Setting pipeline to PAUSED ...
Opening in BLOCKING MODE 
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
NvMMLiteOpen : Block : BlockType = 279 
NVMEDIA: Reading vendor.tegra.display-size : status: 6 
NvMMLiteBlockCreate : Block : BlockType = 279 

However, it doesn’t work when relaying H265 from RTSP server:

gst-launch-1.0 rtspsrc location=rtsp://127.0.0.1:8554/test latency=0 ! rtph265depay ! queue ! h265parse ! identity drop-allocation=1 ! video/x-h265,stream-format=byte-stream,alignment=au ! v4l2sink device=/dev/video0

It can work decoding and re-encoding, but this would be slow and a waste of resources.
Maybe @DaneLLL or someone else could better advise for this case.

Well, thanks a lot for trying!

I saw the same result with the pipelines I could think to try. I should probably start a new conversation for this question. I can’t find much on this topic. I can find some history about removing restrictions on compressed data pipelined into loop-back devices, but no actual examples of using it.

Have a good night.

Hi,
Not sure if it works but may try to set config-interval=1 to h265parse plugin:

  config-interval     : Send VPS, SPS and PPS Insertion Interval in seconds (spr
op parameter sets will be multiplexed in the data stream when detected.) (0 = di
sabled, -1 = send with every IDR frame)
                        flags: readable, writable
                        Integer. Range: -1 - 3600 Default: 0

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.