My objective is to print a continuously updating time stamp on every second of a ten-minute video recording instead of one that updates every minute. I'm running the picamera module of python version 2.7 on Raspberry Pi zero.
So far, I have been able to place a time stamp on the first and last frames of the video recording but not in between. Here is my coded attempt for displaying the time stamp.
camera.annotate_background = picamera.Color('black') #this determines the background color camera.annotate_text = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') #places timestamp on first frame of video date_string=time.strftime("%Y-%m-%d_%H-%M") #this gets the time as a string camera.start_recording('/home/pi/Desktop/Mouse_Monitoring/IS-11255x_' + date_string + '.h264') #camera begins recording and file is saved under this name start = datetime.datetime.now() #this stores the time that recording starts print(start) #this prints time that recording starts while (datetime.datetime.now() - start).seconds < (segment_length_min*60): #this indicates to continue filming until you reach the maximize time for a given recording sgement camera.wait_recording(segment_length_min*60) camera.annotate_text = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') #this places a timestamp on final frame of video time.sleep(5) #this allows enough time to place the final timestamp on the video camera.stop_recording() #terminates recording
Here, the camera enters into the filming loop, places a timestamp on the first frame of the video, and then begins recording. It records until the video reaches the maximimum time for a given segment of video (e.g if you set the maximum time for a single recording to be five minutes, it will stop recording after five minutes and begin a new recording session). The camera.wait_recording line indicates how long to record for, and the camera.annotate_text line places a time in the Year/Month/Day/Hour/Minute/Second format on the final frame of the video recording. I initially tried moving the camera.annotate_text line inside the while statement, but it appears that when the camera.wait_recording line executes, it ignores any line of code below it until it is finished executing.
In summary, this coded attempt only displays an updating time stamp on the first and last frames of the video. I want to display the accurate time during every second of the video. I would be grateful for any suggestions you have on this matter. Thank you!