Преобразовать html для блога:
http://www.elliotswan.com/postable/
bash:
#!/bin/bash
echo " Преобразовать html код"
echo " например для blogger.com"
echo " * * * нажать Enter чтобы продолжить * * *"
echo " Вставить html код..."
read T
truncate -s 0 /tmp/0.html
nano /tmp/0.html
sed 's/&/\&/g; s/</\</g; s/>/\>/g; s/"/\"/g; s/'"'"'/\'/g' /tmp/0.html > /tmp/1.html
cat /tmp/1.html
nano stream_mjpg.py
-----------------------------------------------
import picamera
import io
import logging
import socketserver
import datetime as dt
from threading import Condition
from http import server
PAGE="""\
<html>
<head>
<title>Raspberry Pi - My Camera</title>
</head>
<body>
<center><h1>Raspberry Pi - My Camera</h1></center>
<center><img src="stream.mjpg" width="960" height="580"></center>
</body>
</html>
"""
class StreamingOutput(object):
def __init__(self):
self.frame = None
self.buffer = io.BytesIO()
self.condition = Condition()
def write(self, buf):
if buf.startswith(b'\xff\xd8'):
self.buffer.truncate()
with self.condition:
self.frame = self.buffer.getvalue()
self.condition.notify_all()
self.buffer.seek(0)
return self.buffer.write(buf)
class StreamingHandler(server.BaseHTTPRequestHandler):
def do_GET(self):
if self.path == '/':
self.send_response(301)
self.send_header('Location', '/index.html')
self.end_headers()
elif self.path == '/index.html':
content = PAGE.encode('utf-8')
self.send_response(200)
self.send_header('Content-Type', 'text/html')
self.send_header('Content-Length', len(content))
self.end_headers()
self.wfile.write(content)
elif self.path == '/stream.mjpg':
self.send_response(200)
self.send_header('Age', 0)
self.send_header('Cache-Control', 'no-cache, private')
self.send_header('Pragma', 'no-cache')
self.send_header('Content-Type', 'multipart/x-mixed-replace; boundary=FRAME')
self.end_headers()
try:
while True:
with output.condition:
output.condition.wait()
frame = output.frame
self.wfile.write(b'--FRAME\r\n')
self.send_header('Content-Type', 'image/jpeg')
self.send_header('Content-Length', len(frame))
self.end_headers()
self.wfile.write(frame)
self.wfile.write(b'\r\n')
except Exception as e:
logging.warning(
'Removed streaming client %s: %s',
self.client_address, str(e))
else:
self.send_error(404)
self.end_headers()
class StreamingServer(socketserver.ThreadingMixIn, server.HTTPServer):
allow_reuse_address = True
daemon_threads = True
with picamera.PiCamera() as camera:
output = StreamingOutput()
camera.rotation = 180
camera.color_effects = (128,128)
camera.contrast = 60
camera.brightness = 80
camera.iso = 600
camera.resolution = (1920, 1080)
camera.framerate = 29
camera.start_recording(output, format='mjpeg')
try:
address = ('', 8000)
server = StreamingServer(address, StreamingHandler)
server.serve_forever()
finally:
camera.stop_recording()
воскресенье, 20 октября 2019 г.
Подписаться на:
Комментарии к сообщению (Atom)
h265.sh
#!/bin/bash file="../mp4" if [ -d $file ]; then echo " Директория существует :-) " for i in *.mp4; do f...
-
30 мая воплотилась в жизнь давняя мечта -- покататься на лодке. Плюс к тому в тот же день я попробовал свои силы в тире. Не разочаровался в ...
-
#!/bin/bash file="../mp4" if [ -d $file ]; then echo " Директория существует :-) " for i in *.mp4; do f...
Комментариев нет:
Отправить комментарий