Compare commits

...

3 Commits

Author SHA1 Message Date
Alexander Popov 22e024ab90
CHANGES :) 2024-03-20 00:28:23 +03:00
Alexander Popov 813b58a4b0
CV: Camera->RTMP 2024-03-20 00:27:28 +03:00
Alexander Popov afcda27417
Check SSL details 2024-03-20 00:23:02 +03:00
4 changed files with 94 additions and 3 deletions

View File

@ -0,0 +1,50 @@
"""
https://stackoverflow.com/questions/41620369/how-to-get-ssl-certificate-details-using-python
"""
import socket
import ssl
import datetime
domains = [
'iiiypuk.me',
'a2s.su',
'ya.ru'
]
def ssl_expiry_datetime(hostname):
ssl_dateformat = r'%b %d %H:%M:%S %Y %Z'
context = ssl.create_default_context()
context.check_hostname = False
conn = context.wrap_socket(
socket.socket(socket.AF_INET),
server_hostname=hostname,
)
# 5 second timeout
conn.settimeout(5.0)
conn.connect((hostname, 443))
ssl_info = conn.getpeercert()
# Python datetime object
return datetime.datetime.strptime(ssl_info["notAfter"], ssl_dateformat)
if __name__ == "__main__":
for value in domains:
now = datetime.datetime.now()
try:
expire = ssl_expiry_datetime(value)
diff = expire - now
print(
"Domain name: {} Expiry Date: {} Expiry Day: {}".format(
value, expire.strftime("%Y-%m-%d"), diff.days
)
)
except Exception as e:
print(e)

View File

@ -0,0 +1,42 @@
import subprocess
import cv2
rtmp_url = "rtmp://127.0.0.1:1935/stream/pupils_trace"
# In my mac webcamera is 0, also you can set a video file name instead, for example "/home/user/demo.mp4"
path = 0
cap = cv2.VideoCapture(path)
# gather video info to ffmpeg
fps = int(cap.get(cv2.CAP_PROP_FPS))
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
# command and params for ffmpeg
command = ['ffmpeg',
'-y',
'-f', 'rawvideo',
'-vcodec', 'rawvideo',
'-pix_fmt', 'bgr24',
'-s', "{}x{}".format(width, height),
'-r', str(fps),
'-i', '-',
'-c:v', 'libx264',
'-pix_fmt', 'yuv420p',
'-preset', 'ultrafast',
'-f', 'flv',
rtmp_url]
# using subprocess and pipe to fetch frame data
p = subprocess.Popen(command, stdin=subprocess.PIPE)
while cap.isOpened():
ret, frame = cap.read()
if not ret:
print("frame read failed")
break
# YOUR CODE FOR PROCESSING FRAME HERE
# write to pipe
p.stdin.write(frame.tobytes())

View File

@ -47,6 +47,5 @@ class SingleMotionDetector:
(x, y, w, h) = cv2.boundingRect(c)
(minX, minY) = (min(minX, x), min(minY, y))
(maxX, maxY) = (max(maxX, x + w), max(maxY, y + h))
# otherwise, return a tuple of the thresholded image along
# with bounding box
# otherwise, return a tuple of the thresholded image along with bounding box
return (thresh, (minX, minY, maxX, maxY))

View File

@ -23,7 +23,7 @@
<body>
<div class="video">
<h1>OpenCV Stream video to web browser/HTML page</h1>
<img class="video-frame" src="{{ url_for('video_feed') }}">
<img class="video-frame rounded" src="{{ url_for('video_feed') }}">
</div>
</body>
</html>