I'm using my picamera in combination with the raspberry pi to capture video data synchrounously to other sensor data. Every sensor captures data in its own thread. All sensors start at the start of the program and when a SIGINT signal is received all threads join and program exits gracefully.
I have trouble with my picamera. Therefore I opened an issue at https://github.com/waveform80/picamera/issues/478.
The copy of the issue as a later reference:
Goal: I'm using the pi camera in a really simple scenario. My goal is to record a video when my python-script starts and to stop it when SIGINT is sent to my program.
Issue: There are missing several seconds (>10s) at the end of a two minutes video.
import picamera import os # File camera_filename = acttime + '_camera.h264' camera_filepath = measurement_basepath + camera_filename cameraFileObj = open(camera_filepath, 'wb') # Picamera camera = picamera.PiCamera() camera.sensor_mode = 6 camera.framerate = 60 camera.resolution = (1280, 720) # Recording camera.start_recording(cameraFileObj, format='h264', sei=False, sps_timing=True) print('Video has been started: '+ str(time.time())) # Wait for stop signal (stop mechanism is not shown) while not self.stopper.is_set(): camera.wait_recording() camera.stop_recording() print('Video has been stopped: ' + str(time.time())) cameraFileObj.flush() os.fsync(cameraFileObj.fileno()) cameraFileObj.close() camera.close()
Example output from console:
Video has been started: 1522408341.1150882 s
Video has been stopped: 1522408503.7099283 s
Calculated time difference between start and stop: 162.5948401 s
Video length: 149.233 s
In this example there are missing more than 13 s. The missing time is also visible in the video images (missing scene).
What could causing this behaviour?
Does anybody of you has some advice? In the documentation of picamera I was not able to find information about this topic.