Stream Master Watchdog is a Python script designed to monitor streams in the StreamMaster application. It ensures uninterrupted streaming by detecting buffering issues and automatically switching to the next stream if buffering persists for a configurable period.
- Monitors streams for buffering issues in real-time.
- Displays the current speed of each stream being monitored.
- Detects buffering below a configurable speed threshold.
- Automatically switches to the next stream after prolonged buffering.
- Logs relevant messages to the console, including buffering detection and resolution status.
- Python 3.8 or higher
- Dependencies:
requests
re
subprocess
time
threading
- Clone this repository:
git clone https://github.com/SergeantPanda/StreamMaster-Watchdog.git cd StreamMaster-Watchdog
- Install required Python dependencies:
pip install requests
- Ensure
ffmpeg
is installed and available on your system.
Update the following variables in the script to match your environment:
SERVERURL
: Base URL of your StreamMaster server (e.g.,http://ubuntuserver:7098
).FFMPEG_PATH
: Path to yourffmpeg
executable.USER_AGENT
: Identifier used for the watchdog client.QUERY_INTERVAL
: Interval (in seconds) to query the API for stream updates.BUFFERING_THRESHOLD
: Speed threshold (default:1.0x
) to detect buffering.BUFFERING_TIME_LIMIT
: Time (in seconds) to wait before switching streams when buffering.
- Start the script:
python stream-master-watchdog.py
- The script will:
- Periodically query the StreamMaster API for active streams.
- Monitor each stream's speed using FFmpeg.
- Switch to the next stream if buffering persists.
The script uses the following StreamMaster APIs:
- Endpoint:
/api/statistics/getchannelmetrics
- Method:
GET
- Purpose: Fetches the current active streams and client details.
- Endpoint:
/api/streaming/movetonextstream
- Method:
PATCH
- Payload:
{ "smChannelId": <stream_id> }
- Purpose: Commands StreamMaster to switch to the next stream.
Started watchdog for stream 48
Stream 48 - Speed: 2.84x
Stream 48 - Speed: 0.90x
Buffering detected on stream 48 for 30 seconds.
Switched to the next stream successfully.
Contributions are welcome! Feel free to submit issues or pull requests to improve this script.
This project is licensed under the MIT License. See the LICENSE file for details.
Special thanks to the Stream Master developer Senex for providing a robust API to enhance streaming experiences.