Commit 8212814d authored by LockhomeDevelopper's avatar LockhomeDevelopper
Browse files

Up

parent 1cbdc274
......@@ -11,14 +11,15 @@ from http import server
import datetime
import time
import ffmpeg
import socket
PAGE="""\
<html>
<head>
<title>Caméra de surveillance</title>
<title>Camera de surveillance</title>
</head>
<body>
<center><h1>Caméra de surveillance</h1></center>
<center><h1>Camera de surveillance</h1></center>
<center><img src="stream.mjpg" style="width:50%" ></center>
</body>
</html>
......@@ -27,7 +28,7 @@ PAGE="""\
STREAMING="""\
<html>
<head>
<title>Caméra de surveillance</title>
<title>Camera de surveillance</title>
</head>
<body>
<video controls src="__URL__" style="width:50%" autoplay ></video>
......@@ -37,6 +38,14 @@ STREAMING="""\
RECORDING = False
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("8.8.8.8", 80))
print("L'IP de cette camera est : " + s.getsockname()[0])
print("Démarrage de la caméra")
s.close()
class StreamingOutput(object):
def __init__(self):
self.frame = None
......@@ -96,6 +105,7 @@ class StreamingHandler(server.BaseHTTPRequestHandler):
self.end_headers()
self.wfile.write(content)
elif "record" in self.path :
min = self.path.split("/")[2].replace("/", "")
self.send_response(200)
self.end_headers()
self.wfile.write("ok".encode('utf-8'))
......@@ -107,13 +117,13 @@ class StreamingHandler(server.BaseHTTPRequestHandler):
name = today.strftime("%d-%m-%Y_%Hh%M") #on met comme nom de fichier l'heure et la date de l'enregistrement (hh:mm:ss-JJ-MM-YY)
camera.start_recording("./RECORD_RAW/" + name + ".h264", format="h264", splitter_port=1) #début du record avec nom du fichier
print ("Enregistrement démarré : "+ name)
time.sleep(30)
time.sleep(int(min))
camera.stop_recording()
print ("Fin enregistrement")
RECORDING = False
ffmpeg.input("./RECORD_RAW/" + name + ".h264").output("./RECORD/" + name + '.mp4').run()
ffmpeg.input("./RECORD_RAW/" + name + ".h264").output("./RECORD/" + name + '.mp4').overwrite_output().run()
remove("./RECORD_RAW/" + name + ".h264")
RECORDING = False
elif "stream.mjpg" in self.path :
self.send_response(200)
......@@ -157,4 +167,4 @@ with picamera.PiCamera(resolution='1296x730', framerate=30) as camera:
server = StreamingServer(address, StreamingHandler)
server.serve_forever()
finally:
camera.stop_recording()
\ No newline at end of file
camera.stop_recording()
TODO: Ajouter dans le guide du dev comment configurer apache
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment