Feb-24-2023, 03:39 PM
Dear everyone,
for an ecological study I recorded insects in front of a nesting aid with a Raspberry Pi. I wrote a simple python code to do this which I looped via a crontab (at least I thought it was simple). After I rewatched my videos, I noticed that the recordings did not stop after one hour (as I intended) but recorded on, until my energy saving tool (a wittyPi) powered the Raspberry Pi down (and I wondered why a couple of USB-sticks kicked the bucket
) . Although I got my videos, it still bugs me - what is wrong with my code? Maybe anyone knows?
for an ecological study I recorded insects in front of a nesting aid with a Raspberry Pi. I wrote a simple python code to do this which I looped via a crontab (at least I thought it was simple). After I rewatched my videos, I noticed that the recordings did not stop after one hour (as I intended) but recorded on, until my energy saving tool (a wittyPi) powered the Raspberry Pi down (and I wondered why a couple of USB-sticks kicked the bucket
import datetime
import time
date = datetime.datetime.now().strftime("%m_%d_%Y_%H_%M_%S")
import picamera
camera = picamera.PiCamera()
camera.annotate_background = picamera.Color('black') #this determines the background color
camera.annotate_text = date #places timestamp on first frame of video
camera.start_recording("/media/pi/SD_02/"+ "Plotxx_" + date + ".h264")
start = datetime.datetime.now()
while (datetime.datetime.now() - start).seconds < (3600):#this indicates to continue filming until you reach the maximize time for a given recording segment
camera.annotate_text = datetime.datetime.now().strftime('%d-%m-%Y %H:%M:%S')
camera.wait_recording(0.2)
camera.wait_recording(3600)
camera.stop_recording()
