从多个摄像头写入视频

时间:2016-09-21 09:37:24

标签: python-2.7 opencv video

我存储了多个视频。我想通过提供视频捕获对象的路径来从这些多个视频中编写视频。我想写一个视频,从这些多个视频中获取帧。那么有没有办法从不同的视频中读取帧而不创建多个捕获对象

1 个答案:

答案 0 :(得分: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()