Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import subprocess
- import RPi.GPIO as GPIO
- from time import sleep,strftime
- GPIO.setmode(GPIO.BCM)
- GPIO.setup(4, GPIO.IN)
- while True:
- if (GPIO.input(4) == False):
- sleep(.25)
- time=strftime("%H-%M-%S_%d-%m-%Y")
- if (GPIO.input(4) == True):
- cmd0='raspistill -t 10 -o /home/pi/' + time + '.jpg'
- subprocess.call("%s" % cmd0, shell=True)
- sleep(1.0)
- else:
- loop = 1
- cmd1='raspivid -t 0 -o /home/pi/' + time + '.h264'
- subprocess.Popen("%s" % cmd1, shell=True)
- sleep(1.0)
- while (loop == 1):
- if (GPIO.input(4) == False):
- cmd2='pkill raspivid'
- cmd3='MP4Box -add /home/pi/' + time + '.h264 /home/pi/' + time + '.mp4'
- cmd4='rm -f /home/pi/' + time + '.h264'
- subprocess.call("%s" % cmd2, shell=True)
- subprocess.call("%s" % cmd3, shell=True)
- subprocess.call("%s" % cmd4, shell=True)
- sleep(1.0)
- loop='0'
- sleep(0.1);
- sleep(0.1);
Advertisement
Add Comment
Please, Sign In to add comment