Jetson Xavier NX - RTSP camera open issue

I am trying to open the camera using GSTREAMER through OpenCV 4.4.0 CUDA version

Environment:
Jetson NX development board
Jetpack 4.5.1
CUDA 10.2
OpenCV 4.4.0 GPU version

C++ Code:

  1. std::string public_url = “rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov”;
  2. cv::VideoCapture cap;
  3. bool ok = cap.open(public_url,cv::CAP_GSTREAMER);
  4. if (!cap.isOpened())
  5. throw std::runtime_error(“Source is not open”);

Code never reaches line number 4 and following the output

Opening in BLOCKING MODE 
NvMMLiteOpen : Block : BlockType = 261 
NVMEDIA: Reading vendor.tegra.display-size : status: 6 
NvMMLiteBlockCreate : Block : BlockType = 261

OpenCV 4.4.0 build from source on NX as per the NVidia opencv_install_jetson script. Build log
General configuration for OpenCV 4.4.0 =====================================
– Version control: unknown

– Extra modules:
– Location (extra): /home/workspace/opencv_contrib-4.4.0/modules
– Version control (extra): unknown

– Platform:
– Timestamp: 2021-05-07T17:53:10Z
– Host: Linux 4.9.201-tegra aarch64
– CMake: 3.10.2
– CMake generator: Unix Makefiles
– CMake build tool: /usr/bin/make
– Configuration: RELEASE

– CPU/HW features:
– Baseline: NEON FP16
– required: NEON
– disabled: VFPV3

– C/C++:
– Built as dynamic libs?: YES
– C++ standard: 11
– C++ Compiler: /usr/bin/c++ (ver 7.5.0)
– C++ flags (Release): -fsigned-char -ffast-math -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG
– C++ flags (Debug): -fsigned-char -ffast-math -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
– C Compiler: /usr/bin/gcc-7
– C flags (Release): -fsigned-char -ffast-math -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -O3 -DNDEBUG -DNDEBUG
– C flags (Debug): -fsigned-char -ffast-math -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG
– Linker flags (Release): -Wl,–gc-sections -Wl,–as-needed
– Linker flags (Debug): -Wl,–gc-sections -Wl,–as-needed
– ccache: NO
– Precompiled headers: NO
– Extra dependencies: m pthread cudart_static -lpthread dl rt nppc nppial nppicc nppicom nppidei nppif nppig nppim nppist nppisu nppitc npps cublas cudnn cufft -L/usr/local/cuda/lib64 -L/usr/lib/aarch64-linux-gnu
– 3rdparty dependencies:

– OpenCV modules:
– To be built: alphamat aruco bgsegm bioinspired calib3d ccalib core cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev datasets dnn dnn_objdetect dnn_superres dpm face features2d flann freetype fuzzy gapi hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor ml objdetect optflow phase_unwrapping photo plot quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking video videoio videostab xfeatures2d ximgproc xobjdetect xphoto
– Disabled: python2 python3 world
– Disabled by dependency: -
– Unavailable: cnn_3dobj cvv hdf java js julia matlab ovis sfm ts viz
– Applications: apps
– Documentation: NO
– Non-free algorithms: NO

– GUI:
– GTK+: YES (ver 2.24.32)
– GThread : YES (ver 2.56.4)
– GtkGlExt: NO
– VTK support: NO

– Media I/O:
– ZLib: /usr/lib/aarch64-linux-gnu/libz.so (ver 1.2.11)
– JPEG: /usr/lib/aarch64-linux-gnu/libjpeg.so (ver 80)
– WEBP: build (ver encoder: 0x020f)
– PNG: /usr/lib/aarch64-linux-gnu/libpng.so (ver 1.6.34)
– TIFF: /usr/lib/aarch64-linux-gnu/libtiff.so (ver 42 / 4.0.9)
– JPEG 2000: build Jasper (ver 1.900.1)
– OpenEXR: build (ver 2.3.0)
– HDR: YES
– SUNRASTER: YES
– PXM: YES
– PFM: YES

– Video I/O:
– DC1394: YES (2.2.5)
– FFMPEG: YES
– avcodec: YES (57.107.100)
– avformat: YES (57.83.100)
– avutil: YES (55.78.100)
– swscale: YES (4.8.100)
– avresample: NO
– GStreamer: YES (1.14.5)
– v4l/v4l2: YES (linux/videodev2.h)

– Parallel framework: pthreads

– Trace: YES (with Intel ITT)

– Other third-party libraries:
– Lapack: NO
– Eigen: YES (ver 3.3.4)
– Custom HAL: YES (carotene (ver 0.0.1))
– Protobuf: build (3.5.1)

– NVIDIA CUDA: YES (ver 10.2, CUFFT CUBLAS FAST_MATH)
– NVIDIA GPU arch: 75
– NVIDIA PTX archs:

– cuDNN: YES (ver 8.0.0)

– OpenCL: YES (no extra features)
– Include path: /home/workspace/opencv-4.4.0/3rdparty/include/opencl/1.2
– Link libraries: Dynamic load

– Python (for build): /usr/bin/python2.7

– Java:
– ant: NO
– JNI: NO
– Java wrappers: NO
– Java tests: NO

– Install to: /usr/local



– Configuring done
– Generating done

Could you please help me with this?

  1. X86_64 Platform GSTREAMER capture through OpenCV is working fine
    2. NX-ARM64 is not working

After I changed the code

#include <iostream>
#include <opencv2/videoio.hpp>
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/videoio.hpp>

int main(){
        std::string url = "rtspsrc location=rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov latency=200 ! queue ! rtph264depay ! h264parse ! nvv4l2decoder enable-max-performance=1 drop-frame-interval=1 ! nvvidconv ! video/x-raw(memory:NVMM),format=BGRx ! queue ! nvvidconv ! video/x-raw,format=BGRx ! videoconvert ! video/x-raw,format=BGR ! videorate max-rate=30 drop-only=true average-period=5000000 ! video/x-raw,framerate=30/1 ! appsink sync=true";
        cv::VideoCapture cap;
        cap.open(url, cv::CAP_GSTREAMER);
        cv::Mat frame;
        while(true){
                bool ok = cap.read(frame);
                if (!ok){
                        break;
                }
                std::cout << "Reading Frame" ;
                //              cv::imshow("Streaming", frame);
                //cv::waitKey(1);
        }
        //cv::destroyAllWindows();
        return 0;
}

as per the discussion

following is the output

Opening in BLOCKING MODE
Opening in BLOCKING MODE

Nothing happens after that.

Moving to the Jetson Xavier NX forum.

Hi,
Please check if you can run this python sample:
Doesn't work nvv4l2decoder for decoding RTSP in gstreamer + opencv - #3 by DaneLLL