Combination "rtspsrc protocols=tcp" + appsink fails with segmentation fault

Hi all.

The following python script fails (segmentation fault), but works if UDP is used instead of TCP (see comments in code):

###########################################
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import numpy as np
import cv2

# Fails (observe protocols=tcp):
# cap = cv2.VideoCapture('rtspsrc protocols=tcp buffer-mode=buffer latency=100 location=rtsp://..... ! rtph264depay !  h264parse ! nvv4l2decoder ! nvvideoconvert ! appsink', cv2.CAP_GSTREAMER)

# Works (observe protocols=udp):
cap = cv2.VideoCapture('rtspsrc protocols=udp buffer-mode=buffer latency=100 location=rtsp://..... ! rtph264depay !  h264parse ! nvv4l2decoder ! nvvideoconvert ! appsink', cv2.CAP_GSTREAMER)

while(True):
    ret, frame = cap.read()
    cv2.imshow('frame', frame)
    if cv2.waitKey(1) & 0xFF == ord('q'):
    break
cap.release()
cv2.destroyAllWindows()
###########################################

Nevertheless, the following two command lines work (both of them, one with TCP, the other with UDP):

$ gst-launch-1.0 rtspsrc protocols=tcp latency=100 location=rtsp://..... ! rtph264depay !  h264parse ! nvv4l2decoder ! nvvideoconvert ! nveglglessink
$ gst-launch-1.0 rtspsrc protocols=udp latency=100 location=rtsp://..... ! rtph264depay !  h264parse ! nvv4l2decoder ! nvvideoconvert ! nveglglessink

Analyzing with gdb the core generated by the python program when crashing, I can see that it is the plugin nvvideoconvert the one that is crashing:

#0 0x00007f9224fdbded in gst_nvvideoconvert_transform () from /usr/lib/x86_64-linux-gnu/gstreamer-1.0/deepstream/libgstnvvideoconvert.so
#1 0x00007f924fcbe401 in ?? () from /usr/lib/x86_64-linux-gnu/libgstbase-1.0.so.0
#2 0x00007f924fcbdb84 in ?? () from /usr/lib/x86_64-linux-gnu/libgstbase-1.0.so.0
#3 0x00007f9254f2488b in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0
#4 0x00007f9254f2cbb3 in gst_pad_push () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0
#5 0x00007f924f572f1a in ?? () from /usr/lib/x86_64-linux-gnu/libgstvideo-1.0.so.0
#6 0x00007f924f57a09b in gst_video_decoder_finish_frame () from /usr/lib/x86_64-linux-gnu/libgstvideo-1.0.so.0
#7 0x00007f92260276d4 in gst_v4l2_video_dec_loop () from /usr/lib/x86_64-linux-gnu/gstreamer-1.0/deepstream/libgstnvvideo4linux2.so
#8 0x00007f9254f59269 in ?? () from /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0
#9 0x00007f9254da2ac5 in g_thread_pool_thread_proxy () from /home/pedroe/miniconda3/lib/libglib-2.0.so.0
#10 0x00007f9254da2080 in g_thread_proxy () from /home/pedroe/miniconda3/lib/libglib-2.0.so.0
#11 0x00007f9273dd86db in start_thread (arg=0x7f91e1fff700) at pthread_create.c:463
#12 0x00007f9273b0188f in clone () at …/sysdeps/unix/sysv/linux/x86_64/clone.S:95

To summarize, it seems that the combination “rtspsrc protocols=tcp”+appsink is failing, while “rtspsrc protocols=tcp”+nveglglessink works seamlessly. UDP does not pose any type of problem in any case.

Any ideas or workarounds? We need to access rtspsrc via TCP from our python scripts…

Thanks in advance,
Pedro E.

Hi again.

Just find the solution here:

https://devtalk.nvidia.com/default/topic/1062748/deepstream-sdk/nvvideoconvert-crashes-on-rtsp-input-src-crop-x-y-w-h-pipeline/3

It was a known problem, and the new file libgstnvvideoconvert.so attached at the end of that thread solves it.

Pedro E.