How can I capture a SRT stream?

Viewed 572

I have established an SRT Stream from a Raspberry Pi to my PC. Everything works fine. I am also able to watch the stream with VLC. Now I want to capture the stream in Python.

With RTMP and HTTP the command

cap = cv2.VideoCapture("srt://IP:PORT")
frame = cap.read()

worked without any problem.

But with SRT, OpenCV does not even try to capture the stream.

What could I do?

Edit:

Some more information about my project: I have a USB Camera connected with my Raspberry Pi and stream this live video over SRT. I installed SRT from Haivision and created the stream with the following command:

./srt-live-transmit udp://:1234 srt://:4201 -v 

The UDP path is the input of the USB camera. To watch the stream locally on the Raspberry Pi over ffplay works. As I said before, to consume the Video on my PC also worked. With OBS, until now, I was not able to start the stream.

1 Answers

There are three ways:

1. Use RTSP instead of SRT
I couldn`t find any data on how to decode SRT in python, and there is an only official library and example codes for C in Haivision in their GitHub repo, so the easiest way is to change the video streaming protocol for RPI.
There is good example instruction on how to stream video in RTSP from RPI camera..
Pros: Easy to do.
Cons: Not SRT if it is a requirement.

2. Use SRT but not Python
There are documented examples of code to create an SRT client script, but they are in C and I did not find any data about the python library or example code for SRT. But there is a good example in C: example from Git Haivision
On the other hand, OpenCV is also a C-based library. As a result, you may start to learn the C language.
Pros: OpenCV and SRT by Haivision are C-based, so it is even better to use C.
Cons: C is hard to learn.

3. Develop C wrapper for Python
If you have a friend that can develop in C, then create a client library or even client API for python.
There is how C wrappers work.

Pros: it is easier for you.
Cons: it is not easy for your friend.

Related