2016-09-21 177 views
1

我有多個視頻存儲。我想通過爲視頻捕獲對象提供路徑來從這些多個視頻中編寫視頻。我想編寫一個從這些多個視頻中獲取幀的視頻。那麼,有沒有辦法讀取來自不同的視頻幀,而無需創建多個捕獲目標從多個攝像頭寫視頻

回答

0

一種方法是保存文件路徑爲您的影片在一個數組,然後使用VideoCapture :: open方法,如圖所示:

video = cv2.VideoWriter('video.avi','''other args''') 
filePath=["File/Path/1","File/Path/2"]#and so on 
cap=cv2.Videocapture(0)#just for initialization, we don't need live cam 

for i in range(len(filePath)): 
    cap.open(filePath[i]) 
    while(cap.isOpened()) 
     ret,img=cap.read() 
     video.write(img) 
video.release() 
相關問題