Page 1 of 1

While true

Posted: Thu Jun 25, 2015 5:41 am
by brizey
I am wanting to use this code in a infinite loop where it overwrites the files 1-10, Can someone please help with a example
would it be while true:

Code: Select all

import picamera

with picamera.PiCamera() as camera:
    camera.resolution = (640, 480)
    camera.start_recording('1.h264')
    camera.wait_recording(5)
    for i in range(2, 11):
        camera.split_recording('%d.h264' % i)
        camera.wait_recording(5)
    camera.stop_recording()

Re: While true

Posted: Thu Jun 25, 2015 8:28 am
by elParaguayo
That code looks very similar to the one in this post (although motopi never replied to say if it was now working...)

Re: While true

Posted: Thu Jun 25, 2015 2:03 pm
by RST8
I'm not familiar with the picamera api, but if all you want to do is put the code in an infinite loop then a

Code: Select all

while True:
   #code that goes on forever here
will do the trick. However are you planning to constantly record and limit the 10 files to a certain duration / size ? Are they going to be constantly overwritten once 10 files of a certain size / duration have been recorded?
It's not clear from your code as to what the aim is with when to split the files.
Does the camera.stop_recording need to execute to write out the files? Does it need to execute at some point?

Joe