import gpiozero
from gpiozero import MotionSensor
from picamera import PiCamera
from datetime import datetime
from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
from email.mime.text import MIMEText
import email.encoders
import smtplib
import os
import email
import sys
import time
camera = PiCamera()
pir = MotionSensor(4)
camera.rotation = 180 # delete or adjust to 90, 180, or 270 accordingly
camera.resolution = (1920, 1080)
h264_video = ".h264"
mp4_video = ".mp4"
while True:
# record h264 video then save as mp4
pir.wait_for_motion()
video_name = datetime.now().strftime("%m-%d-%Y_%H.%M.%S")
camera.start_recording(video_name + h264_video)
pir.wait_for_no_motion()
camera.wait_recording(30)
camera.stop_recording()
os.system("MP4Box -add " + video_name + h264_video + " " + video_name + mp4_video) # tutorial for install to make this conversion possible at: http://raspi.tv/2013/another-way-to-convert-raspberry-pi-camera-h264-output-to-mp4
os.system("rm " + video_name + h264_video) # delete h264 file
footage = video_name + mp4_video
'''Part 5 '''
# prepare the email
f_time = datetime.now().strftime("%A %B %d %Y @ %H:%M:%S")
msg = MIMEMultipart()
msg["Subject"] = f_time
msg["From"] = "
[email protected]" #configure sender email
msg["To"] = "
[email protected]" #configure receiver email
text =...