我想用Python用OpenCV处理mms视频流。 流来自一个我无法控制的IP摄像头(流量监视器)。 流可用作mms或mmst方案-
mms://194.90.203.111/cam2
在VLC和Windows Media Player上播放。
mmst://194.90.203.111/cam2
只适用于VLC。 我曾试图通过使用FFmpeg和VLC重新流式传输将方案更改为HTTP,但没有成功。
据我所知,mms正在使用Windows媒体视频对流进行编码。在URI的末尾加上“.mjpeg”不走运。我还没有找到OpenCV接受的流媒体类型。
这是我的密码-
import cv2, platform
#import numpy as np
cam = "mms://194.90.203.111/cam2"
#cam = 0 # Use local webcam.
cap = cv2.VideoCapture(cam)
if not cap:
print("!!! Failed VideoCapture: invalid parameter!")
while(True):
# Capture frame-by-frame
ret, current_frame = cap.read()
if type(current_frame) == type(None):
print("!!! Couldn't read frame!")
break
# Display the resulting frame
cv2.imshow('frame',current_frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# release the capture
cap.release()
cv2.destroyAllWindows()
那个 我错过了什么?OpenCV可以捕获什么类型的视频流? 有没有一个优雅的解决方案,而不改变方案或转码?
谢谢!
Python 2.7.8版,OpenCV的2.4.9版,都是x86。Win7 x64版本
使用FFmpeg和FFserver解决。注意FFserver只在Linux上工作。 该解决方案使用来自here的python代码,如Ryan所建议的。
流程如下-
运行FFserver
在第二个终端上运行FFmpeg
Python代码。在这种情况下,代码将打开一个包含视频流的窗口。
ffserver.config-
请注意,这个ffserver.config需要进行更多的微调,但它们工作得相当好,只需稍微冻结一点帧,就可以生成非常接近源代码的帧。
相关问题 更多 >
编程相关推荐