|
|
@ -12,15 +12,13 @@ def five_minute_segment_from(the_time): |
|
|
|
def path_to_video_at(time_stamp): |
|
|
|
def path_to_video_at(time_stamp): |
|
|
|
return 'videos/' + str(time_stamp) + '.mkv' # mkv required for h264 encoding |
|
|
|
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 |
|
|
|
#delay for long delay |
|
|
|
long_delay = timedelta(minutes=1) |
|
|
|
long_delay = timedelta(minutes=1) |
|
|
|
|
|
|
|
|
|
|
|
last_time_stamp = five_minute_segment_from(datetime.now()) |
|
|
|
last_time_stamp = five_minute_segment_from(datetime.now()) |
|
|
|
|
|
|
|
|
|
|
|
# live webcam feed |
|
|
|
# live webcam feed |
|
|
|
camera = cv2.VideoCapture(0, cv2.CAP_FFMPEG) |
|
|
|
camera = cv2.VideoCapture(0) |
|
|
|
if not camera.isOpened(): |
|
|
|
if not camera.isOpened(): |
|
|
|
print("Cannot open camera") |
|
|
|
print("Cannot open camera") |
|
|
|
exit() |
|
|
|
exit() |
|
|
@ -35,7 +33,7 @@ video_writer = cv2.VideoWriter(path_to_video_at(last_time_stamp), |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
# video feed from previously captured video |
|
|
|
# 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 |
|
|
|
# fullscreen window yess good |
|
|
|
cv2.namedWindow("mirror", cv2.WINDOW_NORMAL) |
|
|
|
cv2.namedWindow("mirror", cv2.WINDOW_NORMAL) |
|
|
@ -46,8 +44,8 @@ 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? |
|
|
|
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) |
|
|
|
longterm = False # are we shoowing a long term delay? (versus a sshort term delay) |
|
|
|
|
|
|
|
|
|
|
|
with keep.presenting(): |
|
|
|
#with keep.presenting(): |
|
|
|
while(True): |
|
|
|
while(True): |
|
|
|
if last_time_stamp != five_minute_segment_from(datetime.now()): |
|
|
|
if last_time_stamp != five_minute_segment_from(datetime.now()): |
|
|
|
# find file older than our long delay |
|
|
|
# find file older than our long delay |
|
|
|
old_file = path_to_video_at(five_minute_segment_from(datetime.now() - long_delay - timedelta(minutes=1))) |
|
|
|
old_file = path_to_video_at(five_minute_segment_from(datetime.now() - long_delay - timedelta(minutes=1))) |
|
|
@ -105,6 +103,7 @@ with keep.presenting(): |
|
|
|
|
|
|
|
|
|
|
|
# After the loop release the cap object |
|
|
|
# After the loop release the cap object |
|
|
|
camera.release() |
|
|
|
camera.release() |
|
|
|
out.release() |
|
|
|
old_time.release() |
|
|
|
|
|
|
|
video_writer.release() |
|
|
|
# Destroy all the windows |
|
|
|
# Destroy all the windows |
|
|
|
cv2.destroyAllWindows() |
|
|
|
cv2.destroyAllWindows() |
|
|
|