One of the biggest problems with the built in commands for using the Raspberry Pi Camera module is that you can’t stop a recording after an unknown time. You can record for a given number of seconds and that’s it. I have attempted to solve this problem by backgrounding the initial record process with a time of 27777.8 hours (99999999 seconds) when it’s time to stop recording, the process is manually killed using pkill.
Here is a test of my code, which I’ve called CameraModulePlus (written in python) which takes two videos, one for five seconds, and one for ten seconds, with a 10 second delay in between.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
from CameraModulePlus import CameraModuleVideo
import subprocess
from time import sleep
import time
v1 = CameraModuleVideo(“/home/pi/CreatureCapture/”, “video1”)
v2 = CameraModuleVideo(“/home/pi/CreatureCapture/”, “video2”)
try:
v1.startRecording()
time.sleep(5)
v1.stopRecording()
time.sleep(10)
v2.startRecording()
time.sleep(10)
v2.stopRecording()
except ValueError as e:
print(e)
|
Here is a result of the 5 second duration test:
Here is a result of the 10 second duration test:
View more at: http://yoursmart.mobi
Post a Comment