从多个摄像头写视频
问题描述:
我有多个视频存储。我想通过为视频捕获对象提供路径来从这些多个视频中编写视频。我想编写一个从这些多个视频中获取帧的视频。那么,有没有办法读取来自不同的视频帧,而无需创建多个捕获目标从多个摄像头写视频
答
一种方法是保存文件路径为您的影片在一个数组,然后使用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()