Video-Summary/generate test footage/kap.py

34 lines
749 B
Python
Raw Normal View History

2020-11-05 22:17:05 +00:00
#python
import cv2
import imageio
import time
2020-11-08 15:28:47 +00:00
writer = imageio.get_writer("./x23.mp4", fps=15)
2020-11-05 22:17:05 +00:00
url = "http://50.227.41.1/mjpg/video.mjpg"
i = 0
cap = cv2.VideoCapture(url)
while True :
try:
if i < 10:
i+=1
continue
result, frame = cap.read()
if result == False:
print("Error in cap.read()") # this is for preventing a breaking error
# break;
time.sleep(1)
2020-11-08 15:28:47 +00:00
break
2020-11-05 22:17:05 +00:00
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
writer.append_data(frame)
i+=1
2020-11-08 15:28:47 +00:00
if i > 20*60*60*2:
2020-11-05 22:17:05 +00:00
break
except Exception as e:
2020-11-08 15:28:47 +00:00
print("meh")
cap.release()
cv2.destroyAllWindows()
writer.close()