# IP camera streaming on Jetson TX2

**URL:** <https://forums.developer.nvidia.com/t/ip-camera-streaming-on-jetson-tx2/57574>\
**Category:** Jetson TX2\
**Created:** [January 29, 2018, 10:37am UTC](https://forums.developer.nvidia.com/t/ip-camera-streaming-on-jetson-tx2/57574 "2018-01-29T10:37:52Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![pharatekomal](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@pharatekomal](https://forums.developer.nvidia.com/u/pharatekomal)\
**Post date:** [January 29, 2018, 10:37am UTC](https://forums.developer.nvidia.com/t/ip-camera-streaming-on-jetson-tx2/57574/1 "2018-01-29T10:37:52Z")

</div>

Jetson TX2  
Jetpack 3.1  
Opencv 3.3.0 Installation link: [https://github.com/jetsonhacks/buildOpenCVTX2](https://github.com/jetsonhacks/buildOpenCVTX2)  
Python 2.7.12

I have uninstalled OpenCV4Tegra before installing OpenCV 3.3.0

i’m using the following code::

```auto
import numpy as np
import cv2

uri= "uridecodebin uri=rtsp://<ip_address>/onvif1 ! videoconvert ! videoscale ! appsink"
cap = cv2.VideoCapture(uri)
while(True):
    try:
	    ret, frame = cap.read()
	    cv2.imshow('frame',frame)
	    if cv2.waitKey(1) & 0xFF == ord('q'):
		break
    except:
	    print "Unable to open"

# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()

```

This code works fine most of the times.

Build Information

```auto
GStreamer:                      
      base: YES (ver 1.8.3)
      video: YES (ver 1.8.3)
      app: YES (ver 1.8.3)
      riff: YES (ver 1.8.3)
      pbutils: YES (ver 1.8.3)\n

```

But it gives following errors sometime :

```auto
OpenCV Error: Unspecified error (GStreamer: unable to start pipeline
) in cvCaptureFromCAM_GStreamer, file __/opencv/modules/videoio/src/cap_gstreamer.cpp, line 881
VIDEOIO(cvCreateCapture_GStreamer (CV_CAP_GSTREAMER_FILE, filename)): raised OpenCV exception:

__/opencv/modules/videoio/src/cap_gstreamer.cpp:881: error: (-2) GStreamer: unable to start pipeline
 in function cvCaptureFromCAM_GStreamer

Error opening stream : Error: Video file could not be opened (opencv reqs. non relative paths)
    at Error (native)
    at startLiveStreaming (/home/nvidia/aggregatorOpenCV/jetson-device-client/aggregatorjetson.js:346:16)
    at /home/nvidia/aggregatorOpenCV/jetson-device-client/aggregatorjetson.js:143:21
    at /home/nvidia/aggregatorOpenCV/jetson-device-client/aggregatorjetson.js:494:17
    at /home/nvidia/aggregatorOpenCV/jetson-device-client/node_modules/mkdirp/index.js:30:20
    at FSReqWrap.oncomplete (fs.js:123:15)

```

There are some more errors regarding gstreamer pipeline.  
Can I know the solution?

---

<div class="post-metadata">

**Author:** ![WayneWWW](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/waynewww/32/14043_2.png) [@WayneWWW](https://forums.developer.nvidia.com/u/WayneWWW)\
**Post date:** [January 30, 2018, 3:09am UTC](https://forums.developer.nvidia.com/t/ip-camera-streaming-on-jetson-tx2/57574/2 "2018-01-30T03:09:14Z")

</div>

Could you try to use

```auto
rtspsrc location= rtsp://255.255.255.255/test name=r latency=0 ! rtph264depay ! h264parse ! decodebin ! appsink

```

---

<div class="post-metadata">

**Author:** ![pharatekomal](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@pharatekomal](https://forums.developer.nvidia.com/u/pharatekomal)\
**Post date:** [January 30, 2018, 9:31am UTC](https://forums.developer.nvidia.com/t/ip-camera-streaming-on-jetson-tx2/57574/3 "2018-01-30T09:31:17Z")

</div>

Thanks for the reply.  
Yes. I tried this.  
It’s also giving the same error.  
Infact it never opens the stream.

---

<div class="post-metadata">

**Author:** ![WayneWWW](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/waynewww/32/14043_2.png) [@WayneWWW](https://forums.developer.nvidia.com/u/WayneWWW)\
**Post date:** [January 30, 2018, 9:36am UTC](https://forums.developer.nvidia.com/t/ip-camera-streaming-on-jetson-tx2/57574/4 "2018-01-30T09:36:38Z")

</div>

Could you try these pipelines by using gst-launch-1.0 and see if any error first?

---

<div class="post-metadata">

**Author:** ![pharatekomal](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@pharatekomal](https://forums.developer.nvidia.com/u/pharatekomal)\
**Post date:** [January 30, 2018, 10:38am UTC](https://forums.developer.nvidia.com/t/ip-camera-streaming-on-jetson-tx2/57574/5 "2018-01-30T10:38:30Z")

</div>

I used gst-launch-1.0 for both. Tt gives the same following errors for both

```auto
gst-launch-1.0 uridecodebin uri=rtsp://<ip_address>/etc ! videoconvert ! videoscale ! appsink

```

It gives the following same errors

```auto
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Progress: (open) Opening Stream
Progress: (connect) Connecting to rtsp://<ip_address>/etc
Progress: (open) Retrieving server options
Progress: (open) Retrieving media info
ERROR: from element /GstPipeline:pipeline0/GstURIDecodeBin:uridecodebin0/GstRTSPSrc:source: Could not open resource for reading.
Additional debug info:
gstrtspsrc.c(5384): gst_rtspsrc_setup_auth (): /GstPipeline:pipeline0/GstURIDecodeBin:uridecodebin0/GstRTSPSrc:source:
No supported authentication protocol was found
ERROR: pipeline doesn't want to preroll.
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...

```

And the other one

```auto
gst-launch-1.0 rtspsrc location=rtsp://<ip_address>/etc name=r latency=0 ! rtph264depay ! h264parse ! decodebin ! appsink

```

Its giving following error:

```auto
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Progress: (open) Opening Stream
Progress: (connect) Connecting to rtsp://<ip_address>/etc
Progress: (open) Retrieving server options
Progress: (open) Retrieving media info
ERROR: from element /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0: Could not open resource for reading.
Additional debug info:
gstrtspsrc.c(5384): gst_rtspsrc_setup_auth (): /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0:
No supported authentication protocol was found
ERROR: pipeline doesn't want to preroll.
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...

```

---

<div class="post-metadata">

**Author:** ![WayneWWW](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/waynewww/32/14043_2.png) [@WayneWWW](https://forums.developer.nvidia.com/u/WayneWWW)\
**Post date:** [January 31, 2018, 2:55am UTC](https://forums.developer.nvidia.com/t/ip-camera-streaming-on-jetson-tx2/57574/6 "2018-01-31T02:55:32Z")

</div>

Could you try to use fakesink first?

gst-launch-1.0 rtspsrc location=rtsp://\<ip\_address\>/etc name=r latency=0 ! rtph264depay ! h264parse ! decodebin ! fakesink

The error “No supported authentication protocol was found”. Are you sure your rtsp server is working? Could you use vlc or any client app to do streaming first?

---

<div class="post-metadata">

**Author:** ![pharatekomal](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@pharatekomal](https://forums.developer.nvidia.com/u/pharatekomal)\
**Post date:** [January 31, 2018, 6:38am UTC](https://forums.developer.nvidia.com/t/ip-camera-streaming-on-jetson-tx2/57574/7 "2018-01-31T06:38:26Z")

</div>

I tried to do so.

I have two types of rtsp.  
First I’m getting from DVR of the form

```auto
rtsp://user:password@<ip>:<port>/cam/realmonitor?channel=11&subtype=0

```

This URL gives that authentication error by using gst-launch-1.0  
But this works fine with OpenCV 3.3.0 and gstreamer 1.8.3 on Jetson

And the other one from IP camera Sricam SP007 of the format

```auto
rtsp://<ip_address>/onvif1

```

Gives all the errors of OpenCV 3.3.0 mentioned except the authentication one.

1. Using gst-launch-1.0 it gives following output for the command::

```auto
gst-launch-1.0 rtspsrc location="rtsp://<ip_address>/onvif1" name=r latency=0 ! rtph264depay ! h264parse ! decodebin ! fakesink

```

```auto
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Progress: (open) Opening Stream
Progress: (connect) Connecting to rtsp://<ip_address>/onvif1
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 = 261 
TVMR: NvMMLiteTVMRDecBlockOpen: 7907: NvMMLiteBlockOpen 
NvMMLiteBlockCreate : Block : BlockType = 261 
TVMR: cbBeginSequence: 1223: BeginSequence 1280x720, bVPR = 0
TVMR: LowCorner Frequency = 100000 
TVMR: cbBeginSequence: 1622: DecodeBuffers = 2, pnvsi->eCodec = 4, codec = 0 
TVMR: cbBeginSequence: 1693: Display Resolution : (1280x720) 
TVMR: cbBeginSequence: 1694: Display Aspect Ratio : (1280x720) 
TVMR: cbBeginSequence: 1762: ColorFormat : 5 
TVMR: cbBeginSequence:1776 ColorSpace = NvColorSpace_YCbCr601
TVMR: cbBeginSequence: 1904: SurfaceLayout = 3
TVMR: cbBeginSequence: 2005: NumOfSurfaces = 9, InteraceStream = 0, InterlaceEnabled = 0, bSecure = 0, MVC = 0 Semiplanar = 1, bReinit = 1, BitDepthForSurface = 8 LumaBitDepth = 8, ChromaBitDepth = 8, ChromaFormat = 5
TVMR: cbBeginSequence: 2007: BeginSequence ColorPrimaries = 2, TransferCharacteristics = 2, MatrixCoefficients = 2
Allocating new output: 1280x720 (x 9), ThumbnailMode = 0
OPENMAX: HandleNewStreamFormat: 3464: Send OMX_EventPortSettingsChanged : nFrameWidth = 1280, nFrameHeight = 720 
TVMR: FrameRate = 15 
TVMR: NVDEC LowCorner Freq = (50000 * 1024) 
---> TVMR: Video-conferencing detected !!!!!!!!!
TVMR: FrameRate = 14.995831

```

1. And using OpenCV the error mentioned and the start.

2. Using ffplay it works fine. Opens the stream. using ffmpeg also it works fine.

Just OpenCV isnt able to do so sometimes. I want reliable streaming from the IP camera.

Can I know if streaming with rtsp+onvif1 need some other plugins or some command line arguments?

---

<div class="post-metadata">

**Author:** ![WayneWWW](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/waynewww/32/14043_2.png) [@WayneWWW](https://forums.developer.nvidia.com/u/WayneWWW)\
**Post date:** [January 31, 2018, 7:26am UTC](https://forums.developer.nvidia.com/t/ip-camera-streaming-on-jetson-tx2/57574/8 "2018-01-31T07:26:58Z")

</div>

Hi pharatekomal,

There are still something to clarify.

```auto
This URL gives that authentication error by using gst-launch-1.0
But this works fine with OpenCV 3.3.0 and gstreamer 1.8.3 on Jetson

```

What is the difference here between gst-launch-1.0 and gstreamer1.8.3? They are supposed to be the same thing. Do you mean some rtsp plugin from gstreamer 1.8.3?

OpenCV 3.3 works fine under this camera, right?

For second camera, looks like gstreamer can work. Could you try it with gst-launch-1.0 rtspsrc location=“rtsp://\<ip\_address\>/onvif1” name=r latency=0 ! rtph264depay ! h264parse ! decodebin ! nvoverlaysink on Tegra to see if preview is shown?

This thread has successful example, could you take a look?

> **[That proceesing to Open IP Camera with gstreamer and opencv only display a...](https://forums.developer.nvidia.com/default/topic/1007962/that-proceesing-to-open-ip-camera-with-gstreamer-and-opencv-only-display-a-still-picture-how-to-solve-it-/)**
>
> Hello everyone!I have encountered a confusing problem on my jetson-TX2. First,I tested “gst-launch-1.0 rtspsrc location=“rtsp://192.168.0.10:554/user=admin\_password=tlJwpbo6\_channel=1\_stream=0.sdp?real\_stream” latency=0 ! decodebin ! nvvidconv !...

---

<div class="post-metadata">

**Author:** ![pharatekomal](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@pharatekomal](https://forums.developer.nvidia.com/u/pharatekomal)\
**Post date:** [February 2, 2018, 7:07am UTC](https://forums.developer.nvidia.com/t/ip-camera-streaming-on-jetson-tx2/57574/9 "2018-02-02T07:07:31Z")

</div>

```auto
This URL gives that authentication error by using gst-launch-1.0
    But this works fine with OpenCV 3.3.0 and gstreamer 1.8.3 on Jetson

```

I meant OpenCV3.3.0 which is using gstreamer 1.8.3 internally is giving the issue  
While using gst-launch-1.0 command line tool, streaming works fine.

* * *

Actually I’m able to stream IP camera. But like 3 out of 10 times it fails giving the gstreamer OpenCV issue mentioned at very first.  
Using gst-launch and ffmpeg or ffplay these URLs works fine.  
The issue is with OpenCV streaming Videocapture.

```auto
OpenCV Error: Unspecified error (GStreamer: unable to start pipeline
    ) in cvCaptureFromCAM_GStreamer, file __/opencv/modules/videoio/src/cap_gstreamer.cpp, line 881
    VIDEOIO(cvCreateCapture_GStreamer (CV_CAP_GSTREAMER_FILE, filename)): raised OpenCV exception:

    __/opencv/modules/videoio/src/cap_gstreamer.cpp:881: error: (-2) GStreamer: unable to start pipeline
     in function cvCaptureFromCAM_GStreamer

    Error opening stream : Error: Video file could not be opened (opencv reqs. non relative paths)
        at Error (native)
        at startLiveStreaming (/home/nvidia/aggregatorOpenCV/jetson-device-client/aggregatorjetson.js:346:16)
        at /home/nvidia/aggregatorOpenCV/jetson-device-client/aggregatorjetson.js:143:21
        at /home/nvidia/aggregatorOpenCV/jetson-device-client/aggregatorjetson.js:494:17
        at /home/nvidia/aggregatorOpenCV/jetson-device-client/node_modules/mkdirp/index.js:30:20
        at FSReqWrap.oncomplete (fs.js:123:15)

```

Like if it’s works with gst-launch anf ffmpeg consistently, then why it isnt consistent with OpenCV.

And if it gets opened  
Also while doing

```auto
cap.release()

```

It sometimes gives following error

```auto
(node:6523): GStreamer-CRITICAL **: 
Trying to dispose element videoconvert0, but it is in READY instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.

(node:6523): GStreamer-CRITICAL **: 
Trying to dispose element pipeline0, but it is in PAUSED instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.

(node:6523): GStreamer-CRITICAL **: 
Trying to dispose element videoscale0, but it is in READY instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.

(node:6523): GStreamer-CRITICAL **: 
Trying to dispose element pipeline0, but it is in PLAYING instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.

```

---

<div class="post-metadata">

**Author:** ![pharatekomal](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@pharatekomal](https://forums.developer.nvidia.com/u/pharatekomal)\
**Post date:** [February 2, 2018, 7:33am UTC](https://forums.developer.nvidia.com/t/ip-camera-streaming-on-jetson-tx2/57574/10 "2018-02-02T07:33:26Z")

</div>

I tried to stream using suggested URL  
1.

> **[That proceesing to Open IP Camera with gstreamer and opencv only display a...](https://forums.developer.nvidia.com/default/topic/1007962/that-proceesing-to-open-ip-camera-with-gstreamer-and-opencv-only-display-a-still-picture-how-to-solve-it-/)**
>
> Hello everyone!I have encountered a confusing problem on my jetson-TX2. First,I tested “gst-launch-1.0 rtspsrc location=“rtsp://192.168.0.10:554/user=admin\_password=tlJwpbo6\_channel=1\_stream=0.sdp?real\_stream” latency=0 ! decodebin ! nvvidconv !...

But its not able to open the stream  
and gives some errors.

1. The option mentioned by you.

```auto
gst-launch-1.0 rtspsrc location="rtsp://<ip_address>/onvif1" name=r latency=0 ! rtph264depay ! h264parse ! decodebin ! nvoverlaysink

```

Gives this output

```auto
WARNING: erroneous pipeline: no element "nvoverlaysink"

```

* * *

While  
I tried ::

```auto
gst-launch-1.0 rtspsrc location=\"rtsp://<ip_adrees>/onvif1\" ! rtph264depay ! h264parse ! omxh264dec ! videoconvert ! xvimagesink

```

And

```auto
uri="rtspsrc location=\"rtsp://<ip_adrees>/onvif1\" ! rtph264depay ! h264parse ! omxh264dec ! videoconvert ! xvimagesink"
cam=cv2.VideoCapture(uri)
#do something
cam.release()

```

Works fine for me maximum times.

Just need to solve issues mentioned while opening and releasibg the stream(3 out of 10 times).

I hope I’m not confusing.  
Thanks

---

<div class="post-metadata">

**Author:** ![WayneWWW](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/waynewww/32/14043_2.png) [@WayneWWW](https://forums.developer.nvidia.com/u/WayneWWW)\
**Post date:** [February 2, 2018, 9:25am UTC](https://forums.developer.nvidia.com/t/ip-camera-streaming-on-jetson-tx2/57574/11 "2018-02-02T09:25:09Z")

</div>

Could you try to check cap status before read frame?

```auto
cap.isOpened()

```

---

<div class="post-metadata">

**Author:** ![pharatekomal](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@pharatekomal](https://forums.developer.nvidia.com/u/pharatekomal)\
**Post date:** [February 2, 2018, 11:54am UTC](https://forums.developer.nvidia.com/t/ip-camera-streaming-on-jetson-tx2/57574/12 "2018-02-02T11:54:03Z")

</div>

Yes I do check.  
The error occurs at VideoCapture only.

---

<div class="post-metadata">

**Author:** ![WayneWWW](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/waynewww/32/14043_2.png) [@WayneWWW](https://forums.developer.nvidia.com/u/WayneWWW)\
**Post date:** [February 8, 2018, 8:42am UTC](https://forums.developer.nvidia.com/t/ip-camera-streaming-on-jetson-tx2/57574/13 "2018-02-08T08:42:39Z")

</div>

Is this issue resolved?

---

<div class="post-metadata">

**Author:** ![pharatekomal](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@pharatekomal](https://forums.developer.nvidia.com/u/pharatekomal)\
**Post date:** [February 13, 2018, 9:05am UTC](https://forums.developer.nvidia.com/t/ip-camera-streaming-on-jetson-tx2/57574/14 "2018-02-13T09:05:05Z")

</div>

No.It’s not solved yet.

---

<div class="post-metadata">

**Author:** ![Honey\_Patouceul](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/honey_patouceul/32/389777_2.png) [@Honey\_Patouceul](https://forums.developer.nvidia.com/u/Honey_Patouceul)\
**Post date:** [March 12, 2018, 10:17pm UTC](https://forums.developer.nvidia.com/t/ip-camera-streaming-on-jetson-tx2/57574/15 "2018-03-12T22:17:48Z")

</div>

You may check [url][opencv problem with capturing rtsp stream using gstreamer on tx2 - Jetson TX2 - NVIDIA Developer Forums](https://devtalk.nvidia.com/default/topic/1030866/jetson-tx2/opencv-problem-with-capturing-rtsp-stream-using-gstreamer-on-tx2/post/5244649/#5244649%5B/url%5D)

---

<div class="post-metadata">

**Author:** ![nadeemm](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/nadeemm/32/367020_2.png) [@nadeemm](https://forums.developer.nvidia.com/u/nadeemm)\
**Post date:** [October 18, 2021, 6:28pm UTC](https://forums.developer.nvidia.com/t/ip-camera-streaming-on-jetson-tx2/57574/16 "2021-10-18T18:28:24Z")

</div>

Closed on October 18, 2021, 6:28pm UTC


