SliceOfPie is an application that monitors and analyzes video streams, with automatic recording capabilities based on detected activity.
- Real-time video stream monitoring
- Motion and face detection
- Automatic recording of activity
- Integration with MediaMTX streaming server
SliceOfPie integrates with MediaMTX, a multi-protocol media server that supports:
- SRT (Secure Reliable Transport)
- RTMP (Real-Time Messaging Protocol)
- RTSP (Real-Time Streaming Protocol)
- HLS (HTTP Live Streaming)
- WebRTC
The integration provides these capabilities:
- Automatic Server Management: MediaMTX server starts/stops with the application
- Stream Input: Send video to SliceOfPie using any supported protocol (SRT, RTMP, etc.)
- Intelligent Recording: Video is automatically recorded when motion or faces are detected
You can stream to SliceOfPie using any of these methods:
- In OBS, go to Settings > Stream
- Select "Custom..." as the service
- For SRT streaming:
- URL:
srt://YOUR_SERVER_IP:8890 - Stream Key:
YOUR_STREAM_NAME
- URL:
- For RTMP streaming:
- URL:
rtmp://YOUR_SERVER_IP:1935 - Stream Key:
YOUR_STREAM_NAME
- URL:
# Stream using SRT
ffmpeg -i YOUR_INPUT -c:v libx264 -preset veryfast -b:v 3000k -c:a aac -b:a 128k -f mpegts srt://YOUR_SERVER_IP:8890?streamid=YOUR_STREAM_NAME
# Stream using RTMP
ffmpeg -i YOUR_INPUT -c:v libx264 -preset veryfast -b:v 3000k -c:a aac -b:a 128k -f flv rtmp://YOUR_SERVER_IP:1935/YOUR_STREAM_NAME# Stream using SRT
gst-launch-1.0 videotestsrc ! x264enc ! h264parse ! mpegtsmux ! srtserversink uri=srt://YOUR_SERVER_IP:8890/YOUR_STREAM_NAME
# Stream using RTMP
gst-launch-1.0 videotestsrc ! x264enc ! flvmux ! rtmpsink location=rtmp://YOUR_SERVER_IP:1935/YOUR_STREAM_NAMEThe MediaMTX server is configured automatically with default settings. If you want to customize the configuration, edit the mediamtx.yml file in the application directory.
When activity is detected in a stream, SliceOfPie automatically starts recording. Recordings are stored in the recordings folder and are organized by stream name and timestamp.
- Python 3.12+
- GStreamer with appropriate plugins
- GTK 4
- Monitor multiple RTSP video streams from MediaMTX
- Real-time face detection using MediaPipe
- Motion detection for activity analysis
- Automatic recording of active streams
- Live preview of all streams with activity status
- Configurable activity thresholds and weights
- Modern GTK4-based user interface
- Create a virtual environment using
uv:
uv venv
source .venv/bin/activate- Install dependencies:
uv pip install -e .-
Start your MediaMTX server and ensure your video streams are available via RTSP.
-
Run the application:
python -m sliceofpie-
Use the "Add Stream" button to add new video streams to monitor.
-
The application will automatically:
- Display live previews of all streams
- Detect faces and motion in each stream
- Calculate activity scores
- Start/stop recording based on activity
- Highlight active streams in the UI
Each stream can be configured with:
- Activity threshold (default: 0.7)
- Face detection weight (default: 0.8)
- Motion detection weight (default: 0.2)
The application uses:
- GStreamer for video pipeline management
- MediaPipe for face detection
- GTK4 for the user interface
- Asyncio for concurrent stream processing
- Pydantic for data validation
- Code is formatted using Black
- Linting is done with Ruff
- Type hints are mandatory
- Test coverage target: 85%
MIT License
uv pip install -e ./mediamtx/generated