Made some more progress on Docker Compose
This commit is contained in:
parent
37f74127bc
commit
7a32a3eb6f
|
@ -6,11 +6,11 @@ services:
|
||||||
container_name: bridge-wyze
|
container_name: bridge-wyze
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
image: mrlt8/wyze-bridge:latest
|
image: mrlt8/wyze-bridge:latest
|
||||||
# ports:
|
ports:
|
||||||
# - 1935:1935 # RTMP
|
- 1935:1935 # RTMP
|
||||||
# - 8554:8554 # RTSP
|
- 8554:8554 # RTSP
|
||||||
# - 8888:8888 # HLS
|
- 8888:8888 # HLS
|
||||||
# - 5000:5000 # WEB-UI
|
- 5000:5000 # WEB-UI
|
||||||
environment:
|
environment:
|
||||||
- WYZE_EMAIL=${WYZE_EMAIL} # Replace with wyze email
|
- WYZE_EMAIL=${WYZE_EMAIL} # Replace with wyze email
|
||||||
- WYZE_PASSWORD=${WYZE_PASSWORD} # Replace with wyze password
|
- WYZE_PASSWORD=${WYZE_PASSWORD} # Replace with wyze password
|
||||||
|
@ -47,7 +47,7 @@ services:
|
||||||
depends_on:
|
depends_on:
|
||||||
- bridge
|
- bridge
|
||||||
# Use wait-for-it to wait for the bridge at port 8554 to be ready and then run /app/main.py
|
# Use wait-for-it to wait for the bridge at port 8554 to be ready and then run /app/main.py
|
||||||
command: /bin/sh -c "wait-for-it.sh bridge:8554 --timeout=0 --strict -- python /app/main.py"
|
command: /bin/bash -c "wait-for-it.sh -h bridge -p 1935 --timeout=0 --strict -- echo "done" && python /app/main.py"
|
||||||
|
|
||||||
|
|
||||||
# How can this be run and a .env file passed?
|
# How can this be run and a .env file passed?
|
||||||
|
|
26
main.py
26
main.py
|
@ -6,6 +6,8 @@ from dotenv import load_dotenv
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
import pathlib
|
import pathlib
|
||||||
|
import requests
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
|
@ -82,6 +84,27 @@ else:
|
||||||
|
|
||||||
print(f"Current config: {config}")
|
print(f"Current config: {config}")
|
||||||
|
|
||||||
|
# Try this 5 times, 5 seconds apart. If the stream is not available, exit
|
||||||
|
for i in range(5):
|
||||||
|
# Check if HLS stream is available using the requests library
|
||||||
|
# If it is not, print an error and exit
|
||||||
|
try:
|
||||||
|
# Replace rtsp with http and the port with 8888
|
||||||
|
r = requests.get(URL.replace("rtsp", "http").replace(":8554", ":8888"))
|
||||||
|
if r.status_code != 200:
|
||||||
|
print("HLS stream not available, please check your URL")
|
||||||
|
exit()
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
print("HLS stream not available, please check your URL")
|
||||||
|
if i == 4:
|
||||||
|
exit()
|
||||||
|
else:
|
||||||
|
print(f"Retrying in 5 seconds ({i+1}/5)")
|
||||||
|
time.sleep(5)
|
||||||
|
continue
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for face in config["faces"]:
|
for face in config["faces"]:
|
||||||
# Load a sample picture and learn how to recognize it.
|
# Load a sample picture and learn how to recognize it.
|
||||||
image = face_recognition.load_image_file(config["faces"][face]["image"])
|
image = face_recognition.load_image_file(config["faces"][face]["image"])
|
||||||
|
@ -96,6 +119,9 @@ video_capture = cv2.VideoCapture(URL)
|
||||||
# However, this means that the video may be choppy
|
# However, this means that the video may be choppy
|
||||||
video_capture.set(cv2.CAP_PROP_BUFFERSIZE, 1)
|
video_capture.set(cv2.CAP_PROP_BUFFERSIZE, 1)
|
||||||
|
|
||||||
|
# Print the resolution of the video
|
||||||
|
print(f"Video resolution: {video_capture.get(cv2.CAP_PROP_FRAME_WIDTH)}x{video_capture.get(cv2.CAP_PROP_FRAME_HEIGHT)}")
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
# Grab a single frame of video
|
# Grab a single frame of video
|
||||||
ret, frame = video_capture.read()
|
ret, frame = video_capture.read()
|
||||||
|
|
|
@ -7,3 +7,5 @@ numpy==1.23.5
|
||||||
opencv-python==4.6.0.66
|
opencv-python==4.6.0.66
|
||||||
Pillow==9.3.0
|
Pillow==9.3.0
|
||||||
python-dotenv==0.21.0
|
python-dotenv==0.21.0
|
||||||
|
urllib3==1.26.13
|
||||||
|
requests==2.28.1
|
||||||
|
|
Loading…
Reference in New Issue