I'm using VLC media player to stream .mp4 video using http. Streaming works fine (i was able to attach to this stream using another instance of VLC). Now I want to connect to this stream using OpenCV with python 2.7 and get video frame by frame.
This is modified tutorial code (which works perfectly fine with local file):
<code>
import numpy as np
import cv2
address = '10.0.0.71' # this is my stream ip address
port = 8080 # this is stream port
# should I use socket somehow?
# found this somewhere, no idea what this do
# import socket
# msocket = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
# msocket.connect((address, port))
cap = cv2.VideoCapture('file.mp4') # how to use VideoCapture with online stream?
# just showing video to screen
while(cap.isOpened()):
ret, frame = cap.read()
cv2.imshow('frame', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
Please help.
http://answers.opencv.org/question/24154/how-to-using-opencv-api-get-web-video-stream/
You should be able to just cap = cv2.VideoCapture('yourStreamURIHere')
If you need to login to the stream, for example some stream at 127.0.0.1 with username: hello, password: goodbye:
cap = cv2.VideoCapture('http://hello:goodbye@127.0.0.1/?action=stream?otherparamshere)