I'm developing a python program to receive a live streaming video from android device via RTMP. I created a server and also I'm capable of transmitting a videoStream from android device. But the problem is I can't access that stream in opencv. Can anyone tell me a way to access it via opencv. It is better if you can post any python code snippets.
Asked
Active
Viewed 1.4k times
8
-
Possible duplicate of [OpenCV won't capture frames from a RTMP source, while FFmpeg does](https://stackoverflow.com/questions/30096327/opencv-wont-capture-frames-from-a-rtmp-source-while-ffmpeg-does) – aergistal Sep 01 '17 at 06:24
-
Did you create the server in python with pyrtmp? I've had success reading frames with opencv when using "Local RTMP Server" on Mac or "MonaServer" on windows, but never when creating the RTMP server in python. – Peter Jun 01 '23 at 17:46
1 Answers
11
Just open the address instead of your cam :
myrtmp_addr = "rtmp://myip:1935/myapp/mystream"
cap = cv2.VideoCapture(myrtmp_addr)
frame,err = cap.read()
From there you can handle your frames like when you get it from your cam.
if it still doesn't work, check if you have a valid version of ffmpeg linked with your opencv. You can check it with
print(cv2.getBuildInformation())
Hope I could help

Martin Faucheux
- 884
- 9
- 26