Opencv: Raspberry pi rtsp server, ffmpeg decoding

Created on 29 Mar 2017  路  3Comments  路  Source: opencv/opencv

System information (version)
  • OpenCV => 3.1
  • Opencv-python => 3.1.0-dev
  • Operating System / Platform => Ubuntu 16.04 LTS
Detailed description

I want to process an rtsp stream created from a raspberry camera frame by frame with python or C++.

Steps to reproduce
.py
     import cv2
     rtsp_url = "rtsp://192.168.55.151:8554/stream.sdp"
     video = cv2.VideoCapture(rtsp_url)
     while(1):
            ret, frame = video.read()
            cv2.imshow('VIDEO', frame)
            cv2.waitKey(1)

The stream is created from the raspberry machine using vlc: raspivid -o - -t 0 -hf -w 640 -h 480 -fps 30 | cvlc stream:///dev/stdin --sout "#rtp{sdp=rtsp://192.168.55.151:8554/stream.sdp}" :demux=h264

The stream is successfully opened from vlc player with: rtsp://192.168.55.151:8554/stream.sdp

From the python code though, i get: method SETUP failed: 461 Client error (an ffmpeg error)

If i run the command line ffmpeg: ffmpeg -rtsp_transport tcp -i rtsp://192.168.55.151:8554/stream.sdp
i get the same exact error: method SETUP failed: 461 Client error as well as Protocol not supported
If i run the command line ffmpeg: ffmpeg -rtsp_transport udp -i rtsp://192.168.55.151:8554/stream.sdp
the stream decodes successfully.

Is this transport protocol a bug, or am i doing something wrong? Can i specify the transport protocol in the OpenCV code?

videoio question (invalid tracker)

Most helpful comment

You may want to install the UV4L driver for the raspberry camera, it will allow you to have a url with the video stream which is compatible iwth opencv and works just fine. i tested already.

do you have a tutorial for this?

All 3 comments

To prevent network glitches / video stream disconnection / etc OpenCV forces TCP transport protocol. You should reconfigure your rstp server for TCP support or use non-FFmpeg OpenCV backend (Gstreamer?).

BTW, Usage questions should go to Users OpenCV Q/A forum: http://answers.opencv.org

You may want to install the UV4L driver for the raspberry camera, it will allow you to have a url with the video stream which is compatible iwth opencv and works just fine. i tested already.

You may want to install the UV4L driver for the raspberry camera, it will allow you to have a url with the video stream which is compatible iwth opencv and works just fine. i tested already.

do you have a tutorial for this?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shravankumar147 picture shravankumar147  路  3Comments

charlesxwang picture charlesxwang  路  3Comments

koleckar picture koleckar  路  3Comments

opencv-pushbot picture opencv-pushbot  路  3Comments

orange-jacky picture orange-jacky  路  3Comments