brizey
Posts: 1
Joined: Thu Jun 25, 2015 5:37 am

While true

Thu Jun 25, 2015 5:41 am

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()

User avatar
elParaguayo
Posts: 1943
Joined: Wed May 16, 2012 12:46 pm
Location: London, UK

Re: While true

Thu Jun 25, 2015 8:28 am

That code looks very similar to the one in this post (although motopi never replied to say if it was now working...)
RPi Information Screen: plugin based system for displaying weather, travel information, football scores etc.

User avatar
RST8
Posts: 64
Joined: Tue Nov 25, 2014 1:57 pm

Re: While true

Thu Jun 25, 2015 2:03 pm

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

Return to “Python”