即時通訊嘗試在ubuntu上使用Opencv3(安裝在conda
env中)在我的python腳本中讀取mp4文件。但得到以下消息:Anaconda和Opencv不打開mp4
Unable to stop the stream: Inappropriate ioctl for device
我發現Opencv不支持開箱即用的mp4。是否有可能在我的機器上安裝額外的庫以使視頻工作而不重建Opencv?一些配置可能?
這裏談到的代碼:
def workOnVideoFile(path) :
print('Reading the video from ' + path)
cap = cv2.VideoCapture(path)
print('Is video opened? ' + str(cap.isOpened()))
while(cap.isOpened()):
ret, frame = cap.read()
print('Frame has been read ' + str(ret))
workOnFrame(frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
print('Releasing the video' + str(cap))
cap.release()
#img = cv2.imread('car.jpg')
if __name__ == "__main__":
if (os.path.isfile(videoFile)) :
workOnVideoFile(videoFile)
else :
print('File ' + videoFile + ' is not found')
cv2.destroyAllWindows()
它是否像任何mp4文件中描述的那樣工作?你能否分享一個小的mp4文件,爲什麼它會失敗。 –
任何文件,但由於@Mick提到的專利,Ubuntu有視頻問題。 – Anton