Doesn't work nvv4l2decoder for decoding RTSP in gstreamer + opencv

Hi all,
I want to do decoding multi-stream RTSP using h264 hardware decoder of jetson nano, but When I use nvv4l2decoder for decoding, Doesn’t work, but omxh264dec is work correctly.
I want to use drop-frame-interval options of nvv4l2decoder, but this option isn’t exist in omxh264dec,
my jetson nano system :
cuda 10.0
jetpack 4.2.2
opencv 3.4.6 and cuda support and gstreamer support (build from source)

The below code is work correctly, but when I put nvv4l2decoder instead of omxh264dec, the decoder doesn’t work.

 gstream_elemets = (
                'rtspsrc location=rtsp latency=300 !'
                'rtph264depay ! h264parse !'
                'queue max-size-buffers=10 !'
                'omxh264dec enable-max-performance=1 enable-low-outbuffer=1 !'
                'video/x-raw(memory:NVMM),format=(string)NV12 !'
                'nvvidconv ! video/x-raw  format=(string)BGRx !'
                'queue max-size-buffers=10 !'
                'videoconvert ! '
                'appsink')
cv2.VideoCapture(gstream_elemets, cv2.CAP_GSTREAMER)

I also this work for filesrc but don’t work for rtspsrc, why?

gst_str = ('filesrc location=file_path latency=300 ! '
               'qtdemux   ! h264parse ! nvv4l2decoder  ! '
               'nvvidconv ! '
               'video/x-raw, '
               'format=(string)NV12 ! '
               'videoconvert !'
               'appsink ')
cv2.VideoCapture(gst_str, cv2.CAP_GSTREAMER)

Hi,
We try to launch public RTSP source and it works fine:

import sys
import cv2

def read_cam():
    cap = cv2.VideoCapture("rtspsrc location=rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov ! rtph264depay ! h264parse ! nvv4l2decoder ! nvvidconv ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw,format=BGR ! appsink ")
    if cap.isOpened():
        cv2.namedWindow("demo", cv2.WINDOW_AUTOSIZE)
        while True:
            ret_val, img = cap.read();
            cv2.imshow('demo',img)
            cv2.waitKey(10)
    else:
     print "rtsp open failed"

    cv2.destroyAllWindows()


if __name__ == '__main__':
    read_cam()

FYR.

2 Likes
Decode using nvcuvid
H264 decoder for RTSP stream inside the docker
How to open rtspsrc as VideoCapture
Connect camera ip (Hikvision) to jetson tx2 without internet
Is there a way to crop an image with gpu
Freezing when opencv and gstreamer(with nvv4l2decoder) used on Xavier NX
Build OpenCV with FFmpeg Bug don't work VideoCapture For RTSP URL
Problem with Jetson Nano and OpenCV
Capturing a stream from raspberry via Gstreamer
Problem with two USB cameras
Why I try to convert video with FFmpeg CPU utilization is very high?
Videocapture blocked! please help
Window playback using g-streamer python in DeepStream5.0 Jetson Nano device
Jetson Xavier NX - RTSP camera open issue
Use opencv to display
Port missing in uri warning: Error opening http URL with Python cv2.VideoCapture() on Jetson
Frame from IP camera thinning using OpenCV and GStreamer
RTSP stream with openCV: Missing installation?
Error compiling for opencv4.5.5 with cuda acceleration on JetsonNano (cudaVideoCodec_AV1 was not declared)
Delay acumulation with gstreamer and opencv
Opencv with rtsp source and backgroundsubtractor in Xavier AGX
Stream image with gstreamer and python over tcp
Help needed: RTSP stream from raspberry pi to jetson nano
FLIR Lepton Streaming from Pi Zero to Nano
FLIR Lepton Streaming from Pi Zero to Nano
How to decode h264 buffers to CV MAT with gstreamer
Is OpenCV VideoCapture able to get branched appsink from test-launch
Trying to get OpenCV (built with CUDA) working with FFMPEG
RTSP with OpenCV (VideoCapture) on python3.7
Jetson Nano with IDS GigE camera
Cant use opencv with backend gstreamer to capture live video youtube on JetsonNX
Jetson Nano Publish RTSP server with csi camera
Error opening bin: no element "nvv4l2decoder"
PiCam in OpenCV nano_built_opencv error
Rtsp and gst-launch is not working opencv.VideoCapture in python but working in x86
When opencv captures gstreamer video data, black screen!
Jetson nx use opencv get rstp camera streaming problem
I failed to create an RTSP streaming server using test-launch
Gstreamer pipeline input to opencv in python
Multiple RTSP cameras using GStreamer to a python OpenCV array on Jetson Nano?
Accessing CCTV camera feeds
RTSP gstream simple receive downscale, then store in file
Import cv2 complains libnvbuf_utils.so.1.0.0 not found
How to Call Hardware Decoding to Accelerate RTSP Video Reading?
GStreamer-CRITICAL gst_poll_read_control: assertion 'set != NULL' failed
GStreamer pipeline with accelerated elements to get RGB frames
GStreamer warning: Error pushing buffer to GStreamer pipeline
Jetpack 6.2 RTSP Stream Enable Nvidia Decoder
Problems with RTSP video in Python
Problem with Gstream and Opencv on Jetson nano
Running `gst-inspect-1.0 nvv4l2h264dec` will show that there is no such element as `nvv4l2h264dec`
File→RTSP (OpenCV+GStreamer→mediamtx) unstable on Jetson; direct RTSP works
Cap_gstreamer.cpp, Gstreamer not working
Gstreamer warning
Trying to test for RTSP failed
OpenCV installation for AVerMedia Jetson Nano
Running `gst-inspect-1.0 nvv4l2h264dec` will show that there is no such element as `nvv4l2h264dec`
cv::Videocap::open(url) is blocked all the time with parsebin for rtsp stream
Video Lag in Jetson AGX Orin
Gstreamer with Opencv for rtsp stream

I run your code and it doesn’t show me any things, and stuck in this state:
I set my location = rtsp://IP:PORT/1920x1080.264, and I stream the 1920x1080.264 file with live555 from other system and I want to decode with jetson nano.
this rtsp is work correctly with omxh264dec.

This is with jetpack 4.2.2 :

nvbuf_utils: Could not get EGL display connection
Opening in BLOCKING MODE 
NvMMLiteOpen : Block : BlockType = 261 
NVMEDIA: Reading vendor.tegra.display-size : status: 6 
NvMMLiteBlockCreate : Block : BlockType = 261 

(python3:20431): GStreamer-CRITICAL **: 11:29:19.872: gst_mini_object_unref: assertion 'mini_object != NULL' failed
NvMMLiteOpen : Block : BlockType = 261 
NVMEDIA: Reading vendor.tegra.display-size : status: 6 
NvMMLiteBlockCreate : Block : BlockType = 261

This is with jetpack 4.4 DP:

libEGL warning: DRI2: failed to authenticate
libEGL warning: MESA-LOADER: failed to open swrast (search paths /usr/lib/aarch64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri)

libEGL warning: MESA-LOADER: failed to open swrast (search paths /usr/lib/aarch64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri)

nvbuf_utils: Could not get EGL display connection
Opening in BLOCKING MODE 
NvMMLiteOpen : Block : BlockType = 261 
NVMEDIA: Reading vendor.tegra.display-size : status: 6 
NvMMLiteBlockCreate : Block : BlockType = 261
1 Like

There is no update from you for a period, assuming this is not an issue any more.
Hence we are closing this topic. If need further support, please open a new one. Thanks

Hi,
Does the public RTSP URI work?

rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov

We don’t see issue in connecting to the URI. Would like to align this result first.

Same issue for me. Nothing.

Here is my pipe:
std::string pipe = "rtspsrc location=rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov ! rtph264depay ! h264parse ! nvv4l2decoder ! nvvidconv ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw,format=BGR ! appsink ";

All I get is “Opening in BLOCKING MODE”
nothing else… until Cntl-C to exit.

It works with omxh264dec.

Still trying to get 264 hardware acceleration on VideoCapture.
Running Xavier NX.

dk@XavierNX:~$ gst-inspect-1.0 nvv4l2decoder
Factory Details:
Rank primary + 11 (267)
Long-name NVIDIA v4l2 video decoder
Klass Codec/Decoder/Video
Description Decode video streams via V4L2 API
Author Nicolas Dufresne nicolas.dufresne@collabora.com, Viranjan Pagar vpagar@nvidia.com

Plugin Details:
Name nvvideo4linux2
Description Nvidia elements for Video 4 Linux
Filename /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstnvvideo4linux2.so
Version 1.14.0
License LGPL
Source module nvvideo4linux2
Binary package nvvideo4linux2
Origin URL http://nvidia.com/

GObject
±—GInitiallyUnowned
±—GstObject
±—GstElement
±—GstVideoDecoder
±—GstNvV4l2VideoDec
±—nvv4l2decoder

Any help much appreciated!
Dave

Hi birdingpix,

Please help to open a new topic for your issue. Thanks