Skip to content

jererobles/sliceofpie

Repository files navigation

SliceOfPie Logo

SliceOfPie is an application that monitors and analyzes video streams, with automatic recording capabilities based on detected activity.

Features

  • Real-time video stream monitoring
  • Motion and face detection
  • Automatic recording of activity
  • Integration with MediaMTX streaming server

MediaMTX Integration

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:

  1. Automatic Server Management: MediaMTX server starts/stops with the application
  2. Stream Input: Send video to SliceOfPie using any supported protocol (SRT, RTMP, etc.)
  3. Intelligent Recording: Video is automatically recorded when motion or faces are detected

Streaming to SliceOfPie

You can stream to SliceOfPie using any of these methods:

From OBS Studio

  1. In OBS, go to Settings > Stream
  2. Select "Custom..." as the service
  3. For SRT streaming:
    • URL: srt://YOUR_SERVER_IP:8890
    • Stream Key: YOUR_STREAM_NAME
  4. For RTMP streaming:
    • URL: rtmp://YOUR_SERVER_IP:1935
    • Stream Key: YOUR_STREAM_NAME

From FFmpeg

# 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

From GStreamer

# 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_NAME

Configuration

The MediaMTX server is configured automatically with default settings. If you want to customize the configuration, edit the mediamtx.yml file in the application directory.

Recordings

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.

Requirements

  • Python 3.12+
  • GStreamer with appropriate plugins
  • GTK 4

Features

  • 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

Installation

  1. Create a virtual environment using uv:
uv venv
source .venv/bin/activate
  1. Install dependencies:
uv pip install -e .

Usage

  1. Start your MediaMTX server and ensure your video streams are available via RTSP.

  2. Run the application:

python -m sliceofpie
  1. Use the "Add Stream" button to add new video streams to monitor.

  2. 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

Configuration

Each stream can be configured with:

  • Activity threshold (default: 0.7)
  • Face detection weight (default: 0.8)
  • Motion detection weight (default: 0.2)

Architecture

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

Development

  • Code is formatted using Black
  • Linting is done with Ruff
  • Type hints are mandatory
  • Test coverage target: 85%

License

MIT License

uv pip install -e ./mediamtx/generated

About

Life vlogging made effortless or how I learned to stop worrying and love Big Brother.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published