I want to process an rtsp stream created from a raspberry camera frame by frame with python or C++.
.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?
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?
Most helpful comment
do you have a tutorial for this?