So I was trying out this exact same script in this answer https://raspberrypi.stackexchange.com/a/46513 but when I tried to run it (for the second or third time) it gave me this exception:
Exception in thread Thread-1: Traceback (most recent call last): File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner self.run() File "/usr/lib/python2.7/threading.py", line 763, in run self.__target(*self.__args, **self.__kwargs) File "/usr/lib/python2.7/dist-packages/gpiozero/mixins.py", line 509, in fill self.parent._fire_events() File "/usr/lib/python2.7/dist-packages/gpiozero/mixins.py", line 327, in _fire_events self._fire_deactivated() File "/usr/lib/python2.7/dist-packages/gpiozero/mixins.py", line 306, in _fire_deactivated self.when_deactivated() File "PIRscript.py", line 24, in finish_video camera.stop_recording() File "/usr/lib/python2.7/dist-packages/picamera/camera.py", line 1193, in stop_recording 'port %d' % splitter_port) PiCameraNotRecording: There is no recording in progress on port 1
I rebooted my pi and tried starting up the script again, but I keep getting this error. This seems like it's because I don't close the camera anywhere, but I need to know
- how do I handle this exception now i.e. how do I make this error go away?
- how do I change my code to make it close the camera safely?