I am trying to record a video using camera.start_recording
from picamera
package until a specific predefined time is reached.
I was trying to counter this problem using code similar to the following MWE.
import picamera
import time
time_to_record = 15
camera = picamera.PiCamera()
camera.resolution = (1920, 1080)
camera.framerate = 24
end_time = time.time() + time_to_record
while time.time() <= end_time:
camera.start_recording('Test.h264', format='h264')
# Here is another functions that samples a value from a thermocouple and annotates it in the video
Because of the function mentioned in the comment I'm not able to use the method camera.wait_recording()
from the picamera
package.
The camera needs to run for a specific time so the loop has to stay.
When I run my code I get the following exception:
camera.PiCameraAlreadyRecording
which mentions that the Camera is already recording. I'm think that this is a problem comming from the while loop because the camera.start_recording()
method is called multiple times.
I don't have an idea how I can avoid this problem without dropping the ability to record for a specific time. Maybe someone has an idea?