-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpdated
More file actions
51 lines (45 loc) · 1.4 KB
/
Copy pathUpdated
File metadata and controls
51 lines (45 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import cv2
import os
from datetime import datetime
dest = '/home/gsurats1/Desktop'
os.chdir(dest)
interval = 5
cap2 = cv2.VideoCapture(2)
cap = cv2.VideoCapture(0)
cap.set(3, 640)
cap.set(4, 480)
cap2.set(3, 640)
cap2.set(4, 480)
start_time = datetime.now()
X = cv2.VideoWriter_fourcc(*'XVID')
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
fps = cap.get(cv2.CAP_PROP_FPS)
width2 = int(cap2.get(cv2.CAP_PROP_FRAME_WIDTH))
height2 = int(cap2.get(cv2.CAP_PROP_FRAME_HEIGHT))
fps2 = cap2.get(cv2.CAP_PROP_FPS)
i = 1
while True:
ret1, frame1 = cap.read()
ret2, frame2 = cap2.read()
cv2.imshow('Live1', frame1)
cv2.imshow('Live2', frame2)
current_time = datetime.now()
time_passed = (current_time - start_time).total_seconds()
if time_passed >= interval:
timestamp = current_time.strftime("%Y-%m-%d_%H-%M-%S")
file_name = 'video_{}.avi'.format(timestamp)
file_name2 = 'video2_{}.avi'.format(timestamp)
output = cv2.VideoWriter(file_name, X, fps, (width, height))
output2 = cv2.VideoWriter(file_name2, X, fps2, (width2, height2))
for j in range(150):
output.write(frame1)
output2.write(frame2)
output.release()
output2.release()
start_time = current_time
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cap2.release()
cv2.destroyAllWindows()