|
|
|
@ -12,15 +12,13 @@ def five_minute_segment_from(the_time): |
|
|
|
|
def path_to_video_at(time_stamp): |
|
|
|
|
return 'videos/' + str(time_stamp) + '.mkv' # mkv required for h264 encoding |
|
|
|
|
|
|
|
|
|
os.environ["OPENCV_FFMPEG_CAPTURE_OPTIONS"]="hwaccel;vaapi;hw_decoders_any;vaapi,vdpau" # maybe this enables hardware accelerated ffmpeg? |
|
|
|
|
|
|
|
|
|
#delay for long delay |
|
|
|
|
long_delay = timedelta(minutes=1) |
|
|
|
|
|
|
|
|
|
last_time_stamp = five_minute_segment_from(datetime.now()) |
|
|
|
|
|
|
|
|
|
# live webcam feed |
|
|
|
|
camera = cv2.VideoCapture(0, cv2.CAP_FFMPEG) |
|
|
|
|
camera = cv2.VideoCapture(0) |
|
|
|
|
if not camera.isOpened(): |
|
|
|
|
print("Cannot open camera") |
|
|
|
|
exit() |
|
|
|
@ -35,7 +33,7 @@ video_writer = cv2.VideoWriter(path_to_video_at(last_time_stamp), |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
# video feed from previously captured video |
|
|
|
|
old_time = cv2.VideoCapture(path_to_video_at(last_time_stamp), cv2.CAP_FFMPEG) |
|
|
|
|
old_time = cv2.VideoCapture(path_to_video_at(last_time_stamp)) |
|
|
|
|
|
|
|
|
|
# fullscreen window yess good |
|
|
|
|
cv2.namedWindow("mirror", cv2.WINDOW_NORMAL) |
|
|
|
@ -46,7 +44,7 @@ idx = 0 # current index into the frame queue |
|
|
|
|
short_term_delay_frames = 20 # hoow many frames back are we going in the buffer when we're on a short term delay? |
|
|
|
|
longterm = False # are we shoowing a long term delay? (versus a sshort term delay) |
|
|
|
|
|
|
|
|
|
with keep.presenting(): |
|
|
|
|
#with keep.presenting(): |
|
|
|
|
while(True): |
|
|
|
|
if last_time_stamp != five_minute_segment_from(datetime.now()): |
|
|
|
|
# find file older than our long delay |
|
|
|
@ -105,6 +103,7 @@ with keep.presenting(): |
|
|
|
|
|
|
|
|
|
# After the loop release the cap object |
|
|
|
|
camera.release() |
|
|
|
|
out.release() |
|
|
|
|
old_time.release() |
|
|
|
|
video_writer.release() |
|
|
|
|
# Destroy all the windows |
|
|
|
|
cv2.destroyAllWindows() |
|
|
|
|