【问题标题】:How to get video frame by frame from stream using openCV and python如何使用openCV和python从流中逐帧获取视频
【发布时间】: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


【解决方案1】:

http://answers.opencv.org/question/24154/how-to-using-opencv-api-get-web-video-stream/

你应该可以cap = cv2.VideoCapture('yourStreamURIHere')

如果您需要登录到流,例如在 127.0.0.1 的某个流,用户名:hello,密码:goodbye:

cap = cv2.VideoCapture('http://hello:goodbye@127.0.0.1/?action=stream?otherparamshere)

【讨论】:

    【解决方案2】:

    我有点晚了,但我创建了强大的线程化 VidGear 视频处理 python 库,现在提供 NetGear API,它专门用于通过网络在互连系统之间实时同步传输视频帧通过 ZmQ 消息系统。 用法示例,请在此处查看我的详细答案: https://stackoverflow.com/a/57205019/10158117

    【讨论】:

      猜你喜欢
      • 2013-09-28
      • 2018-03-09
      • 1970-01-01
      • 2013-11-08
      • 1970-01-01
      • 2017-12-31
      • 2012-03-04
      • 2018-01-27
      • 2015-08-28
      相关资源
      最近更新 更多