【发布时间】:2016-07-15 21:07:21
【问题描述】:
我正在使用 VLC 媒体播放器通过 http 流式传输 .mp4 视频。流工作正常(我能够使用 VLC 的另一个实例附加到此流)。 现在我想使用 OpenCV 和 python 2.7 连接到这个流并逐帧获取视频。
这是修改后的教程代码(与本地文件完美配合):
<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()
请帮忙。
【问题讨论】:
标签: python sockets opencv video frame