1

I would like to record videos using this code:

RecordIntervalTime = 30*60 # 30 min
def camRecord():
with picamera.PiCamera() as camera:
    camera.resolution = (640, 480)
    camera.framerate = 24
    camera.rotation = 90
    camera.annotate_background = picamera.Color('black')
    camera.annotate_text = dt.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
    camera.annotate_text_size = 16
    date_string = time.strftime("%Y-%m-%d_%H-%M")
    device_name = socket.gethostname()  # device (sensor) name
    print('Start recording with' + device_name + '_' + date_string)
    camera.start_recording('/home/pi/' + device_name + '_' + date_string + '.h264', quality=20,
                           bitrate=2*1000000)
    start = dt.datetime.now()
    while (dt.datetime.now() - start).seconds < RecordIntervalTime:
        camera.annotate_text = ' (' + device_name + ') ' + dt.datetime.now().strftime('%Y-%m-%d %H:%M:%S') + ' '
        camera.wait_recording(1)
    camera.stop_recording()
    print('end recording')
    time.sleep(1)

if __name__ == '__main__':
    while True:
        print('Recording start')
        camRecord()
        time.sleep(10)

My intention is recording the videos with 30 minutes interval until running out of battery. When I conducted an experiments with 10 sensors and the code, there are different results of the recording. For example, while one device recorded videos from 9:00 to 14:00 (not the time of running out), the other recorded that from 9:00 to 24:00 (the time of running out, I would like to make that).

Do you think that the differences from the code?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.