2017-02-10 103 views
1

即時通訊嘗試在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() 
+0

它是否像任何mp4文件中描述的那樣工作?你能否分享一個小的mp4文件,爲什麼它會失敗。 –

+0

任何文件,但由於@Mick提到的專利,Ubuntu有視頻問題。 – Anton

回答

1

我認爲它可能是Ubuntu的這是不支持MP4開箱 - 這是因爲MP4有一些專利問題。

通常的做法是在一個標準的方式添加支持MP4到Ubuntu的安裝是這樣的:

命令和apt-get安裝Ubuntu的限制,演員

這個名字也許看起來有點奇怪,但它或多或少標準做法 - 請參閱幫助文章在這裏向您保證:

許多想要播放視頻的人只需安裝VideoLan即可完成所有這些操作,因此他們無需執行上述步驟。

+0

我做了stepabove它沒有幫助 – Anton

+0

基本上這是我的問題,要安裝和/或如何配置,以使opencv承認變化。通過may可以在Mac上正常工作 – Anton