Python Script to start the recording using Picamara in Rasoberry Pi
Hii guys....
Today I'm going to write a python script to start the video recording in Picamera Using RaspberryPi..
For that You the following equpiment You need to integtare with raspberry pi..
Today I'm going to write a python script to start the video recording in Picamera Using RaspberryPi..
For that You the following equpiment You need to integtare with raspberry pi..
- PiCamera Connected to raspberry pi
- Pir Sensor module connected to GPIO Pin to raspbeery Pi
- 5V Rapberry Pi Charger
Now, Here I am going to write the python script to start recording :
import RPi.GPIO as GPIO
import time
import picamera
import datetime # new
def get_file_name(): # new
return datetime.datetime.now().strftime("%Y-%m-%d_%H.%M.%S.h264")
sensor = 4
GPIO.setmode(GPIO.BCM)
GPIO.setup(sensor, GPIO.IN, GPIO.PUD_DOWN)
previous_state = False
current_state = False
cam = picamera.PiCamera()
while True:
time.sleep(0.1)
previous_state = current_state
current_state = GPIO.input(sensor)
if current_state != previous_state:
new_state = "HIGH" if current_state else "LOW"
print("GPIO pin %s is %s" % (sensor, new_state))
if current_state:
fileName = get_file_name() # new
cam.start_preview()
cam.start_recording(fileName) # new
else:
cam.stop_preview()
cam.stop_recording() # new
by Executing this program You will get the .H264 Video file, which will save in the same folder of your python script. This file shows date as a file name..
Comments
Post a Comment