Skip to content

Commit

Permalink
Merge pull request #8 from exddc/imporved_stream
Browse files Browse the repository at this point in the history
Improved Streaming Performance
  • Loading branch information
exddc committed Jun 24, 2024
2 parents 2cc2b12 + 8d668fa commit 8abcf04
Show file tree
Hide file tree
Showing 8 changed files with 229 additions and 133 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ logs/
recordings/
htmx.min.js
.webassets-cache/
dist/
dist/
images/
5 changes: 2 additions & 3 deletions agent/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ PROPERTY_FLOORS=3 # 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10
PROPERTY_FLOOR_NAMES=EG,1OG,2OG # comma separated list of floor names
TEST_MODE=False # True | False
MODULES=relay,video # comma separated list of modules
IMAGE_ON_RING=True # True | False

# MQTT
MQTT_BROKER_IP=192.168.178.1 # IP address or hostname of the MQTT broker
Expand Down Expand Up @@ -43,9 +44,7 @@ SOUND_PLAY_STARTUP_SOUND=FALSE # Play the startup sound on startup
# Video
VIDEO_WIDTH=1920 # Width of the video stream
VIDEO_HEIGHT=1080 # Height of the video stream
VIDEO_FPS=30 # Frames per second of the video stream
VIDEO_BITRATE=1000000 # Bitrate of the video stream
VIDEO_STREAM_PORT=8080 # Port for the video stream
VIDEO_STREAM_PORT=10001 # Port for the video stream
VIDEO_RECORDING_DURATION=10 # Duration of the video recordings in seconds
VIDEO_AUTOSTART=True # Automatically start the video stream on startup

Expand Down
2 changes: 1 addition & 1 deletion agent/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.0
0.2.1
7 changes: 3 additions & 4 deletions agent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,12 @@ def run(self):
"%s agent starting with version: %s", self.__agent_type, self._version
)
self._agent.run()
for module in self._modules:
module.run()
self._internet_connection.start()
self._web_server.run()

for module in self._modules:
module.run()

def _select_agent(self):
"""Select the agent based on the agent type."""
if self.__agent_type == "doorbell":
Expand Down Expand Up @@ -107,7 +108,6 @@ def stop(self):
self._mqtt.stop()
self._web_server.stop()
self._internet_connection.join()
GPIO.cleanup()
LOGGER.info("%s %s agent stopped.", self.__agent_type, self.__agent_location)

def _check_internet_connection(self):
Expand Down Expand Up @@ -176,6 +176,5 @@ def watch_env_file(agent_instance):
# pylint: disable=broad-except
except Exception as e:
LOGGER.error("Agent failed: %s", str(e))
agent.stop()
LOGGER.info("Restarting agent...")
time.sleep(0.5)
9 changes: 5 additions & 4 deletions agent/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ gpiozero
python-dotenv
paho-mqtt==1.6.1
RPi.GPIO
spidev
mfrc522
numpy
#spidev
#mfrc522
#numpy
picamera2
pillow
Flask
Flask-Assets
pytailwindcss
waitress
waitress
flask-socketio
12 changes: 6 additions & 6 deletions agent/templates/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
{% block content %}
<h1 class="font-bold text-lg mx-auto w-fit">Dashboard</h1>
{% if stream_url %}
{% include 'partials/video_stream.html' %}
{% include 'partials/video_stream.html' %}
{% else %}
<div class="max-w-7xl mx-auto rounded-lg bg-gray-100 border border-gray-300 p-1 shadow-lg">
<div class="flex items-center justify-center h-96">
<p class="text-lg text-gray-500">No video stream available</p>
</div>
<div class="max-w-7xl mx-auto rounded-lg bg-gray-100 border border-gray-300 p-1 shadow-lg">
<div class="flex items-center justify-center h-96">
<p class="text-lg text-gray-500">No video stream available</p>
</div>
</div>
{% endif %}
{% endblock content %}
{% endblock %}
Loading

0 comments on commit 8abcf04

Please sign in to comment.